PR4122: Tweak the ambiguity handling to handle (S())() correctly. I've
left out handling for stuff like (S())++ for the moment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72394 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index 5e6ba68..681c6ad 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -1088,12 +1088,17 @@
ParseAs = CompoundLiteral;
} else {
bool NotCastExpr;
- // Try parsing the cast-expression that may follow.
- // If it is not a cast-expression, NotCastExpr will be true and no token
- // will be consumed.
- Result = ParseCastExpression(false/*isUnaryExpression*/,
- false/*isAddressofOperand*/,
- NotCastExpr);
+ // FIXME: Special-case ++ and --: "(S())++;" is not a cast-expression
+ if (Tok.is(tok::l_paren) && NextToken().is(tok::r_paren)) {
+ NotCastExpr = true;
+ } else {
+ // Try parsing the cast-expression that may follow.
+ // If it is not a cast-expression, NotCastExpr will be true and no token
+ // will be consumed.
+ Result = ParseCastExpression(false/*isUnaryExpression*/,
+ false/*isAddressofOperand*/,
+ NotCastExpr);
+ }
// If we parsed a cast-expression, it's really a type-id, otherwise it's
// an expression.