aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-05 03:55:46 +0000
committerChris Lattner <sabre@nondot.org>2009-01-05 03:55:46 +0000
commit5b4547318bb179fc76f984f0eeaaf615927e795c (patch)
tree23463f07964aeba1dfa3576d2912fa0ffe1709be /lib/Parse/ParseExpr.cpp
parent357089dea05855e27f80f6f244f9c60fc77cee83 (diff)
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
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r--lib/Parse/ParseExpr.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 80e25ee6cb..c2bbad3cda 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -626,25 +626,21 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
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();
}