From: Richard Smith Date: Fri, 25 Apr 2014 19:21:40 +0000 (+0000) Subject: PR19558: don't produce an "unused variable" warning for a variable template partial... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=62034adc96e13107a6f07a3045e560c08165df8e;p=clang PR19558: don't produce an "unused variable" warning for a variable template partial specialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207260 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7603e2c254..ed74c5d47a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9062,7 +9062,8 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) { AddPushedVisibilityAttribute(VD); // FIXME: Warn on unused templates. - if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate()) + if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate() && + !isa(VD)) MarkUnusedFileScopedDecl(VD); // Now we have parsed the initializer and can update the table of magic diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp index ecb36ec274..8dcbe7271d 100644 --- a/test/SemaCXX/warn-unused-variables.cpp +++ b/test/SemaCXX/warn-unused-variables.cpp @@ -122,8 +122,19 @@ namespace PR19305 { template const int l = 0; // no warning int b = l; + // PR19558 + template const int o = 0; // no warning + template const int o = 0; // no warning + int c = o; + + template<> int o = 0; // no warning + int d = o; + // FIXME: It'd be nice to warn here. template int m = 0; + template int m = 0; + + template<> const int m = 0; // expected-warning {{unused variable}} } namespace ctor_with_cleanups {