public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] PR fortrsn/101564 - ICE in resolve_allocate_deallocate, at fortran/resolve.c:8169
Date: Thu, 22 Jul 2021 21:50:41 +0200	[thread overview]
Message-ID: <trinity-662b7425-1d29-4ae6-a4a1-86ff47e98787-1626983441414@3c-app-gmx-bap16> (raw)
In-Reply-To: <9b6187f0-d3dd-bb2d-d6f3-ada831cdecf0@codesourcery.com>

Hi Tobias,

I am afraid we're really opening a can of worms here....

> Additionally, I wonder whether that will work with:
> 
> integer, pointer :: ptr
> integer function f()
>    pointer :: f
>    f = ptr
> end
> allocate(A, stat=f())
> 
> The f() is a variable and definable – but I am currently not sure it sets stat->symtree
> and not only stat->value.function.esym, but I have not tested it.

I think a "working" testcase for this could be:

program p
  implicit none
  integer, target  :: ptr
  integer, pointer :: A
  allocate (A, stat=f())
  print *, ptr
contains
  function f()
    integer, pointer :: f
    f => ptr
  end function f
end

This works as expected with Intel and AOCC, but gives a
syntax error with every gfortran tested because of match.c:

alloc_opt_list:

      m = gfc_match (" stat = %v", &tmp);

where the comment before gfc_match states:

   %v  Matches a variable expression (an lvalue)

although it matches only variables and not every type of lvalue.
We therefore never get to the interesting checks elsewhere...

> Additionally, I have to admit that I do not understand the
> following existing condition, which you did not touch:
> 
>        if ((stat->ts.type != BT_INTEGER
>             && !(stat->ref && (stat->ref->type == REF_ARRAY
>                                || stat->ref->type == REF_COMPONENT)))
>            || stat->rank > 0)
>          gfc_error ("Stat-variable at %L must be a scalar INTEGER "
>                     "variable", &stat->where);
> 
> I mean the ts.type != BT_INTEGER and stat->rank != 0 is clear,
> but what's the reason for the refs?

Well, that needs to be answered by Steve (see commit 3759634).

[...]

> And possibly add a testcase for stat=f() [valid]
> and stat=x%y%kind [invalid] as well?

Well, I need to go back to the drawing board then...

Thanks,
Harald


  reply	other threads:[~2021-07-22 19:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 20:36 Harald Anlauf
2021-07-22 17:55 ` Tobias Burnus
2021-07-22 19:50   ` Harald Anlauf [this message]
2021-07-23  8:17     ` Tobias Burnus
2021-07-26 21:55       ` Harald Anlauf
2021-07-27  7:52         ` Tobias Burnus
2021-07-27 21:42           ` Harald Anlauf
2021-07-28 10:23             ` Tobias Burnus

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=trinity-662b7425-1d29-4ae6-a4a1-86ff47e98787-1626983441414@3c-app-gmx-bap16 \
    --to=anlauf@gmx.de \
    --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).