diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-09-06 02:06:12 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-09-06 02:06:12 +0000 |
commit | efa6f736e63a9978d68f47be6e980803452d256d (patch) | |
tree | d5a98324e5863e700e3558af4b02de96ce10026a /clang/lib/Parse/ParseExprCXX.cpp | |
parent | d650b82b229eaece6f8ee5f28fee1d7ca91dba06 (diff) | |
download | bcm5719-llvm-efa6f736e63a9978d68f47be6e980803452d256d.tar.gz bcm5719-llvm-efa6f736e63a9978d68f47be6e980803452d256d.zip |
Add error, recovery and fixit for "~A::A() {...}".
llvm-svn: 217302
Diffstat (limited to 'clang/lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 27109aba5b7..cf0e4ce5c0c 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -2452,10 +2452,29 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, return true; } + // If the user wrote ~T::T, correct it to T::~T. + if (!TemplateSpecified && NextToken().is(tok::coloncolon)) { + if (SS.isSet()) { + AnnotateScopeToken(SS, /*NewAnnotation*/true); + SS.clear(); + } + if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext)) + return true; + if (Tok.isNot(tok::identifier) || NextToken().is(tok::coloncolon)) { + Diag(TildeLoc, diag::err_destructor_tilde_scope); + return true; + } + + // Recover as if the tilde had been written before the identifier. + Diag(TildeLoc, diag::err_destructor_tilde_scope) + << FixItHint::CreateRemoval(TildeLoc) + << FixItHint::CreateInsertion(Tok.getLocation(), "~"); + } + // Parse the class-name (or template-name in a simple-template-id). IdentifierInfo *ClassName = Tok.getIdentifierInfo(); SourceLocation ClassNameLoc = ConsumeToken(); - + if (TemplateSpecified || Tok.is(tok::less)) { Result.setDestructorName(TildeLoc, ParsedType(), ClassNameLoc); return ParseUnqualifiedIdTemplateId(SS, TemplateKWLoc, @@ -2463,7 +2482,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, EnteringContext, ObjectType, Result, TemplateSpecified); } - + // Note that this is a destructor name. ParsedType Ty = Actions.getDestructorName(TildeLoc, *ClassName, ClassNameLoc, getCurScope(), |