Silence the -Wshadow warning for enumerators shadowing a type.

Amends r344259 so that enumerators shadowing types are not diagnosed, as shadowing under those circumstances is rarely (if ever) an issue in practice.

llvm-svn: 344898
This commit is contained in:
Aaron Ballman 2018-10-22 13:05:53 +00:00
parent c6c894b88f
commit a529bc3d26
3 changed files with 15 additions and 1 deletions

View File

@ -16295,7 +16295,7 @@ Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl, Decl *lastEnumConst,
return nullptr;
if (PrevDecl) {
if (!TheEnumDecl->isScoped()) {
if (!TheEnumDecl->isScoped() && isa<ValueDecl>(PrevDecl)) {
// Check for other kinds of shadowing not already handled.
CheckShadow(New, PrevDecl, R);
}

View File

@ -64,3 +64,10 @@ enum PR24718_1{pr24718}; // expected-note {{previous declaration is here}}
void PR24718(void) {
enum PR24718_2{pr24718}; // expected-warning {{declaration shadows a variable in the global scope}}
}
struct PR24718_3;
struct PR24718_4 {
enum {
PR24718_3 // Does not shadow a type.
};
};

View File

@ -225,3 +225,10 @@ void f(int a) {
int PR24718;
enum class X { PR24718 }; // Ok, not shadowing
struct PR24718_1;
struct PR24718_2 {
enum {
PR24718_1 // Does not shadow a type.
};
};