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>, fortran <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fortran: overloading of intrinsic binary operators [PR109641]
Date: Fri, 5 May 2023 13:43:28 +0200	[thread overview]
Message-ID: <618d5f73-55f9-d9d2-e470-aabb5dd7ab17@orange.fr> (raw)
In-Reply-To: <trinity-ce8b7413-8aa1-46d7-b361-5fc943e01d23-1682958599603@3c-app-gmx-bap68>

Hello,

Le 01/05/2023 à 18:29, Harald Anlauf via Fortran a écrit :
> Dear all,
> 
> the attached patch is mostly self-explaining: we mishandled the
> overloading of intrinsic binary operators in the case the actual
> operands were of intrinsic numeric type and the ranks of the
> operands were not conformable, i.e. both were of non-zero and
> different ranks.  In that case the operators could be converted
> to the same type before the correct user-defined operator was
> resolved, leading to either rejects-valid or accepts-invalid
> or wrong resolution (= wrong code).
> 
> Regtested on x86_64-pc-linux-gnu.  OK for mainline?
> 
> The patch is actually very limited in impact, but the bug is
> sort of annoying.  Would it be OK to backport to 13.2 after
> some waiting?
> 
> Thanks,
> Harald
(...)
> diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
> index c3d508fb45d..341909d7de7 100644
> --- a/gcc/fortran/resolve.cc
> +++ b/gcc/fortran/resolve.cc
> @@ -5644,6 +5666,23 @@ done:
>  }
> 
> 
> +/* Given two expressions, check that their rank is conformable, i.e. either
> +   both have the same rank or at least one is a scalar.  */
> +
> +bool
> +gfc_op_rank_conformable (gfc_expr *op1, gfc_expr *op2)
> +{
> +//  if (op1->expr_type == EXPR_VARIABLE && op1->ref)
Please remove this, and the other one below.

> +  if (op1->expr_type == EXPR_VARIABLE)
> +    gfc_expression_rank (op1);
> +//  if (op2->expr_type == EXPR_VARIABLE && op2->ref)
> +  if (op2->expr_type == EXPR_VARIABLE)
> +    gfc_expression_rank (op2);
> +
> +  return (op1->rank == 0 || op2->rank == 0 || op1->rank == op2->rank);
> +}
> +
> +
>  static void
>  add_caf_get_intrinsic (gfc_expr *e)
>  {

The rest looks good.
OK for master, and backport as well.

Thanks
Mikael

  reply	other threads:[~2023-05-05 11:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01 16:29 Harald Anlauf
2023-05-05 11:43 ` Mikael Morin [this message]
2023-05-05 19:36   ` Harald Anlauf
2023-05-05 19:36     ` 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=618d5f73-55f9-d9d2-e470-aabb5dd7ab17@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).