forked from OSchip/llvm-project
Make #pragma unused work for static local variables.
llvm-svn: 118500
This commit is contained in:
parent
82f755c58d
commit
ba57154614
|
@ -282,7 +282,7 @@ void Sema::ActOnPragmaUnused(const Token *Identifiers, unsigned NumIdentifiers,
|
|||
}
|
||||
|
||||
VarDecl *VD = Lookup.getAsSingle<VarDecl>();
|
||||
if (!VD || !VD->hasLocalStorage()) {
|
||||
if (!VD || !(VD->hasLocalStorage() || VD->isStaticLocal())) {
|
||||
Diag(PragmaLoc, diag::warn_pragma_unused_expected_localvar)
|
||||
<< Name << SourceRange(Tok.getLocation());
|
||||
continue;
|
||||
|
|
|
@ -59,3 +59,9 @@ namespace PR6948 {
|
|||
X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
|
||||
}
|
||||
}
|
||||
|
||||
void unused_local_static() {
|
||||
static int x = 0;
|
||||
static int y = 0; // expected-warning{{unused variable 'y'}}
|
||||
#pragma unused(x)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue