]> granicus.if.org Git - clang/commitdiff
PR19558: don't produce an "unused variable" warning for a variable template partial...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 25 Apr 2014 19:21:40 +0000 (19:21 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 25 Apr 2014 19:21:40 +0000 (19:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207260 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/warn-unused-variables.cpp

index 7603e2c2541e598643d38cc202d5ca966d56ee89..ed74c5d47ae87e99d84ead41ee7e08e21347d37d 100644 (file)
@@ -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
index ecb36ec2749d9fa3738235d617af4739404f1933..8dcbe7271d69d0114737874d63eba4846ee60820 100644 (file)
@@ -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 {