diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-02 18:28:36 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-02 18:28:36 +0000 |
commit | c392617cff4f5293c6a1c62a1d2dd3aa048c68ac (patch) | |
tree | 1df5040a2cd08761ace27d34beeb918f3c82ee95 /clang/lib/Sema/SemaDecl.cpp | |
parent | 65813a3bce7cb1806a5c510ca0685f02c83720ad (diff) | |
download | bcm5719-llvm-c392617cff4f5293c6a1c62a1d2dd3aa048c68ac.tar.gz bcm5719-llvm-c392617cff4f5293c6a1c62a1d2dd3aa048c68ac.zip |
PR19305: Don't issue -Wunused-variable warnings on variable templates. It's not
meaningful to odr-use the VarDecl inside a variable template. (Separately, it'd
be nice to track referenced-ness for templates, and warn on unused ones, but
that's really a distinct issue...)
Move a test that generates and tests a warning-suppressing error out to its own
test file, so it doesn't have weird effects on the other tests in the same file.
llvm-svn: 205448
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 9d7f13cdd78..43d855c0cb9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1204,7 +1204,8 @@ bool Sema::ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const { if (D->isInvalidDecl() || D->isUsed() || D->hasAttr<UnusedAttr>()) return false; - // Ignore class templates. + // Ignore all entities declared within templates, and out-of-line definitions + // of members of class templates. if (D->getDeclContext()->isDependentContext() || D->getLexicalDeclContext()->isDependentContext()) return false; @@ -9044,7 +9045,8 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) { if (DC->getRedeclContext()->isFileContext() && VD->isExternallyVisible()) AddPushedVisibilityAttribute(VD); - if (VD->isFileVarDecl()) + // FIXME: Warn on unused templates. + if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate()) MarkUnusedFileScopedDecl(VD); // Now we have parsed the initializer and can update the table of magic |