diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-25 19:21:40 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-25 19:21:40 +0000 |
commit | 62034adc96e13107a6f07a3045e560c08165df8e (patch) | |
tree | 2f1bb5a468b468c02904af3769f7f7319fa84dea | |
parent | 653f5c673baa5288e285b5be30aacaf1f70d7d5b (diff) | |
download | clang_35a-62034adc96e13107a6f07a3045e560c08165df8e.tar.gz |
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
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/warn-unused-variables.cpp | 11 |
2 files changed, 13 insertions, 1 deletions
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<VarTemplatePartialSpecializationDecl>(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<typename T> const int l = 0; // no warning int b = l<int>; + // PR19558 + template<typename T> const int o = 0; // no warning + template<typename T> const int o<T*> = 0; // no warning + int c = o<int*>; + + template<> int o<void> = 0; // no warning + int d = o<void>; + // FIXME: It'd be nice to warn here. template<typename T> int m = 0; + template<typename T> int m<T*> = 0; + + template<> const int m<void> = 0; // expected-warning {{unused variable}} } namespace ctor_with_cleanups { |