]> granicus.if.org Git - clang/commitdiff
Relaxed enumeration constant naming rules for scoped enumerators so they no longer...
authorAaron Ballman <aaron@aaronballman.com>
Thu, 19 Jul 2012 03:12:23 +0000 (03:12 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Thu, 19 Jul 2012 03:12:23 +0000 (03:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160490 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/enum-scoped.cpp

index 4041ccf9d39cf6a68a8d5669a3499a82133d39bd..6c6aeb1ab146fe87ccdd9421739322bec0d0a4d4 100644 (file)
@@ -10406,15 +10406,21 @@ Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl, Decl *lastEnumConst,
     }
   }
 
-  // C++ [class.mem]p13:
-  //   If T is the name of a class, then each of the following shall have a 
-  //   name different from T:
-  //     - every enumerator of every member of class T that is an enumerated 
-  //       type
+  // C++ [class.mem]p15:
+  // If T is the name of a class, then each of the following shall have a name 
+  // different from T:
+  // - every enumerator of every member of class T that is an unscoped 
+  // enumerated type
+  //
+  // C++ [dcl.enum]p10:
+  // Each enum-name and each unscoped enumerator is declared in the scope that 
+  // immediately contains the enum-specifier. Each scoped enumerator is declared 
+  // in the scope of the enumeration.
   if (CXXRecordDecl *Record
                       = dyn_cast<CXXRecordDecl>(
                              TheEnumDecl->getDeclContext()->getRedeclContext()))
-    if (Record->getIdentifier() && Record->getIdentifier() == Id)
+    if (!TheEnumDecl->isScoped() && 
+        Record->getIdentifier() && Record->getIdentifier() == Id)
       Diag(IdLoc, diag::err_member_name_of_class) << Id;
   
   EnumConstantDecl *New =
index ebe924535850b4e609ad15ec99d06422285aa050..a1f911d79d395af53d26f1858b8f89b4b92ba92e 100644 (file)
@@ -245,3 +245,10 @@ namespace test10 {
   int m = g<int>();
   int n = g<short>(); // expected-note {{here}}
 }
+
+namespace pr13128 {
+  // This should compile cleanly
+  class C {
+    enum class E { C };
+  };
+}