summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2014-06-24 16:22:41 +0000
committerAaron Ballman <aaron@aaronballman.com>2014-06-24 16:22:41 +0000
commit709135b01b238ef34d701ec67219c7e410b265de (patch)
treeaacd7ac5c60f8bff4f51c7fa3e751e89fcadcbb6
parentd3694b66873bfd1a753527b49752b63f4236e44d (diff)
downloadclang-709135b01b238ef34d701ec67219c7e410b265de.tar.gz
clang-709135b01b238ef34d701ec67219c7e410b265de.tar.bz2
clang-709135b01b238ef34d701ec67219c7e410b265de.tar.xz
Allow static_assert inside an anonymous union; fixes PR20021 as well as implements C++ Issue 1940.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211606 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp2
-rw-r--r--test/SemaCXX/anonymous-union-cxx11.cpp9
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index bdc8609116..90499d2749 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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.
diff --git a/test/SemaCXX/anonymous-union-cxx11.cpp b/test/SemaCXX/anonymous-union-cxx11.cpp
index 9f987a9681..b0dd1a874d 100644
--- a/test/SemaCXX/anonymous-union-cxx11.cpp
+++ b/test/SemaCXX/anonymous-union-cxx11.cpp
@@ -12,3 +12,12 @@ namespace PR12866 {
(void)sizeof(bar::member);
}
}
+
+namespace PR20021 {
+class C {
+ union {
+ static_assert(true, "");
+ int i;
+ };
+};
+}