diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-01-30 16:53:11 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-01-30 16:53:11 +0000 |
commit | f9e37be2d63ea563bb235b74f7103353ec0fdfef (patch) | |
tree | fb54c3885ec7b8b6e66a0eb268ec26f2d5d6de87 /clang/lib/Parse/ParseExprCXX.cpp | |
parent | 655b59854fba05212109b63ca4cd7e40e2843917 (diff) | |
download | bcm5719-llvm-f9e37be2d63ea563bb235b74f7103353ec0fdfef.tar.gz bcm5719-llvm-f9e37be2d63ea563bb235b74f7103353ec0fdfef.zip |
Follow-up to r217302 and r227555: Don't crash on inline ~A::A() if A is an int.
Even with r227555, this still crashed:
struct S {
int A;
~A::A() {}
};
That's because ParseOptionalCXXScopeSpecifier()'s call to
ActOnCXXNestedNameSpecifier() doesn't mark the scope spec as invalid if sema
thought it's a good idea to fixit-correct "::" to ":". For the diagnostic
improvement done in r217302, we never want :: to be interpreted as :, so fix
this by setting ColonSacred to false temporarily.
Found by SLi's bot.
llvm-svn: 227581
Diffstat (limited to 'clang/lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index a753b0ff27a..8faec51667b 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -2509,7 +2509,13 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, // If the user wrote ~T::T, correct it to T::~T. DeclaratorScopeObj DeclScopeObj(*this, SS); - if (!TemplateSpecified && NextToken().is(tok::coloncolon)) { + if (!TemplateSpecified && //!ColonIsSacred && + NextToken().is(tok::coloncolon)) { + // Don't let ParseOptionalCXXScopeSpecifier() "correct" + // `int A; struct { ~A::A(); };` to `int A; struct { ~A:A(); };`, + // it will confuse this recovery logic. + ColonProtectionRAIIObject ColonRAII(*this, false); + if (SS.isSet()) { AnnotateScopeToken(SS, /*NewAnnotation*/true); SS.clear(); |