remove optimization to avoid looking ahead for cases like ::foo. This
isn't worth the complexity and the code already does a ton of lookahead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61671 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 80e25ee..c2bbad3 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -626,25 +626,21 @@
return ParsePostfixExpressionSuffix(move(Res));
case tok::coloncolon: {
+ // ::foo::bar -> global qualified name etc. If TryAnnotateTypeOrScopeToken
+ // annotates the token, tail recurse.
+ if (TryAnnotateTypeOrScopeToken())
+ return ParseCastExpression(isUnaryExpression);
+
// ::new -> [C++] new-expression
// ::delete -> [C++] delete-expression
- // ::foo::bar -> global qualified name etc.
- Token ColonColonTok = Tok;
- ConsumeToken();
+ SourceLocation CCLoc = ConsumeToken();
if (Tok.is(tok::kw_new))
- return ParseCXXNewExpression(true, ColonColonTok.getLocation());
+ return ParseCXXNewExpression(true, CCLoc);
if (Tok.is(tok::kw_delete))
- return ParseCXXDeleteExpression(true, ColonColonTok.getLocation());
- // Turn the qualified name into a annot_qualtypename or annot_cxxscope if
- // it would be valid.
- if ((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) &&
- TryAnnotateTypeOrScopeToken(&ColonColonTok)) {
- // If so, retry (tail recurse).
- return ParseCastExpression(isUnaryExpression);
- }
-
+ return ParseCXXDeleteExpression(true, CCLoc);
+
// This is not a type name or scope specifier, it is an invalid expression.
- Diag(ColonColonTok, diag::err_expected_expression);
+ Diag(CCLoc, diag::err_expected_expression);
return ExprError();
}