summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-09-18 02:10:12 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-09-18 02:10:12 +0000
commitef985ac91c0752dd6515a422778e056064cee9de (patch)
treeac900c7f4945aff93adbbdca5b041756435643c2 /clang/lib
parent1d24af872df47c0baad9cc291a05575c2e4947d5 (diff)
downloadbcm5719-llvm-ef985ac91c0752dd6515a422778e056064cee9de.tar.gz
bcm5719-llvm-ef985ac91c0752dd6515a422778e056064cee9de.zip
Fix accepts-invalid if a variable template explicit instantiation is missing an
argument list, but could be instantiated with argument list of <>. llvm-svn: 190913
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index c5b97d608e2..f6863fb2799 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -7243,17 +7243,27 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
return true;
}
- TemplateArgumentListInfo TemplateArgs;
- if (D.getName().getKind() == UnqualifiedId::IK_TemplateId) {
- // Translate the parser's template argument list into our AST format.
- TemplateIdAnnotation *TemplateId = D.getName().TemplateId;
- TemplateArgs.setLAngleLoc(TemplateId->LAngleLoc);
- TemplateArgs.setRAngleLoc(TemplateId->RAngleLoc);
- ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
- TemplateId->NumArgs);
- translateTemplateArguments(TemplateArgsPtr, TemplateArgs);
+ if (D.getName().getKind() != UnqualifiedId::IK_TemplateId) {
+ // C++1y [temp.explicit]p3:
+ // If the explicit instantiation is for a variable, the unqualified-id
+ // in the declaration shall be a template-id.
+ Diag(D.getIdentifierLoc(),
+ diag::err_explicit_instantiation_without_template_id)
+ << PrevTemplate;
+ Diag(PrevTemplate->getLocation(),
+ diag::note_explicit_instantiation_here);
+ return true;
}
+ // Translate the parser's template argument list into our AST format.
+ TemplateArgumentListInfo TemplateArgs;
+ TemplateIdAnnotation *TemplateId = D.getName().TemplateId;
+ TemplateArgs.setLAngleLoc(TemplateId->LAngleLoc);
+ TemplateArgs.setRAngleLoc(TemplateId->RAngleLoc);
+ ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
+ TemplateId->NumArgs);
+ translateTemplateArguments(TemplateArgsPtr, TemplateArgs);
+
DeclResult Res = CheckVarTemplateId(PrevTemplate, TemplateLoc,
D.getIdentifierLoc(), TemplateArgs);
if (Res.isInvalid())
OpenPOWER on IntegriCloud