diff options
author | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
commit | 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df (patch) | |
tree | a9243275843fbeaa590afc07ee888e006b8d54ea /lib/Sema/SemaAttr.cpp | |
parent | 69b4eca4a4255ba43baa5c1d9bbdec3ec17f479e (diff) | |
download | FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.zip FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.tar.gz |
Vendor import of clang trunk r126079:
http://llvm.org/svn/llvm-project/cfe/trunk@126079
Diffstat (limited to 'lib/Sema/SemaAttr.cpp')
-rw-r--r-- | lib/Sema/SemaAttr.cpp | 81 |
1 files changed, 50 insertions, 31 deletions
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp index 0921156..794b0b1 100644 --- a/lib/Sema/SemaAttr.cpp +++ b/lib/Sema/SemaAttr.cpp @@ -263,37 +263,35 @@ 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()) { - 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); + + 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) { + Diag(PragmaLoc, diag::warn_pragma_unused_expected_var_arg) + << 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<VisibilityAttr::VisibilityType, - SourceLocation> > VisStack; +typedef std::vector<std::pair<unsigned, SourceLocation> > VisStack; +enum { NoVisibility = (unsigned) -1 }; void Sema::AddPushedVisibilityAttribute(Decl *D) { if (!VisContext) @@ -303,7 +301,11 @@ void Sema::AddPushedVisibilityAttribute(Decl *D) { return; VisStack *Stack = static_cast<VisStack*>(VisContext); - VisibilityAttr::VisibilityType type = Stack->back().first; + unsigned rawType = Stack->back().first; + if (rawType == NoVisibility) return; + + VisibilityAttr::VisibilityType type + = (VisibilityAttr::VisibilityType) rawType; SourceLocation loc = Stack->back().second; D->addAttr(::new (Context) VisibilityAttr(loc, Context, type)); @@ -315,8 +317,7 @@ void Sema::FreeVisContext() { VisContext = 0; } -static void PushPragmaVisibility(Sema &S, VisibilityAttr::VisibilityType type, - SourceLocation loc) { +static void PushPragmaVisibility(Sema &S, unsigned type, SourceLocation loc) { // Put visibility on stack. if (!S.VisContext) S.VisContext = new VisStack; @@ -349,8 +350,26 @@ void Sema::ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType, } } -void Sema::PushVisibilityAttr(const VisibilityAttr *Attr) { - PushPragmaVisibility(*this, Attr->getVisibility(), Attr->getLocation()); +void Sema::ActOnPragmaFPContract(tok::OnOffSwitch OOS) { + switch (OOS) { + case tok::OOS_ON: + FPFeatures.fp_contract = 1; + break; + case tok::OOS_OFF: + FPFeatures.fp_contract = 0; + break; + case tok::OOS_DEFAULT: + FPFeatures.fp_contract = getLangOptions().DefaultFPContract; + break; + } +} + +void Sema::PushNamespaceVisibilityAttr(const VisibilityAttr *Attr) { + // Visibility calculations will consider the namespace's visibility. + // Here we just want to note that we're in a visibility context + // which overrides any enclosing #pragma context, but doesn't itself + // contribute visibility. + PushPragmaVisibility(*this, NoVisibility, SourceLocation()); } void Sema::PopPragmaVisibility() { |