PR18530: Don't assert when performing error recovery after a missing 'template<>' on a variable template explicit specialization.

llvm-svn: 200099
This commit is contained in:
Richard Smith 2014-01-25 21:32:06 +00:00
parent f137f9317b
commit 72db563280
2 changed files with 12 additions and 12 deletions

View File

@ -5129,7 +5129,7 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
<< SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc)
<< FixItHint::CreateInsertion(D.getDeclSpec().getLocStart(),
"template<> ");
IsVariableTemplateSpecialization = true;
IsExplicitSpecialization = true;
TemplateParams = TemplateParameterList::Create(Context, SourceLocation(),
SourceLocation(), 0, 0,
SourceLocation());
@ -5206,18 +5206,13 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
SetNestedNameSpecifier(NewVD, D);
// FIXME: Do we need D.getCXXScopeSpec().isSet()?
if (TemplateParams && TemplateParamLists.size() > 1 &&
(!IsVariableTemplateSpecialization || D.getCXXScopeSpec().isSet())) {
// If we have any template parameter lists that don't directly belong to
// the variable (matching the scope specifier), store them.
unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
if (TemplateParamLists.size() > VDTemplateParamLists)
NewVD->setTemplateParameterListsInfo(
Context, TemplateParamLists.size() - 1, TemplateParamLists.data());
} else if (IsVariableTemplateSpecialization ||
(!TemplateParams && TemplateParamLists.size() > 0 &&
(D.getCXXScopeSpec().isSet()))) {
NewVD->setTemplateParameterListsInfo(Context,
TemplateParamLists.size(),
TemplateParamLists.data());
}
Context, TemplateParamLists.size() - VDTemplateParamLists,
TemplateParamLists.data());
if (D.getDeclSpec().isConstexprSpecified())
NewVD->setConstexpr(true);

View File

@ -436,3 +436,8 @@ namespace nested_name {
class a<int> {}; // expected-error {{identifier followed by '<' indicates a class template specialization but 'a' refers to a variable template}}
enum a<int> {}; // expected-error {{expected identifier or '{'}} expected-warning {{does not declare anything}}
}
namespace PR18530 {
template<typename T> int a;
int a<int>; // expected-error {{requires 'template<>'}}
}