mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-04 16:41:43 +00:00
[Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute
A variable declared with __attribute__((cleanup)) cannot be unused, as its address is passed to the clean up function. Do not emit -Wunused-variable for variables declared with the cleanup attribute, which matches GCC's behavior: https://godbolt.org/z/dz5YfTsan Reviewed By: erichkeane, nickdesaulniers Differential Revision: https://reviews.llvm.org/D152180
This commit is contained in:
parent
9959cdb66a
commit
877210faa4
@ -1992,7 +1992,8 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (D->hasAttr<UnusedAttr>() || D->hasAttr<ObjCPreciseLifetimeAttr>())
|
||||
if (D->hasAttr<UnusedAttr>() || D->hasAttr<ObjCPreciseLifetimeAttr>() ||
|
||||
D->hasAttr<CleanupAttr>())
|
||||
return false;
|
||||
|
||||
if (isa<LabelDecl>(D))
|
||||
|
@ -30,3 +30,8 @@ int f3(void) {
|
||||
(void)(^() { int X = 4; }); // expected-warning{{unused}}
|
||||
(void)(^() { int X = 4; return Y + X; }); // expected-error {{use of undeclared identifier 'Y'}}
|
||||
}
|
||||
|
||||
void c1(int *);
|
||||
void f4(void) {
|
||||
int __attribute__((cleanup(c1))) X1 = 4;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user