Allow static_assert inside an anonymous union; fixes PR20021 as well as implements C++ Issue 1940.
llvm-svn: 211606
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index bdc8609..90499d2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3754,6 +3754,8 @@
}
} 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/clang/test/SemaCXX/anonymous-union-cxx11.cpp b/clang/test/SemaCXX/anonymous-union-cxx11.cpp
index 9f987a9..b0dd1a8 100644
--- a/clang/test/SemaCXX/anonymous-union-cxx11.cpp
+++ b/clang/test/SemaCXX/anonymous-union-cxx11.cpp
@@ -12,3 +12,12 @@
(void)sizeof(bar::member);
}
}
+
+namespace PR20021 {
+class C {
+ union {
+ static_assert(true, "");
+ int i;
+ };
+};
+}