[cfe-commits] r93862 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/enum.cpp

Douglas Gregor dgregor at apple.com
Mon Jan 18 22:06:57 PST 2010


Author: dgregor
Date: Tue Jan 19 00:06:57 2010
New Revision: 93862

URL: http://llvm.org/viewvc/llvm-project?rev=93862&view=rev
Log:
When looking up enumerator names for redeclaration, use the
ForRedeclaration flag so that we don't look into base classes. 
Fixes PR6061.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/enum.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=93862&r1=93861&r2=93862&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan 19 00:06:57 2010
@@ -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);

Modified: cfe/trunk/test/SemaCXX/enum.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum.cpp?rev=93862&r1=93861&r2=93862&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum.cpp Tue Jan 19 00:06:57 2010
@@ -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 }; 
+  };
+}





More information about the cfe-commits mailing list