Allow static_assert inside an anonymous union; fixes PR20021 as well as implements...
authorAaron Ballman <aaron@aaronballman.com>
Tue, 24 Jun 2014 16:22:41 +0000 (16:22 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Tue, 24 Jun 2014 16:22:41 +0000 (16:22 +0000)
llvm-svn: 211606

clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/anonymous-union-cxx11.cpp

index bdc8609..90499d2 100644 (file)
@@ -3754,6 +3754,8 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
         }
       } 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.
index 9f987a9..b0dd1a8 100644 (file)
@@ -12,3 +12,12 @@ namespace PR12866 {
     (void)sizeof(bar::member);
   }
 }
+
+namespace PR20021 {
+class C {
+  union {
+    static_assert(true, "");
+    int i;
+  };
+};
+}