From: Richard Smith Date: Thu, 16 Feb 2012 21:23:54 +0000 (+0000) Subject: Make sure we still reject static data members in anonymous unions in C++11. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=449d4f06fe7501ed53e3aaaa465a499442285e90;p=clang Make sure we still reject static data members in anonymous unions in C++11. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150724 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/class/class.union/p2-0x.cpp b/test/CXX/class/class.union/p2-0x.cpp index d353bda27c..b5c410925c 100644 --- a/test/CXX/class/class.union/p2-0x.cpp +++ b/test/CXX/class/class.union/p2-0x.cpp @@ -34,3 +34,15 @@ union U3 { static const int k; U3() : k(0) {} // expected-error {{does not name a non-static data member}} }; + +struct S { + union { + static const int n; // expected-error {{static members cannot be declared in an anonymous union}} + int a; + int b; + }; +}; +static union { + static const int k; // expected-error {{static members cannot be declared in an anonymous union}} + int n; +};