From a8dfd33611f978e3b78e5175ee4b55618ec00c1e Mon Sep 17 00:00:00 2001 From: Kaelyn Takata Date: Fri, 1 May 2015 20:59:18 +0000 Subject: [PATCH] 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. llvm-svn: 236347 --- clang/lib/Parse/ParseExpr.cpp | 8 ++++++++ clang/test/SemaCXX/typo-correction-delayed.cpp | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 5116991c0f74..9e0060be57e7 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/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/clang/test/SemaCXX/typo-correction-delayed.cpp b/clang/test/SemaCXX/typo-correction-delayed.cpp index 3866a8a4cb72..dfdd9af811bd 100644 --- a/clang/test/SemaCXX/typo-correction-delayed.cpp +++ b/clang/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'{{$}}}} +} -- 2.34.1