summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-10-28 07:39:29 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-10-28 07:39:29 +0000
commit59a8e49f01ee7ef465deced6f86ef6d0ee9b9319 (patch)
treefa208146d2a4e32d846bcef7ab124e25ebf86db1 /clang/lib/Sema/SemaDecl.cpp
parent2f36dae5c01d46c8c71af594601f125a604226a1 (diff)
downloadbcm5719-llvm-59a8e49f01ee7ef465deced6f86ef6d0ee9b9319.tar.gz
bcm5719-llvm-59a8e49f01ee7ef465deced6f86ef6d0ee9b9319.zip
Revert functional part of r166896 and just suppress -Wunneeded-internal-declaration for reference types for now. This needs more work; the cases we currently miss are a bit random.
llvm-svn: 166899
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6eef427731b..0eb123105b9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1204,18 +1204,17 @@ bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const {
Context.DeclMustBeEmitted(FD))
return false;
} else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+ // Don't warn on variables of const-qualified or reference type, since their
+ // values can be used even if though they're not odr-used, and because const
+ // qualified variables can appear in headers in contexts where they're not
+ // intended to be used.
+ // FIXME: Use more principled rules for these exemptions.
if (!VD->isFileVarDecl() ||
+ VD->getType().isConstQualified() ||
+ VD->getType()->isReferenceType() ||
Context.DeclMustBeEmitted(VD))
return false;
- // If a variable is usable in constant expressions and it's not odr-used,
- // its value may still have been used. Conservatively suppress the warning
- // in this case.
- const VarDecl *VDWithInit = 0;
- if (VD->isUsableInConstantExpressions(Context) &&
- VD->getAnyInitializer(VDWithInit) && VDWithInit->checkInitIsICE())
- return false;
-
if (VD->isStaticDataMember() &&
VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
return false;
OpenPOWER on IntegriCloud