Improve recovery when the middle expression of a ternary operator is ill-formed

llvm-svn: 114231
This commit is contained in:
Douglas Gregor 2010-09-17 22:41:34 +00:00
parent 7a6c37d3e7
commit ec06c124f1
2 changed files with 6 additions and 2 deletions

View File

@ -291,8 +291,10 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
// 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]

View File

@ -10,6 +10,7 @@
blarg * blah = wibble;
A *a2;
z = [a2 method:1];
blah ? blech : [a2 method:1];
}
@end
@ -27,3 +28,4 @@
// CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )}
// RUN: c-index-test -code-completion-at=%s:12:11 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType void}{TypedText method:}{Placeholder (int)} (17)
// RUN: c-index-test -code-completion-at=%s:13:22 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s