r236347 - Also correct typos in the middle of a ternary expression when the RHS is invalid.

Kaelyn Takata rikka at google.com
Fri May 1 13:59:18 PDT 2015


Author: rikka
Date: Fri May  1 15:59:18 2015
New Revision: 236347

URL: http://llvm.org/viewvc/llvm-project?rev=236347&view=rev
Log:
Also correct typos in the middle of a ternary expression when the RHS is invalid.

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.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=236347&r1=236346&r2=236347&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri May  1 15:59:18 2015
@@ -347,7 +347,11 @@ Parser::ParseRHSOfBinaryExpression(ExprR
       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(ExprR
       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();
       }
 

Modified: cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=236347&r1=236346&r2=236347&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Fri May  1 15:59:18 2015
@@ -198,3 +198,8 @@ namespace PR23005 {
 void f() { int a = Unknown::b(c); }  // expected-error {{use of undeclared identifier 'Unknown'}}
 // expected-error at -1 {{use of undeclared identifier 'c'}}
 }
+
+namespace PR23350 {
+int z = 1 ? N : ;  // expected-error {{expected expression}}
+// expected-error-re at -1 {{use of undeclared identifier 'N'{{$}}}}
+}





More information about the cfe-commits mailing list