diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-03-04 21:37:14 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-03-04 21:37:14 +0000 |
commit | 6cd9d4aa13c2145c8b4398453974515b734bfe42 (patch) | |
tree | 32e2b9ddbad8409e4d8e56de3564249fd8ab8fef /lib/Parse/ParseExprCXX.cpp | |
parent | a93fc9f053bae84cf7c2a04ea6b1b26e0ea44d8f (diff) |
Teach Sema::ActOnCXXNestedNameSpecifier and Sema::CheckTemplateIdType
to cope with non-type templates by providing appropriate
errors. Previously, we would either assert, crash, or silently build a
dependent type when we shouldn't. Fixes PR9226.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127037 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index eef2f5e635..d09f20e113 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -197,42 +197,37 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, return false; } - if (TemplateId->Kind == TNK_Type_template || - TemplateId->Kind == TNK_Dependent_template_name) { - // Consume the template-id token. - ConsumeToken(); - - assert(Tok.is(tok::coloncolon) && "NextToken() not working properly!"); - SourceLocation CCLoc = ConsumeToken(); + // Consume the template-id token. + ConsumeToken(); + + assert(Tok.is(tok::coloncolon) && "NextToken() not working properly!"); + SourceLocation CCLoc = ConsumeToken(); - if (!HasScopeSpecifier) - HasScopeSpecifier = true; - - ASTTemplateArgsPtr TemplateArgsPtr(Actions, - TemplateId->getTemplateArgs(), - TemplateId->NumArgs); - - if (Actions.ActOnCXXNestedNameSpecifier(getCurScope(), - /*FIXME:*/SourceLocation(), - SS, - TemplateId->Template, - TemplateId->TemplateNameLoc, - TemplateId->LAngleLoc, - TemplateArgsPtr, - TemplateId->RAngleLoc, - CCLoc, - EnteringContext)) { - SourceLocation StartLoc - = SS.getBeginLoc().isValid()? SS.getBeginLoc() - : TemplateId->TemplateNameLoc; - SS.SetInvalid(SourceRange(StartLoc, CCLoc)); - } - - TemplateId->Destroy(); - continue; + if (!HasScopeSpecifier) + HasScopeSpecifier = true; + + ASTTemplateArgsPtr TemplateArgsPtr(Actions, + TemplateId->getTemplateArgs(), + TemplateId->NumArgs); + + if (Actions.ActOnCXXNestedNameSpecifier(getCurScope(), + /*FIXME:*/SourceLocation(), + SS, + TemplateId->Template, + TemplateId->TemplateNameLoc, + TemplateId->LAngleLoc, + TemplateArgsPtr, + TemplateId->RAngleLoc, + CCLoc, + EnteringContext)) { + SourceLocation StartLoc + = SS.getBeginLoc().isValid()? SS.getBeginLoc() + : TemplateId->TemplateNameLoc; + SS.SetInvalid(SourceRange(StartLoc, CCLoc)); } - - assert(false && "FIXME: Only type template names supported here"); + + TemplateId->Destroy(); + continue; } |