public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mikael Morin <morin-mikael@orange.fr>
To: Harald Anlauf <anlauf@gmx.de>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: Re: [PATCH, v2] Fortran: error recovery for invalid types in array constructors [PR107000]
Date: Fri, 7 Oct 2022 21:47:15 +0200	[thread overview]
Message-ID: <30b93c16-9be9-d2b1-b6c8-c34f4ab8cfff@orange.fr> (raw)
In-Reply-To: <05f415c0-80bc-c04e-a142-1251bf82bb1d@gmx.de>

Le 07/10/2022 à 20:46, Harald Anlauf a écrit :
> 
> OK, that is because reduce_binary dispatches the reduce_binary_*.
> We could move the check from reduce_binary_aa to the beginning of
> reduce_binary, as with the following change on top of the patch:
> 
> diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
> index 2c57c796270..91e70655ad3 100644
> --- a/gcc/fortran/arith.cc
> +++ b/gcc/fortran/arith.cc
> @@ -1426,10 +1426,6 @@ reduce_binary_aa (arith (*eval) (gfc_expr *,
> gfc_expr *, gfc_expr **),
>     if (!gfc_check_conformance (op1, op2, _("elemental binary operation")))
>       return ARITH_INCOMMENSURATE;
> 
> -  if ((op1->expr_type == EXPR_OP && op1->ts.type == BT_UNKNOWN)
> -      || (op2->expr_type == EXPR_OP && op2->ts.type == BT_UNKNOWN))
> -    return ARITH_INVALID_TYPE;
> -
>     head = gfc_constructor_copy (op1->value.constructor);
>     for (c = gfc_constructor_first (head),
>          d = gfc_constructor_first (op2->value.constructor);
> @@ -1467,6 +1463,10 @@ static arith
>   reduce_binary (arith (*eval) (gfc_expr *, gfc_expr *, gfc_expr **),
>                 gfc_expr *op1, gfc_expr *op2, gfc_expr **result)
>   {
> +  if ((op1->expr_type == EXPR_OP && op1->ts.type == BT_UNKNOWN)
> +      || (op2->expr_type == EXPR_OP && op2->ts.type == BT_UNKNOWN))
> +    return ARITH_INVALID_TYPE;
> +
>     if (op1->expr_type == EXPR_CONSTANT && op2->expr_type == EXPR_CONSTANT)
>       return eval (op1, op2, result);
> 
> However, we cannot remove the checks from reduce_binary_ac
> or reduce_binary_ca, as the lengthy testcase proves...
> 
> Do you like the above better?
> 
Yes, definitely, but some less important weirdness remains;
the scalar vs array function catches scalar vs invalid scalar cases.
Let me have a look.

  reply	other threads:[~2022-10-07 19:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-04 21:19 [PATCH] " Harald Anlauf
2022-10-05  8:51 ` Mikael Morin
2022-10-05  9:23   ` Mikael Morin
2022-10-05 21:40     ` [PATCH, v2] " Harald Anlauf
2022-10-06 20:14       ` Mikael Morin
2022-10-06 21:36         ` Harald Anlauf
2022-10-07  8:01           ` Mikael Morin
2022-10-07 18:46             ` Harald Anlauf
2022-10-07 19:47               ` Mikael Morin [this message]
2022-10-07 20:26                 ` [PATCH, v3] " Mikael Morin
2022-10-07 21:41                   ` Harald Anlauf

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=30b93c16-9be9-d2b1-b6c8-c34f4ab8cfff@orange.fr \
    --to=morin-mikael@orange.fr \
    --cc=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /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).