Make #pragma unused work for static local variables.

llvm-svn: 118500
This commit is contained in:
Douglas Gregor 2010-11-09 14:57:47 +00:00
parent 82f755c58d
commit ba57154614
2 changed files with 7 additions and 1 deletions

View File

@ -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;

View File

@ -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)
}