Implementation of new and delete parsing and sema.
This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59835 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 74b0715..9f9b306 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -351,6 +351,8 @@
/// [GNU] '__alignof' '(' type-name ')'
/// [C++0x] 'alignof' '(' type-id ')'
/// [GNU] '&&' identifier
+/// [C++] new-expression
+/// [C++] delete-expression
///
/// unary-operator: one of
/// '&' '*' '+' '-' '~' '!'
@@ -405,6 +407,16 @@
/// '~' class-name [TODO]
/// template-id [TODO]
///
+/// new-expression: [C++ 5.3.4]
+/// '::'[opt] 'new' new-placement[opt] new-type-id
+/// new-initializer[opt]
+/// '::'[opt] 'new' new-placement[opt] '(' type-id ')'
+/// new-initializer[opt]
+///
+/// delete-expression: [C++ 5.3.5]
+/// '::'[opt] 'delete' cast-expression
+/// '::'[opt] 'delete' '[' ']' cast-expression
+///
Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
if (getLang().CPlusPlus) {
// Annotate typenames and C++ scope specifiers.
@@ -614,6 +626,13 @@
Res = ParseCXXIdExpression();
return ParsePostfixExpressionSuffix(Res);
+ case tok::kw_new: // [C++] new-expression
+ // FIXME: ParseCXXIdExpression currently steals :: tokens.
+ return ParseCXXNewExpression();
+
+ case tok::kw_delete: // [C++] delete-expression
+ return ParseCXXDeleteExpression();
+
case tok::at: {
SourceLocation AtLoc = ConsumeToken();
return ParseObjCAtExpression(AtLoc);