зеркало из https://github.com/microsoft/clang-1.git
When in C++, make EnumConstant names hide tag names in the same scope, instead of colliding with them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53702 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
b2a39459f5
Коммит
0ff12f078c
|
@ -2121,7 +2121,12 @@ Sema::DeclTy *Sema::ActOnEnumConstant(Scope *S, DeclTy *theEnumDecl,
|
|||
// Verify that there isn't already something declared with this name in this
|
||||
// scope.
|
||||
if (Decl *PrevDecl = LookupDecl(Id, Decl::IDNS_Ordinary, S)) {
|
||||
if (IdResolver.isDeclInScope(PrevDecl, CurContext, S)) {
|
||||
// When in C++, we may get a TagDecl with the same name; in this case the
|
||||
// enum constant will 'hide' the tag.
|
||||
assert((getLangOptions().CPlusPlus || !isa<TagDecl>(PrevDecl)) &&
|
||||
"Received TagDecl when not in C++!");
|
||||
if (!isa<TagDecl>(PrevDecl) &&
|
||||
IdResolver.isDeclInScope(PrevDecl, CurContext, S)) {
|
||||
if (isa<EnumConstantDecl>(PrevDecl))
|
||||
Diag(IdLoc, diag::err_redefinition_of_enumerator, Id->getName());
|
||||
else
|
||||
|
|
|
@ -48,3 +48,5 @@ void bar3() {
|
|||
}
|
||||
|
||||
enum E e2;
|
||||
|
||||
enum E2 { E2 };
|
||||
|
|
Загрузка…
Ссылка в новой задаче