diff options
-rw-r--r-- | lib/Sema/SemaAttr.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/warn-unused-variables.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp index d7290c3089..02b8289022 100644 --- a/lib/Sema/SemaAttr.cpp +++ b/lib/Sema/SemaAttr.cpp @@ -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; diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp index 6992cdcd09..8ae7d6ace4 100644 --- a/test/SemaCXX/warn-unused-variables.cpp +++ b/test/SemaCXX/warn-unused-variables.cpp @@ -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) +} |