r277095 - [Parser] Fix bug where delayed typo in conditional expression was corrected twice

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 2 11:05:31 PDT 2016


Should we merge this to 3.9?

Thanks,
Hans

On Thu, Jul 28, 2016 at 5:55 PM, Erik Pilkington via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: epilk
> Date: Thu Jul 28 19:55:40 2016
> New Revision: 277095
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277095&view=rev
> Log:
> [Parser] Fix bug where delayed typo in conditional expression was corrected twice
>
> Patch by David Tarditi!
>
> Differential revision: https://reviews.llvm.org/D22930
>
> Modified:
>     cfe/trunk/lib/Parse/ParseExpr.cpp
>     cfe/trunk/test/Sema/typo-correction.c
>
> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=277095&r1=277094&r2=277095&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Jul 28 19:55:40 2016
> @@ -446,14 +446,15 @@ Parser::ParseRHSOfBinaryExpression(ExprR
>          LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
>                                   OpToken.getKind(), LHS.get(), RHS.get());
>
> -        // In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr check.
> -        if (!getLangOpts().CPlusPlus)
> -          continue;
>        } else {
>          LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
>                                           LHS.get(), TernaryMiddle.get(),
>                                           RHS.get());
>        }
> +      // In this case, ActOnBinOp or ActOnConditionalOp performed the
> +      // CorrectDelayedTyposInExpr check.
> +      if (!getLangOpts().CPlusPlus)
> +        continue;
>      }
>      // Ensure potential typos aren't left undiagnosed.
>      if (LHS.isInvalid()) {
>
> Modified: cfe/trunk/test/Sema/typo-correction.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=277095&r1=277094&r2=277095&view=diff
> ==============================================================================
> --- cfe/trunk/test/Sema/typo-correction.c (original)
> +++ cfe/trunk/test/Sema/typo-correction.c Thu Jul 28 19:55:40 2016
> @@ -65,3 +65,18 @@ int fn_with_rs(int r) { r = TYPO + r * T
>  void fn_with_unknown(int a, int b) {
>    fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of undeclared identifier}}
>  }
> +
> +// Two typos in a parenthesized expression or argument list with a conditional
> +// expression caused a crash in C mode.
> +//
> +// r272587 fixed a similar bug for binary operations. The same fix was needed for
> +// conditional expressions.
> +
> +int g(int x, int y) {
> +  return x + y;
> +}
> +
> +int h() {
> +  g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}}
> +  (x, 5 ? z : 0);  // expected-error 2 {{use of undeclared identifier}}
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list