Make the parser handle ::new and ::delete correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60421 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index df46612..50b3a7a 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -638,8 +638,13 @@
Res = ParseCXXIdExpression();
return ParsePostfixExpressionSuffix(Res);
+ case tok::coloncolon: // [C++] new-expression or [C++] delete-expression
+ if (NextToken().is(tok::kw_new))
+ return ParseCXXNewExpression();
+ else
+ return ParseCXXDeleteExpression();
+
case tok::kw_new: // [C++] new-expression
- // FIXME: ParseCXXIdExpression currently steals :: tokens.
return ParseCXXNewExpression();
case tok::kw_delete: // [C++] delete-expression
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index d995b88..5d790fa 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -38,6 +38,12 @@
(Tok.isNot(tok::identifier) || NextToken().isNot(tok::coloncolon)))
return false;
+ // Don't parse ::new and ::delete as scope specifiers. It would only make
+ // things a lot more complicated.
+ if (Tok.is(tok::coloncolon) && (NextToken().is(tok::kw_new) ||
+ NextToken().is(tok::kw_delete)))
+ return false;
+
if (Tok.is(tok::annot_cxxscope)) {
SS.setScopeRep(Tok.getAnnotationValue());
SS.setRange(Tok.getAnnotationRange());