From: Kaelyn Takata Date: Fri, 1 May 2015 20:59:18 +0000 (+0000) Subject: Also correct typos in the middle of a ternary expression when the RHS is invalid. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84b5cd74ff85e673c0a75a6fe064b67e170dac12;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236347 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 5116991c0f..9e0060be57 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -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(); } diff --git a/test/SemaCXX/typo-correction-delayed.cpp b/test/SemaCXX/typo-correction-delayed.cpp index 3866a8a4cb..dfdd9af811 100644 --- a/test/SemaCXX/typo-correction-delayed.cpp +++ b/test/SemaCXX/typo-correction-delayed.cpp @@ -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'{{$}}}} +}