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/Parser/stmt-attributes.c =================================================================== --- clang/test/Parser/stmt-attributes.c +++ clang/test/Parser/stmt-attributes.c @@ -80,7 +80,7 @@ __attribute__((nomerge, unused)) bar(); // expected-error {{expected identifier or '('}} __attribute__((nomerge(1, 2))) bar(); // expected-error {{'nomerge' attribute takes no arguments}} int x; - __attribute__((nomerge)) x = 10; // expected-warning {{nomerge attribute is ignored because there exists no call expression inside the statement}} + __attribute__((nomerge)) x = 10; // expected-warning {{'nomerge' attribute is ignored because there exists no call expression inside the statement}} __attribute__((nomerge)) label : bar(); // expected-error {{'nomerge' attribute only applies to functions and statements}} } Index: clang/test/Parser/stmt-attributes.m =================================================================== --- clang/test/Parser/stmt-attributes.m +++ clang/test/Parser/stmt-attributes.m @@ -29,13 +29,13 @@ // expected-error@-3 {{expected identifier or '('}} // expected-note@-4 {{to match this '['}} __attribute__((nomerge)) [self foo]; - // expected-warning@-1 {{nomerge attribute is ignored because there exists no call expression inside the statement}} + // expected-warning@-1 {{'nomerge' attribute is ignored because there exists no call expression inside the statement}} __attribute__((nomerge)) [getTest() foo]; __attribute__(()) ^{}; // expected-error@-1 {{expected identifier or '('}} __attribute__((nomerge)) ^{}; - // expected-warning@-1 {{nomerge attribute is ignored because there exists no call expression inside the statement}} + // expected-warning@-1 {{'nomerge' attribute is ignored because there exists no call expression inside the statement}} __attribute__((nomerge)) ^{ [self foo]; }(); __attribute__(()) @try { @@ -49,9 +49,9 @@ } __attribute__((nomerge)) (__bridge void *)self; - // expected-warning@-1 {{nomerge attribute is ignored because there exists no call expression inside the statement}} + // expected-warning@-1 {{'nomerge' attribute is ignored because there exists no call expression inside the statement}} __attribute__((nomerge)) self.hasFoobar; - // expected-warning@-1 {{nomerge attribute is ignored because there exists no call expression inside the statement}} + // expected-warning@-1 {{'nomerge' attribute is ignored because there exists no call expression inside the statement}} } @end 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 {{.*}} func 'void ()' +// CHECK-NEXT: NoMergeAttr +// CHECK-NEXT: FunctionDecl {{.*}} func 'void ()' +// CHECK-NEXT: NoMergeAttr {{.*}} Inherited +// CHECK-NEXT: FunctionDecl {{.*}} 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,7 +6,7 @@ [[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}} [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute only applies to functions and statements}}