From: Mikael Morin <morin-mikael@orange.fr>
To: Harald Anlauf <anlauf@gmx.de>, fortran@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH, v3] Fortran: ordering of hidden procedure arguments [PR107441]
Date: Tue, 8 Nov 2022 22:39:16 +0100 [thread overview]
Message-ID: <f4c830fd-825d-1489-325a-2169eabfdc52@orange.fr> (raw)
In-Reply-To: <258a3620-5b8e-f508-2c56-863d47ef2502@gmx.de>
Le 08/11/2022 à 21:31, Harald Anlauf a écrit :
> Hi Mikael,
>
> Am 08.11.22 um 11:32 schrieb Mikael Morin:
>> this is mostly good.
>> There is one last corner case that is not properly handled:
>>
>>> diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
>>> index 63515b9072a..94988b8690e 100644
>>> --- a/gcc/fortran/trans-decl.cc
>>> +++ b/gcc/fortran/trans-decl.cc
>> (...)
>>> @@ -2619,6 +2620,15 @@ create_function_arglist (gfc_symbol * sym)
>>> if (f->sym != NULL) /* Ignore alternate returns. */
>>> hidden_typelist = TREE_CHAIN (hidden_typelist);
>>>
>>> + /* Advance hidden_typelist over optional+value argument presence
>>> flags. */
>>> + optval_typelist = hidden_typelist;
>>> + for (f = gfc_sym_get_dummy_args (sym); f; f = f->next)
>>> + if (f->sym != NULL
>>> + && f->sym->attr.optional && f->sym->attr.value
>>> + && !f->sym->attr.dimension && f->sym->ts.type != BT_CLASS
>>> + && !gfc_bt_struct (f->sym->ts.type))
>>> + hidden_typelist = TREE_CHAIN (hidden_typelist);
>>> +
>>
>> This new loop copies the condition guarding the handling of optional
>> value presence arguments, except that the condition is in an "else if",
>> and the complement of the condition in the corresponding "if" is
>> missing, to have strictly the same conditions.
>
> I know, and I left that intentionally, as it is related to
> PR107444, assuming that it doesn't lead to a new ICE. Bad idea.
>
>> Admittedly, it only makes a difference for character optional value
>> arguments, which are hardly working. At least they work as long as one
>> doesn't try to query their presence. Below is a case regressing with
>> your patch.
>
>> With that fixed, I think it's good for mainline.
>> Thanks for your patience.
>>
>>
>> ! { dg-do compile }
>> !
>> ! PR fortran/107441
>> ! Check that procedure types and procedure decls match when the procedure
>> ! has both character-typed and character-typed optional value args.
>> !
>> ! Contributed by M.Morin
>>
>> program p
>> interface
>> subroutine i(c, o)
>> character(*) :: c
>> character(3), optional, value :: o
>> end subroutine i
>> end interface
>> procedure(i), pointer :: pp
>> pp => s
>> call pp("abcd", "xyz")
>> contains
>> subroutine s(c, o)
>> character(*) :: c
>> character(3), optional, value :: o
>> if (o /= "xyz") stop 1
>> if (c /= "abcd") stop 2
>> end subroutine s
>> end program p
>
> Well, that testcase may compile with 12-branch, but it gives
> wrong code. Furthermore, it is arguably invalid, as you are
> currently unable to check the presence of the optional argument
> due to PR107444. I am therefore reluctant to have that testcase
> now.
>
> To fix that, we may have to bite the bullet and break the
> documented ABI, or rather update it, as character,value,optional
> is broken in all current gfortran versions, and the documentation
> is not completely consistent. I had planned to do this with the
> fix for PR107444, which want to keep separate from the current
> patch for good reasons.
>
> I have modified my patch so that your testcase above compiles
> and runs. But as explained, I don't want to add it now.
>
> Regtested again. What do you think?
>
Let's proceed with the v3 then. Character optional value arguments are
corner cases anyway.
prev parent reply other threads:[~2022-11-08 21:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 20:12 [PATCH] " Harald Anlauf
2022-10-30 19:23 ` Mikael Morin
2022-10-30 20:32 ` Mikael Morin
2022-10-30 21:25 ` Mikael Morin
2022-10-31 9:57 ` Mikael Morin
2022-10-31 20:29 ` [PATCH, v2] " Harald Anlauf
2022-11-02 17:20 ` Mikael Morin
2022-11-02 21:19 ` Harald Anlauf
2022-11-03 10:06 ` Mikael Morin
2022-11-03 22:03 ` Harald Anlauf
2022-11-04 9:53 ` Mikael Morin
2022-11-07 21:45 ` [PATCH, v3] " Harald Anlauf
2022-11-08 10:32 ` Mikael Morin
2022-11-08 20:31 ` Harald Anlauf
2022-11-08 21:39 ` Mikael Morin [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=f4c830fd-825d-1489-325a-2169eabfdc52@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).