diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index b469217108cee7..6d857e832c4bb4 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7019,8 +7019,9 @@ NamedDecl *Sema::ActOnVariableDeclarator( } } - NewVD->addAttr(::new (Context) AsmLabelAttr( - Context, SE->getStrTokenLoc(0), Label, /*IsLiteralLabel=*/true)); + NewVD->addAttr(AsmLabelAttr::Create(Context, Label, + /*IsLiteralLabel=*/true, + SE->getStrTokenLoc(0))); } else if (!ExtnameUndeclaredIdentifiers.empty()) { llvm::DenseMap::iterator I = ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier()); @@ -8923,9 +8924,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (Expr *E = (Expr*) D.getAsmLabel()) { // The parser guarantees this is a string. StringLiteral *SE = cast(E); - NewFD->addAttr(::new (Context) - AsmLabelAttr(Context, SE->getStrTokenLoc(0), - SE->getString(), /*IsLiteralLabel=*/true)); + NewFD->addAttr(AsmLabelAttr::Create(Context, SE->getString(), + /*IsLiteralLabel=*/true, + SE->getStrTokenLoc(0))); } else if (!ExtnameUndeclaredIdentifiers.empty()) { llvm::DenseMap::iterator I = ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier()); diff --git a/clang/test/AST/ast-print-attr.c b/clang/test/AST/ast-print-attr.c index 223e27b3979081..6448437c5eabe8 100644 --- a/clang/test/AST/ast-print-attr.c +++ b/clang/test/AST/ast-print-attr.c @@ -10,3 +10,8 @@ using B = int ** __ptr32 *[3]; // FIXME: Too many parens here! // CHECK: using C = int ((*))() __attribute__((cdecl)); using C = int (*)() [[gnu::cdecl]]; + +// CHECK: int fun_asm() asm(""); +int fun_asm() asm(""); +// CHECK: int var_asm asm(""); +int var_asm asm("");