diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2013-09-10 21:10:25 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2013-09-10 21:10:25 +0000 |
| commit | a5dfebdcfd5fd8ac3f84a5b87eebbb1e9a142e4c (patch) | |
| tree | 7e252a972be2a044837dc416aa7dc2bba9c551a1 /clang/lib/Sema | |
| parent | 1ea6f1e7f9029960842969374ba3b06f416a3df9 (diff) | |
| download | bcm5719-llvm-a5dfebdcfd5fd8ac3f84a5b87eebbb1e9a142e4c.tar.gz bcm5719-llvm-a5dfebdcfd5fd8ac3f84a5b87eebbb1e9a142e4c.zip | |
Fix regression from r190382.
Make sure we perform the correct "referenced-but-not-used" check for
static member constants.
Fixes bug reported on cfe-commits by Alexey Samsonov.
llvm-svn: 190437
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 8 |
2 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index fbff9499d53..91f6d5f7c21 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -358,6 +358,15 @@ static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) { } if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { + // If a variable usable in constant expressions is referenced, + // don't warn if it isn't used: if the value of a variable is required + // for the computation of a constant expression, it doesn't make sense to + // warn even if the variable isn't odr-used. (isReferenced doesn't + // precisely reflect that, but it's a decent approximation.) + if (VD->isReferenced() && + VD->isUsableInConstantExpressions(SemaRef->Context)) + return true; + // UnusedFileScopedDecls stores the first declaration. // The declaration may have become definition so check again. const VarDecl *DeclToCheck = VD->getDefinition(); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 5dbfa105e13..9c93e113125 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1220,14 +1220,6 @@ bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const { if (!isMainFileLoc(*this, VD->getLocation())) return false; - // If a variable usable in constant expressions is referenced, - // don't warn if it isn't used: if the value of a variable is required - // for the computation of a constant expression, it doesn't make sense to - // warn even if the variable isn't odr-used. (isReferenced doesn't - // precisely reflect that, but it's a decent approximation.) - if (VD->isReferenced() && VD->isUsableInConstantExpressions(Context)) - return false; - if (Context.DeclMustBeEmitted(VD)) return false; |

