diff options
Diffstat (limited to 'clang/lib/Sema/SemaAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaAttr.cpp | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index de1e1bf6a20..a67c4fbbb22 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -263,37 +263,31 @@ void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name, } } -void Sema::ActOnPragmaUnused(const Token *Identifiers, unsigned NumIdentifiers, - Scope *curScope, - SourceLocation PragmaLoc, - SourceLocation LParenLoc, - SourceLocation RParenLoc) { - - for (unsigned i = 0; i < NumIdentifiers; ++i) { - const Token &Tok = Identifiers[i]; - IdentifierInfo *Name = Tok.getIdentifierInfo(); - LookupResult Lookup(*this, Name, Tok.getLocation(), LookupOrdinaryName); - LookupParsedName(Lookup, curScope, NULL, true); - - if (Lookup.empty()) { - Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var) - << Name << SourceRange(Tok.getLocation()); - continue; - } +void Sema::ActOnPragmaUnused(const Token &IdTok, Scope *curScope, + SourceLocation PragmaLoc) { - VarDecl *VD = Lookup.getAsSingle<VarDecl>(); - if (!VD || !(VD->hasLocalStorage() || VD->isStaticLocal())) { - Diag(PragmaLoc, diag::warn_pragma_unused_expected_localvar) - << Name << SourceRange(Tok.getLocation()); - continue; - } + IdentifierInfo *Name = IdTok.getIdentifierInfo(); + LookupResult Lookup(*this, Name, IdTok.getLocation(), LookupOrdinaryName); + LookupParsedName(Lookup, curScope, NULL, true); - // Warn if this was used before being marked unused. - if (VD->isUsed()) - Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name; + if (Lookup.empty()) { + Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var) + << Name << SourceRange(IdTok.getLocation()); + return; + } - VD->addAttr(::new (Context) UnusedAttr(Tok.getLocation(), Context)); + VarDecl *VD = Lookup.getAsSingle<VarDecl>(); + if (!VD || !(VD->hasLocalStorage() || VD->isStaticLocal())) { + Diag(PragmaLoc, diag::warn_pragma_unused_expected_localvar) + << Name << SourceRange(IdTok.getLocation()); + return; } + + // Warn if this was used before being marked unused. + if (VD->isUsed()) + Diag(PragmaLoc, diag::warn_used_but_marked_unused) << Name; + + VD->addAttr(::new (Context) UnusedAttr(IdTok.getLocation(), Context)); } typedef std::vector<std::pair<unsigned, SourceLocation> > VisStack; |