summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-01-16 23:39:20 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-01-16 23:39:20 +0000
commitbeef3453cd12923bd8100a40d6a2e6281dd250ab (patch)
tree48047feba2f0821f10968c4c3d75a436bde0ca2e /clang/lib/Sema/SemaTemplate.cpp
parent98d3c101ddf7e657e2dc6171860fe41f03cb0dfc (diff)
downloadbcm5719-llvm-beef3453cd12923bd8100a40d6a2e6281dd250ab.tar.gz
bcm5719-llvm-beef3453cd12923bd8100a40d6a2e6281dd250ab.zip
Clean up variable template handling a bit, and correct the behavior of name
lookup when declaring a variable template specialization. llvm-svn: 199438
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 97137184c29..ca81472b3c5 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2340,11 +2340,9 @@ static bool isSameAsPrimaryTemplate(TemplateParameterList *Params,
}
DeclResult Sema::ActOnVarTemplateSpecialization(
- Scope *S, VarTemplateDecl *VarTemplate, Declarator &D, TypeSourceInfo *DI,
- SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams,
- VarDecl::StorageClass SC, bool IsPartialSpecialization) {
- assert(VarTemplate && "A variable template id without template?");
-
+ Scope *S, Declarator &D, TypeSourceInfo *DI, SourceLocation TemplateKWLoc,
+ TemplateParameterList *TemplateParams, VarDecl::StorageClass SC,
+ bool IsPartialSpecialization) {
// D must be variable template id.
assert(D.getName().getKind() == UnqualifiedId::IK_TemplateId &&
"Variable template specialization is declared with a template it.");
@@ -2357,7 +2355,14 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
TemplateId->NumArgs);
TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc);
translateTemplateArguments(TemplateArgsPtr, TemplateArgs);
- TemplateName Name(VarTemplate);
+ TemplateName Name = TemplateId->Template.get();
+
+ // The template-id must name a variable template.
+ VarTemplateDecl *VarTemplate =
+ dyn_cast<VarTemplateDecl>(Name.getAsTemplateDecl());
+ if (!VarTemplate)
+ return Diag(D.getIdentifierLoc(), diag::err_var_spec_no_template)
+ << IsPartialSpecialization;
// Check for unexpanded parameter packs in any of the template arguments.
for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
OpenPOWER on IntegriCloud