mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-20 10:07:02 +00:00
[clang] inheritance fix for nomerge attribute
Discussed here: https://reviews.llvm.org/D119061#3310822 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D119451
This commit is contained in:
parent
bfb1a33bec
commit
b2936caf77
@ -1390,7 +1390,6 @@ def : MutualExclusions<[Likely, Unlikely]>;
|
||||
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;
|
||||
|
@ -202,7 +202,7 @@ static Attr *handleNoMergeAttr(Sema &S, Stmt *St, const ParsedAttr &A,
|
||||
|
||||
if (!CEF.foundCallExpr()) {
|
||||
S.Diag(St->getBeginLoc(), diag::warn_nomerge_attribute_ignored_in_stmt)
|
||||
<< NMA.getSpelling();
|
||||
<< A;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ void foobar(void) {
|
||||
__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}}
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ Test *getTest(void);
|
||||
// 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 @@ Test *getTest(void);
|
||||
}
|
||||
|
||||
__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
|
||||
|
16
clang/test/Sema/attr-nomerge-ast.cpp
Normal file
16
clang/test/Sema/attr-nomerge-ast.cpp
Normal file
@ -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
|
@ -6,7 +6,7 @@ void foo() {
|
||||
[[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}}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user