summaryrefslogtreecommitdiffstats
path: root/lib/Parse/ParseExprCXX.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-12-09 21:10:43 +0000
committerReid Kleckner <rnk@google.com>2016-12-09 21:10:43 +0000
commitd9da6e9994507d48a41708a26d3e8494a538152c (patch)
tree0833f623e48a8f3a4661709473b244e5965f34f6 /lib/Parse/ParseExprCXX.cpp
parent35f3b49b3c2012b2095fcda31be64a84371dd221 (diff)
Remove special error recovery for ::(id)
The code pattern used to implement the token rewriting hack doesn't interact well with token caching in the pre-processor. As a result, clang would crash on 'int f(::(id));' while doing a tenative parse of the contents of the outer parentheses. The original code from PR11852 still doesn't crash the compiler. This error recovery also often does the wrong thing with member function pointers. The test case from the original PR doesn't recover the right way either: void S::(*pf)() = S::f; // should be 'void (S::*pf)()' Instead we were recovering as 'void S::*pf()', which is still wrong. If we still think that users mistakenly parenthesize identifiers in nested name specifiers, we should change clang to intentionally parse that form with an error, rather than doing a token rewrite. Fixes PR26623, but I think there will be many more bugs like this around token rewriting in the parser. Reviewers: rsmith, rtrieu Differential Revision: https://reviews.llvm.org/D25882 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289273 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExprCXX.cpp')
-rw-r--r--lib/Parse/ParseExprCXX.cpp46
1 files changed, 0 insertions, 46 deletions
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index cabc7b5266..3f335747a4 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -100,48 +100,6 @@ void Parser::CheckForTemplateAndDigraph(Token &Next, ParsedType ObjectType,
/*AtDigraph*/false);
}
-/// \brief Emits an error for a left parentheses after a double colon.
-///
-/// When a '(' is found after a '::', emit an error. Attempt to fix the token
-/// stream by removing the '(', and the matching ')' if found.
-void Parser::CheckForLParenAfterColonColon() {
- if (!Tok.is(tok::l_paren))
- return;
-
- Token LParen = Tok;
- Token NextTok = GetLookAheadToken(1);
- Token StarTok = NextTok;
- // Check for (identifier or (*identifier
- Token IdentifierTok = StarTok.is(tok::star) ? GetLookAheadToken(2) : StarTok;
- if (IdentifierTok.isNot(tok::identifier))
- return;
- // Eat the '('.
- ConsumeParen();
- Token RParen;
- RParen.setLocation(SourceLocation());
- // Do we have a ')' ?
- NextTok = StarTok.is(tok::star) ? GetLookAheadToken(2) : GetLookAheadToken(1);
- if (NextTok.is(tok::r_paren)) {
- RParen = NextTok;
- // Eat the '*' if it is present.
- if (StarTok.is(tok::star))
- ConsumeToken();
- // Eat the identifier.
- ConsumeToken();
- // Add the identifier token back.
- PP.EnterToken(IdentifierTok);
- // Add the '*' back if it was present.
- if (StarTok.is(tok::star))
- PP.EnterToken(StarTok);
- // Eat the ')'.
- ConsumeParen();
- }
-
- Diag(LParen.getLocation(), diag::err_paren_after_colon_colon)
- << FixItHint::CreateRemoval(LParen.getLocation())
- << FixItHint::CreateRemoval(RParen.getLocation());
-}
-
/// \brief Parse global scope or nested-name-specifier if present.
///
/// Parses a C++ global scope specifier ('::') or nested-name-specifier (which
@@ -237,8 +195,6 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
if (Actions.ActOnCXXGlobalScopeSpecifier(ConsumeToken(), SS))
return true;
- CheckForLParenAfterColonColon();
-
HasScopeSpecifier = true;
}
}
@@ -491,8 +447,6 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
Token ColonColon = Tok;
SourceLocation CCLoc = ConsumeToken();
- CheckForLParenAfterColonColon();
-
bool IsCorrectedToColon = false;
bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon : nullptr;
if (Actions.ActOnCXXNestedNameSpecifier(getCurScope(), IdInfo,