When looking up enumerator names for redeclaration, use the
ForRedeclaration flag so that we don't look into base classes.
Fixes PR6061.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93862 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 101cae8..d2ac483 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -6095,7 +6095,8 @@
// Verify that there isn't already something declared with this name in this
// scope.
- NamedDecl *PrevDecl = LookupSingleName(S, Id, LookupOrdinaryName);
+ NamedDecl *PrevDecl = LookupSingleName(S, Id, LookupOrdinaryName,
+ ForRedeclaration);
if (PrevDecl && PrevDecl->isTemplateParameter()) {
// Maybe we will complain about the shadowed template parameter.
DiagnoseTemplateParameterShadow(IdLoc, PrevDecl);
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
index f1b02f5..47ae06a 100644
--- a/test/SemaCXX/enum.cpp
+++ b/test/SemaCXX/enum.cpp
@@ -56,3 +56,14 @@
enum enum4 { v4 = __LONG_MAX__ * 2UL };
int test4[is_same<__typeof(+v4), unsigned long>::value];
}
+
+// PR6061
+namespace PR6061 {
+ struct A { enum { id }; };
+ struct B { enum { id }; };
+
+ struct C : public A, public B
+ {
+ enum { id };
+ };
+}