]> granicus.if.org Git - clang/commitdiff
Also correct typos in the middle of a ternary expression when the RHS is invalid.
authorKaelyn Takata <rikka@google.com>
Fri, 1 May 2015 20:59:18 +0000 (20:59 +0000)
committerKaelyn Takata <rikka@google.com>
Fri, 1 May 2015 20:59:18 +0000 (20:59 +0000)
The LHS was already being corrected before being set to ExprError when
the RHS is invalid, but when it was present the middle of a ternary
expression would be dropped in the error paths.

Fixes PR23350.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236347 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
test/SemaCXX/typo-correction-delayed.cpp

index 5116991c0f746c270917c96c7758922d8ce5de0c..9e0060be57e7a25a38c8a3933e91800d1e9fa71d 100644 (file)
@@ -347,7 +347,11 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
       RHS = ParseCastExpression(false);
 
     if (RHS.isInvalid()) {
+      // FIXME: Errors generated by the delayed typo correction should be
+      // printed before errors from parsing the RHS, not after.
       Actions.CorrectDelayedTyposInExpr(LHS);
+      if (TernaryMiddle.isUsable())
+        TernaryMiddle = Actions.CorrectDelayedTyposInExpr(TernaryMiddle);
       LHS = ExprError();
     }
 
@@ -380,7 +384,11 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
       RHSIsInitList = false;
 
       if (RHS.isInvalid()) {
+        // FIXME: Errors generated by the delayed typo correction should be
+        // printed before errors from ParseRHSOfBinaryExpression, not after.
         Actions.CorrectDelayedTyposInExpr(LHS);
+        if (TernaryMiddle.isUsable())
+          TernaryMiddle = Actions.CorrectDelayedTyposInExpr(TernaryMiddle);
         LHS = ExprError();
       }
 
index 3866a8a4cb72130ab2b5a9d52829931a5f5e79b2..dfdd9af811bd599ea1035b290dd17bb4b8f9189f 100644 (file)
@@ -198,3 +198,8 @@ namespace PR23005 {
 void f() { int a = Unknown::b(c); }  // expected-error {{use of undeclared identifier 'Unknown'}}
 // expected-error@-1 {{use of undeclared identifier 'c'}}
 }
+
+namespace PR23350 {
+int z = 1 ? N : ;  // expected-error {{expected expression}}
+// expected-error-re@-1 {{use of undeclared identifier 'N'{{$}}}}
+}