From: Kamlesh Kumar Date: Fri, 20 Dec 2019 19:41:46 +0000 (-0500) Subject: Apply the alignment specifier attribute to anonymous unions and structs. X-Git-Tag: llvmorg-11-init~1652 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=304d1304b7bac190b6c9733eb07be284bfc17030;p=platform%2Fupstream%2Fllvm.git Apply the alignment specifier attribute to anonymous unions and structs. --- diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 715e875..8f68be7 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5025,6 +5025,8 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, /*BitWidth=*/nullptr, /*Mutable=*/false, /*InitStyle=*/ICIS_NoInit); Anon->setAccess(AS); + ProcessDeclAttributes(S, Anon, Dc); + if (getLangOpts().CPlusPlus) FieldCollector->Add(cast(Anon)); } else { @@ -5038,6 +5040,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, SC = SC_None; } + assert(DS.getAttributes().empty() && "No attribute expected"); Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(), Record->getLocation(), /*IdentifierInfo=*/nullptr, Context.getTypeDeclType(Record), TInfo, SC); diff --git a/clang/test/AST/pr43983.cpp b/clang/test/AST/pr43983.cpp new file mode 100644 index 0000000..0f4f596 --- /dev/null +++ b/clang/test/AST/pr43983.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only %s -ast-dump | FileCheck %s + +struct B { _Alignas(64) struct { int b; }; }; + +// CHECK: AlignedAttr {{.*}} _Alignas +// CHECK: ConstantExpr {{.*}} 64 +// CHECK: IntegerLiteral {{.*}} 64