Author: majnemer Date: Wed Feb 17 11:19:00 2016 New Revision: 261109 URL: http://llvm.org/viewvc/llvm-project?rev=261109&view=rev Log: Correct more typos in conditional expressions
We didn't correctly handle some edge cases, causing us to bail out before correcting all the typos. Modified: cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/Sema/typo-correction.c cfe/trunk/test/SemaCXX/typo-correction.cpp Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=261109&r1=261108&r2=261109&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb 17 11:19:00 2016 @@ -449,9 +449,11 @@ Parser::ParseRHSOfBinaryExpression(ExprR LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc, LHS.get(), TernaryMiddle.get(), RHS.get()); - } else - // Ensure potential typos in the RHS aren't left undiagnosed. + } else { + // Ensure potential typos aren't left undiagnosed. + Actions.CorrectDelayedTyposInExpr(TernaryMiddle); Actions.CorrectDelayedTyposInExpr(RHS); + } } } Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=261109&r1=261108&r2=261109&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Feb 17 11:19:00 2016 @@ -6838,8 +6838,23 @@ ExprResult Sema::ActOnConditionalOp(Sour // doesn't handle dependent types properly, so make sure any TypoExprs have // been dealt with before checking the operands. ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr); - if (!CondResult.isUsable()) return ExprError(); + ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr); + ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr); + + if (!CondResult.isUsable()) + return ExprError(); + + if (LHSExpr) { + if (!LHSResult.isUsable()) + return ExprError(); + } + + if (!RHSResult.isUsable()) + return ExprError(); + CondExpr = CondResult.get(); + LHSExpr = LHSResult.get(); + RHSExpr = RHSResult.get(); } // If this is the gnu "x ?: y" extension, analyze the types as though the LHS Modified: cfe/trunk/test/Sema/typo-correction.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=261109&r1=261108&r2=261109&view=diff ============================================================================== --- cfe/trunk/test/Sema/typo-correction.c (original) +++ cfe/trunk/test/Sema/typo-correction.c Wed Feb 17 11:19:00 2016 @@ -55,3 +55,5 @@ void fn2() { f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}} afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}} } + +int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}} Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=261109&r1=261108&r2=261109&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/typo-correction.cpp (original) +++ cfe/trunk/test/SemaCXX/typo-correction.cpp Wed Feb 17 11:19:00 2016 @@ -663,3 +663,5 @@ class Bar : public A::B::Foofoo {}; using C::D::Foofoo; // expected-error {{no member named 'Foofoo' in namespace 'PR24781_using_crash::C::D'; did you mean 'A::B::Foofoo'?}} } + +int d = ? L : d; // expected-error {{expected expression}} expected-error {{undeclared identifier}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits