[cfe-dev] Patch: Re: -Wshadow rationale for data members
Adam Nohejl
adam+clang at nohejl.name
Fri Nov 12 01:19:15 PST 2010
>> 2.5. An enum constant cannot shadow or be shadowed. Do you agree that enum constants should be treated similarly to variables or, within a class/structure context, to static data members?
>
> I think we shouldn't warn about shadowing enumerators.
I'm not sure whether we mean the same thing. I mean "a" (enum constant), not "A" (enum tag), in "enum A{a};".
Enum constants are little different from variables/static data variables: they can be defined at the same places, have the same scoping rules, and can mostly be used in the same syntactic context (of course there's no storage associated with enum constants).
I can't see why there should be any difference between how x's and y's are handled in the following:
const int x = 0;
enum{ y = 0 };
void f(){
const int x = 1;
enum{ y = 0 };
// ^ or vice versa: const int y, enum{x}
}
struct A{
const int x = 0;
enum{ y = 0 };
};
struct B : public A{
static const int x = 1;
enum{ y = 0 };
// ^ or vice versa: const int y, enum{x}
};
--
Adam
More information about the cfe-dev
mailing list