Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -1379,7 +1379,6 @@ def NoMerge : DeclOrStmtAttr { let Spellings = [Clang<"nomerge">]; let Documentation = [NoMergeDocs]; - let InheritEvenIfAlreadyPresent = 1; let Subjects = SubjectList<[Function, Stmt], ErrorDiag, "functions and statements">; let SimpleHandler = 1; Index: clang/lib/Sema/SemaStmtAttr.cpp =================================================================== --- clang/lib/Sema/SemaStmtAttr.cpp +++ clang/lib/Sema/SemaStmtAttr.cpp @@ -202,7 +202,7 @@ if (!CEF.foundCallExpr()) { S.Diag(St->getBeginLoc(), diag::warn_nomerge_attribute_ignored_in_stmt) - << NMA.getSpelling(); + << A; return nullptr; } Index: clang/test/Sema/attr-nomerge-ast.cpp =================================================================== --- /dev/null +++ clang/test/Sema/attr-nomerge-ast.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -ast-dump %s 2>&1 | FileCheck %s + +[[clang::nomerge]] void func(); +[[clang::nomerge]] void func(); +void func(); +[[clang::nomerge]] void func() {} + +// CHECK: FunctionDecl {{.*}} func 'void ()' +// CHECK-NEXT: NoMergeAttr {{.*}} +// CHECK-NEXT: FunctionDecl {{.*}} col:25 func 'void ()' +// CHECK-NEXT: NoMergeAttr {{.*}} +// CHECK-NEXT: FunctionDecl {{.*}} col:6 func 'void ()' +// CHECK-NEXT: NoMergeAttr {{.*}} Inherited +// CHECK-NEXT: FunctionDecl {{.*}} col:25 func 'void ()' +// CHECK-NEXT: CompoundStmt {{.*}} +// CHECK-NEXT: NoMergeAttr {{.*}} Index: clang/test/Sema/attr-nomerge.cpp =================================================================== --- clang/test/Sema/attr-nomerge.cpp +++ clang/test/Sema/attr-nomerge.cpp @@ -6,8 +6,8 @@ [[clang::nomerge]] bar(); [[clang::nomerge(1, 2)]] bar(); // expected-error {{'nomerge' attribute takes no arguments}} int x; - [[clang::nomerge]] x = 10; // expected-warning {{nomerge attribute is ignored because there exists no call expression inside the statement}} - + [[clang::nomerge]] x = 10; // expected-warning {{'nomerge' attribute is ignored because there exists no call expression inside the statement}} +// FIXME: labeled statement should be accepted [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute only applies to functions and statements}} }