aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-06 14:50:36 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-06 14:50:36 +0000
commitd42066343b3bda72362178e7ece78b9afb709e17 (patch)
treef8521b49703e59b1c3d7c3fe0abd2e9ba133c271 /lib/Parse/ParseExpr.cpp
parentcaadc127fef2a5ce5dddae0d3ac6a582c285baff (diff)
The pre-increment/pre-decrement grammar in C++ differs from that in C,
but we were parsing the C grammar. Handle the C++ grammar appropriately. Fixes PR7794. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r--lib/Parse/ParseExpr.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 589bf4a35f..ec92f0869e 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -568,7 +568,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
// If this expression is limited to being a unary-expression, the parent can
// not start a cast expression.
ParenParseOption ParenExprType =
- isUnaryExpression ? CompoundLiteral : CastExpr;
+ (isUnaryExpression && !getLang().CPlusPlus)? CompoundLiteral : CastExpr;
TypeTy *CastTy;
SourceLocation LParenLoc = Tok.getLocation();
SourceLocation RParenLoc;
@@ -702,10 +702,14 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
case tok::kw___null:
return Actions.ActOnGNUNullExpr(ConsumeToken());
break;
- case tok::plusplus: // unary-expression: '++' unary-expression
- case tok::minusminus: { // unary-expression: '--' unary-expression
+ case tok::plusplus: // unary-expression: '++' unary-expression [C99]
+ case tok::minusminus: { // unary-expression: '--' unary-expression [C99]
+ // C++ [expr.unary] has:
+ // unary-expression:
+ // ++ cast-expression
+ // -- cast-expression
SourceLocation SavedLoc = ConsumeToken();
- Res = ParseCastExpression(true);
+ Res = ParseCastExpression(!getLang().CPlusPlus);
if (!Res.isInvalid())
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, move(Res));
return move(Res);