Improve recovery when the middle expression of a ternary operator is ill-formed
llvm-svn: 114231
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index c3c4b41..ec2c5d6 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -291,8 +291,10 @@
// In particular, the RHS of the '?' is 'expression', not
// 'logical-OR-expression' as we might expect.
TernaryMiddle = ParseExpression();
- if (TernaryMiddle.isInvalid())
- return move(TernaryMiddle);
+ if (TernaryMiddle.isInvalid()) {
+ LHS = ExprError();
+ TernaryMiddle = 0;
+ }
} else {
// Special case handling of "X ? Y : Z" where Y is empty:
// logical-OR-expression '?' ':' conditional-expression [GNU]