From 709135b01b238ef34d701ec67219c7e410b265de Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 24 Jun 2014 16:22:41 +0000 Subject: 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 --- lib/Sema/SemaDecl.cpp | 2 ++ test/SemaCXX/anonymous-union-cxx11.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) 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(Mem)) { // Any access specifier is fine. + } else if (isa(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; + }; +}; +} -- cgit v1.2.3