]> granicus.if.org Git - clang/commitdiff
Improve recovery when the middle expression of a ternary operator is ill-formed
authorDouglas Gregor <dgregor@apple.com>
Fri, 17 Sep 2010 22:41:34 +0000 (22:41 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 17 Sep 2010 22:41:34 +0000 (22:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114231 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
test/Index/complete-recovery.m

index c3c4b4144a4bbd883cd7494327123d76aae096bc..ec2c5d6b9559c5f32a202709bb0f53a3513178da 100644 (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]
index 66084cdcec1c2aa3a38565120eb1514102c2e801..5141a533aeaafdeb47161e72cf54a796651c29f7 100644 (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