aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-04 21:25:24 +0000
committerChris Lattner <sabre@nondot.org>2009-01-04 21:25:24 +0000
commit59232d35f5820e334b6c8b007ae8006f4390055d (patch)
tree90167fb13fa061acdeec6b85b39acbf09e5d7621 /lib/Parse/ParseExpr.cpp
parente607e808c2b90724a2a6fd841e850f07de1f5b30 (diff)
eliminate lookahead when parsing ::new / ::delete.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61638 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r--lib/Parse/ParseExpr.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 0c25fab4f4..f719b8914f 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -626,19 +626,23 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
Res = ParseCXXIdExpression();
return ParsePostfixExpressionSuffix(move(Res));
- case tok::coloncolon: // [C++] new-expression or [C++] delete-expression
- // If the next token is neither 'new' nor 'delete', the :: would have been
- // parsed as a scope specifier already.
- if (NextToken().is(tok::kw_new))
- return ParseCXXNewExpression();
- else
- return ParseCXXDeleteExpression();
+ case tok::coloncolon: { // [C++] new-expression or [C++] delete-expression
+ SourceLocation ScopeLoc = ConsumeToken();
+ if (Tok.is(tok::kw_new))
+ return ParseCXXNewExpression(true, ScopeLoc);
+ else {
+ // If the next token is neither 'new' nor 'delete', the :: would have been
+ // parsed as a scope specifier already.
+ assert(Tok.is(tok::kw_delete));
+ return ParseCXXDeleteExpression(true, ScopeLoc);
+ }
+ }
case tok::kw_new: // [C++] new-expression
- return ParseCXXNewExpression();
+ return ParseCXXNewExpression(false, Tok.getLocation());
case tok::kw_delete: // [C++] delete-expression
- return ParseCXXDeleteExpression();
+ return ParseCXXDeleteExpression(false, Tok.getLocation());
case tok::at: {
SourceLocation AtLoc = ConsumeToken();