[PATCH] D38109: [fixup][Sema] Allow in C to define tags inside enumerations.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 21 10:43:26 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL313894: [fixup][Sema] Allow in C to define tags inside enumerations. (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D38109?vs=116110&id=116219#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38109

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/enum.c


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13916,7 +13916,8 @@
     Invalid = true;
   }
 
-  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() == Decl::Enum) {
+  if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition &&
+      DC->getDeclKind() == Decl::Enum) {
     Diag(New->getLocation(), diag::err_type_defined_in_enum)
       << Context.getTagDeclType(New);
     Invalid = true;
Index: cfe/trunk/test/Sema/enum.c
===================================================================
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -125,9 +125,10 @@
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
 
 // PR28903
+// In C it is valid to define tags inside enums.
 struct PR28903 {
   enum {
-    PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at {{.*}})' cannot be defined in an enumeration}}
+    PR28903_A = (enum {
       PR28903_B,
       PR28903_C = PR28903_B
     })0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38109.116219.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170921/022bf3c8/attachment.bin>


More information about the cfe-commits mailing list