r211606 - Allow static_assert inside an anonymous union; fixes PR20021 as well as implements C++ Issue 1940.

Aaron Ballman aaron at aaronballman.com
Tue Jun 24 09:22:42 PDT 2014


Author: aaronballman
Date: Tue Jun 24 11:22:41 2014
New Revision: 211606

URL: http://llvm.org/viewvc/llvm-project?rev=211606&view=rev
Log:
Allow static_assert inside an anonymous union; fixes PR20021 as well as implements C++ Issue 1940.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/anonymous-union-cxx11.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=211606&r1=211605&r2=211606&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jun 24 11:22:41 2014
@@ -3754,6 +3754,8 @@ Decl *Sema::BuildAnonymousStructOrUnion(
         }
       } else if (isa<AccessSpecDecl>(Mem)) {
         // Any access specifier is fine.
+      } else if (isa<StaticAssertDecl>(Mem)) {
+        // In C++1z, static_assert declarations are also fine.
       } else {
         // We have something that isn't a non-static data
         // member. Complain about it.

Modified: cfe/trunk/test/SemaCXX/anonymous-union-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/anonymous-union-cxx11.cpp?rev=211606&r1=211605&r2=211606&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/anonymous-union-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/anonymous-union-cxx11.cpp Tue Jun 24 11:22:41 2014
@@ -12,3 +12,12 @@ namespace PR12866 {
     (void)sizeof(bar::member);
   }
 }
+
+namespace PR20021 {
+class C {
+  union {
+    static_assert(true, "");
+    int i;
+  };
+};
+}





More information about the cfe-commits mailing list