Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20264,9 +20264,10 @@ Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl, Decl *lastEnumConst,
// different from T:
// - every enumerator of every member of class T that is an unscoped
// enumerated type
if (getLangOpts().CPlusPlus && !TheEnumDecl->isScoped())
DiagnoseClassNameShadow(TheEnumDecl->getDeclContext(),
DeclarationNameInfo(Id, IdLoc));
if (getLangOpts().CPlusPlus && !TheEnumDecl->isScoped() &&
DiagnoseClassNameShadow(TheEnumDecl->getDeclContext(),
DeclarationNameInfo(Id, IdLoc)))
return nullptr;

EnumConstantDecl *New =
CheckEnumConstant(TheEnumDecl, LastEnumConst, IdLoc, Id, Val);
Expand Down
9 changes: 9 additions & 0 deletions clang/test/CXX/class/class.mem/p13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,12 @@ template<typename B> struct CtorDtorName : B {
CtorDtorName();
~CtorDtorName(); // expected-error {{identifier 'CtorDtorName' after '~' in destructor name does not name a type}}
};

struct S { // expected-note {{'S' declared here}}
enum E {
R = 11,
S = 12 // expected-error {{member 'S' has the same name as its class}}
};
static_assert(E::R == 11, "E::R is not 11");
static_assert(E::S == 12, "E::S is not 12"); // expected-error {{no member named 'S' in 'S::E'}}
};