[cfe-dev] -Wshadow rationale for data members
Axel Naumann
Axel.Naumann at cern.ch
Thu Oct 21 02:43:30 PDT 2010
Hi,
struct A {
static void* f; void* g;
struct B { static void* f; void* g; };
};
struct C { static void* f; void* g;};
struct D: public C { static void* f; void* g; };
compiled with
clang++ -c -Wall -Wshadow -O2 t.cxx
generates the warning
t.cxx:3:28: warning: declaration shadows a static data member of 'A'
[-Wshadow]
struct B { static void* f; void* g; };
^
t.cxx:2:17: note: previous declaration is here
static void* f; void* g;
^
What about non-static members? And why only for nested classes (B), not
for inheritance (D)? Shouldn't nested classes be allowed to re-define
static variables with the same name as an outer one?
Cheers, Axel.
More information about the cfe-dev
mailing list