]> granicus.if.org Git - clang/commitdiff
Don't classify variable template names as type templates.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 10 Jan 2017 02:15:49 +0000 (02:15 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 10 Jan 2017 02:15:49 +0000 (02:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291528 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/cxx1y-variable-templates_top_level.cpp

index c32757565dd10ac624040031e250436ab13cd486..7cb3adb8d3b906609503b934486ee36e85cb70d0 100644 (file)
@@ -1044,7 +1044,8 @@ Corrected:
   }
 
   // We can have a type template here if we're classifying a template argument.
-  if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl))
+  if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl) &&
+      !isa<VarTemplateDecl>(FirstDecl))
     return NameClassification::TypeTemplate(
         TemplateName(cast<TemplateDecl>(FirstDecl)));
 
index ec3e2b6f63d106c81ec35793bc38aefb8f317721..367f67bf5fa8f04c11eda0cc22c7278b037aa0a8 100644 (file)
@@ -464,3 +464,8 @@ template <typename... Args> Variadic_t<Args...> Variadic;
 auto variadic1 = Variadic<>;
 auto variadic2 = Variadic<int, int>;
 #endif
+
+namespace VexingParse {
+  template <typename> int var; // expected-note {{declared here}}
+  int x(var); // expected-error {{cannot refer to variable template 'var' without a template argument list}}
+}