r291528 - Don't classify variable template names as type templates.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 18:15:49 PST 2017


Author: rsmith
Date: Mon Jan  9 20:15:49 2017
New Revision: 291528

URL: http://llvm.org/viewvc/llvm-project?rev=291528&view=rev
Log:
Don't classify variable template names as type templates.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=291528&r1=291527&r2=291528&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan  9 20:15:49 2017
@@ -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)));
 

Modified: cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp?rev=291528&r1=291527&r2=291528&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp Mon Jan  9 20:15:49 2017
@@ -464,3 +464,8 @@ template <typename... Args> Variadic_t<A
 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}}
+}




More information about the cfe-commits mailing list