diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-10-28 07:39:29 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-10-28 07:39:29 +0000 |
commit | c36e3596be351a557cc81c8db3ea75fa4bd54c7a (patch) | |
tree | 56f9d311ede41abf41cf4662abf73f6b01ea7e40 /lib/Sema/SemaDecl.cpp | |
parent | 1432a43e3076eec84967305bd85bace3a6e9102b (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 6eef427731..0eb123105b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/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; |