diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-06 14:50:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-06 14:50:36 +0000 |
commit | a49ccfeeb2052dfc8dd5b9b200d3884d7e6afa02 (patch) | |
tree | fa1a2f80941e398a578dc260e99371e87b582da6 /clang/lib/Parse/ParseExpr.cpp | |
parent | 229c281d377385ea6c00965bb688e7a666441ef9 (diff) | |
download | bcm5719-llvm-a49ccfeeb2052dfc8dd5b9b200d3884d7e6afa02.tar.gz bcm5719-llvm-a49ccfeeb2052dfc8dd5b9b200d3884d7e6afa02.zip |
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.
llvm-svn: 110445
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 589bf4a35f8..ec92f0869e5 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/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); |