summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-01-10 02:15:49 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-01-10 02:15:49 +0000
commitf20949c9d512ce322bbba7d4427b1ae9ff3794fe (patch)
tree40dc0e5d1cd3020a3c4c17db796132051553fbfb
parent3be02d1c360e41d4d041bccd59835da82cde4fb7 (diff)
Don't classify variable template names as type templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291528 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp3
-rw-r--r--test/SemaCXX/cxx1y-variable-templates_top_level.cpp5
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index c32757565d..7cb3adb8d3 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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)));
diff --git a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index ec3e2b6f63..367f67bf5f 100644
--- a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -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}}
+}