public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Richard Thomas <paul.richard.thomas@gmail.com>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: Re: [Patch] Fortran: Fix intrinsic null() handling [PR99651]
Date: Fri, 26 Mar 2021 06:48:18 +0000	[thread overview]
Message-ID: <CAGkQGi+n+Kfg=fgJD3UC9WG+O9YeRSL1jZTc6AZ9B87i0Yj6_g@mail.gmail.com> (raw)
In-Reply-To: <31957d7d-6881-5821-cef6-7980c0231ab4@codesourcery.com>

Hi Tobias,

Please go ahead and commit the patch. I think that your analysis is correct
about expr_null and that your patch is the best way to deal with the
problem.

Best regards

Paul


On Tue, 23 Mar 2021 at 17:54, Tobias Burnus <tobias@codesourcery.com> wrote:

> Hi Paul,
>
> On 23.03.21 18:34, Paul Richard Thomas wrote:
> > I took something of a detour in reviewing this patch. Although short,
> > understanding it is not straightforward!
>
> I concur – and as I wrote both in the patch email and in the PR, it is
> not straight forward which message is showing with which setting.
>
> Actually, I think there are many straight-forward ways to fix it
> "properly" but they tend to hide some nicer error messages in favour of
> a more generic one. Only by taking into account all the diagnostic and
> hidden/delayed diagnostic, the patch becomes complex. (-:
>
> > Your patch works as advertised and regtests OK (with the patch for
> > PR93660 on board as well). Is NULL the only case where this can happen?
>
> I am not sure whether any other code would profit form getting one of
> the attributes conditionally assigned in intrinsic.c.
>
> Otherwise, I think that's the only code which verifies like that it in
> such a way whether an intrinsic function was used. I think the reason
> that it does so is because 'null' is turned early during parsing into
> EXPR_NULL, which is not a function and, hence, bypasses some of the
> later checking code in resolve.c.
>
>
> > Just to aid my understanding, I tried:
> > diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
> >
> > --- a/gcc/fortran/primary.c
> > +++ b/gcc/fortran/primary.c
> > @@ -3922,6 +3922,9 @@ gfc_match_rvalue (gfc_expr **result)
> >        if (m == MATCH_NO)
> >         m = MATCH_YES;
> >
> > +      if (!strcmp (sym->name, "NULL") || !strcmp (sym->name, "null"))
> > +       sym->attr.intrinsic = 1;
> > +
> >        break;
> >
> >      generic_function:
> >
> > which also works and regtests OK. (I couldn't remember whether
> > sym->name is upper or lower case at this stage.)
>
> Should be always lowercase, I think. But I am also not sure that your
> aid-understanding patch will work correctly with 'external null' or a
> use-/host-associated/interface 'null' procedure or some array variable.
> Inside intrinsic.c, we are at least sure that we did get an intrinsic
> function after having passed all intrinsic checks.
>
> Tobias
>
> -----------------
> Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München
> Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank
> Thürauf
>


-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein

      reply	other threads:[~2021-03-26  6:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19  8:50 Tobias Burnus
2021-03-23 17:34 ` Paul Richard Thomas
2021-03-23 17:35   ` Paul Richard Thomas
2021-03-23 17:54   ` Tobias Burnus
2021-03-26  6:48     ` Paul Richard Thomas [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='CAGkQGi+n+Kfg=fgJD3UC9WG+O9YeRSL1jZTc6AZ9B87i0Yj6_g@mail.gmail.com' \
    --to=paul.richard.thomas@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.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).