public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Andrew Pinski <pinskia@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Use error_mark_node after error in convert
Date: Mon, 23 Oct 2023 09:45:01 +0200	[thread overview]
Message-ID: <CAFiYyc3rYLxeUa+D1OBzPpt3VeWcOubB98sm_Zg5m2ypPHcYBA@mail.gmail.com> (raw)
In-Reply-To: <20231022222230.1633485-1-pinskia@gmail.com>

On Mon, Oct 23, 2023 at 12:22 AM Andrew Pinski <pinskia@gmail.com> wrote:
>
> While working on PR c/111903, I Noticed that
> convert will convert integer_zero_node to that
> type after an error instead of returning error_mark_node.
> From what I can tell this was the old way of not having
> error recovery since other places in this file does return
> error_mark_node and the places I am replacing date from
> when the file was imported into the repro (either via a gcc2 merge
> or earlier).
>
> I also had to update the objc front-end to allow for the error_mark_node
> change, I suspect you could hit the ICE without this change though.
>
> Bootstrapped and tested on x86_64-linux-gnu with no regressions.

OK.

> gcc/ChangeLog:
>
>         * convert.cc (convert_to_pointer_1): Return error_mark_node
>         after an error.
>         (convert_to_real_1): Likewise.
>         (convert_to_integer_1): Likewise.
>         (convert_to_complex_1): Likewise.
>
> gcc/objc/ChangeLog:
>
>         * objc-gnu-runtime-abi-01.cc (build_objc_method_call): Allow
>         for error_operand after call to build_c_cast.
>         * objc-next-runtime-abi-01.cc (build_objc_method_call): Likewise.
>         * objc-next-runtime-abi-02.cc (build_v2_build_objc_method_call): Likewise.
> ---
>  gcc/convert.cc                       | 12 ++++++------
>  gcc/objc/objc-gnu-runtime-abi-01.cc  |  3 +++
>  gcc/objc/objc-next-runtime-abi-01.cc |  3 +++
>  gcc/objc/objc-next-runtime-abi-02.cc |  3 +++
>  4 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/convert.cc b/gcc/convert.cc
> index 5357609d8f0..ac6af7026a7 100644
> --- a/gcc/convert.cc
> +++ b/gcc/convert.cc
> @@ -96,7 +96,7 @@ convert_to_pointer_1 (tree type, tree expr, bool fold_p)
>
>      default:
>        error ("cannot convert to a pointer type");
> -      return convert_to_pointer_1 (type, integer_zero_node, fold_p);
> +      return error_mark_node;
>      }
>  }
>
> @@ -332,11 +332,11 @@ convert_to_real_1 (tree type, tree expr, bool fold_p)
>      case POINTER_TYPE:
>      case REFERENCE_TYPE:
>        error ("pointer value used where a floating-point was expected");
> -      return convert_to_real_1 (type, integer_zero_node, fold_p);
> +      return error_mark_node;
>
>      default:
>        error ("aggregate value used where a floating-point was expected");
> -      return convert_to_real_1 (type, integer_zero_node, fold_p);
> +      return error_mark_node;
>      }
>  }
>
> @@ -959,7 +959,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
>
>      default:
>        error ("aggregate value used where an integer was expected");
> -      return convert (type, integer_zero_node);
> +      return error_mark_node;
>      }
>  }
>
> @@ -1053,11 +1053,11 @@ convert_to_complex_1 (tree type, tree expr, bool fold_p)
>      case POINTER_TYPE:
>      case REFERENCE_TYPE:
>        error ("pointer value used where a complex was expected");
> -      return convert_to_complex_1 (type, integer_zero_node, fold_p);
> +      return error_mark_node;
>
>      default:
>        error ("aggregate value used where a complex was expected");
> -      return convert_to_complex_1 (type, integer_zero_node, fold_p);
> +      return error_mark_node;
>      }
>  }
>
> diff --git a/gcc/objc/objc-gnu-runtime-abi-01.cc b/gcc/objc/objc-gnu-runtime-abi-01.cc
> index fbf8307297a..6f45283b307 100644
> --- a/gcc/objc/objc-gnu-runtime-abi-01.cc
> +++ b/gcc/objc/objc-gnu-runtime-abi-01.cc
> @@ -700,6 +700,9 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
>
>    lookup_object = build_c_cast (loc, rcv_p, lookup_object);
>
> +  if (error_operand_p (lookup_object))
> +    return error_mark_node;
> +
>    /* Use SAVE_EXPR to avoid evaluating the receiver twice.  */
>    lookup_object = save_expr (lookup_object);
>
> diff --git a/gcc/objc/objc-next-runtime-abi-01.cc b/gcc/objc/objc-next-runtime-abi-01.cc
> index 70ab5262e17..9e28976043e 100644
> --- a/gcc/objc/objc-next-runtime-abi-01.cc
> +++ b/gcc/objc/objc-next-runtime-abi-01.cc
> @@ -846,6 +846,9 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
>
>    lookup_object = build_c_cast (loc, rcv_p, lookup_object);
>
> +  if (error_operand_p (lookup_object))
> +    return error_mark_node;
> +
>    /* Use SAVE_EXPR to avoid evaluating the receiver twice.  */
>    lookup_object = save_expr (lookup_object);
>
> diff --git a/gcc/objc/objc-next-runtime-abi-02.cc b/gcc/objc/objc-next-runtime-abi-02.cc
> index 6548c0078e0..723b47c9cf6 100644
> --- a/gcc/objc/objc-next-runtime-abi-02.cc
> +++ b/gcc/objc/objc-next-runtime-abi-02.cc
> @@ -1729,6 +1729,9 @@ build_v2_build_objc_method_call (int super, tree method_prototype,
>
>    lookup_object = build_c_cast (loc, rcv_p, lookup_object);
>
> +  if (error_operand_p (lookup_object))
> +    return error_mark_node;
> +
>    /* Use SAVE_EXPR to avoid evaluating the receiver twice.  */
>    lookup_object = save_expr (lookup_object);
>
> --
> 2.39.3
>

      reply	other threads:[~2023-10-23  7:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-22 22:22 Andrew Pinski
2023-10-23  7:45 ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc3rYLxeUa+D1OBzPpt3VeWcOubB98sm_Zg5m2ypPHcYBA@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=pinskia@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).