Hi rsmith,

The language forbids defining enums in prototypes, so this check is normally
redundant, but if an enum is defined during template instantiation it should
not be added to the prototype scope.

http://llvm-reviews.chandlerc.com/D2742

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaTemplate/instantiate-enum.cpp

Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12952,7 +12952,7 @@
 
   // If we're declaring a function, ensure this decl isn't forgotten about -
   // it needs to go into the function scope.
-  if (InFunctionDeclarator)
+  if (!getLangOpts().CPlusPlus && InFunctionDeclarator)
     DeclsInPrototypeScope.push_back(Enum);
 
   CheckForDuplicateEnumValues(*this, Elements, Enum, EnumType);
Index: test/SemaTemplate/instantiate-enum.cpp
===================================================================
--- test/SemaTemplate/instantiate-enum.cpp
+++ test/SemaTemplate/instantiate-enum.cpp
@@ -25,3 +25,18 @@
 
   template void f<int>();
 }
+
+namespace EnumScoping {
+
+template <typename T>
+class C {
+  enum {
+    value = 42
+  };
+};
+
+void f(int i, C<int>::C c) {
+  int value;
+}
+
+}
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -12952,7 +12952,7 @@
 
   // If we're declaring a function, ensure this decl isn't forgotten about -
   // it needs to go into the function scope.
-  if (InFunctionDeclarator)
+  if (!getLangOpts().CPlusPlus && InFunctionDeclarator)
     DeclsInPrototypeScope.push_back(Enum);
 
   CheckForDuplicateEnumValues(*this, Elements, Enum, EnumType);
Index: test/SemaTemplate/instantiate-enum.cpp
===================================================================
--- test/SemaTemplate/instantiate-enum.cpp
+++ test/SemaTemplate/instantiate-enum.cpp
@@ -25,3 +25,18 @@
 
   template void f<int>();
 }
+
+namespace EnumScoping {
+
+template <typename T>
+class C {
+  enum {
+    value = 42
+  };
+};
+
+void f(int i, C<int>::C c) {
+  int value;
+}
+
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to