From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp-11.smtpout.orange.fr [80.12.242.11]) by sourceware.org (Postfix) with ESMTPS id 3636D385840D for ; Tue, 8 Nov 2022 21:39:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3636D385840D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=orange.fr Received: from [192.168.1.17] ([83.197.245.49]) by smtp.orange.fr with ESMTPA id sWJQo4cK042kJsWJQoYRQB; Tue, 08 Nov 2022 22:39:17 +0100 X-ME-Helo: [192.168.1.17] X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Tue, 08 Nov 2022 22:39:17 +0100 X-ME-IP: 83.197.245.49 Message-ID: Date: Tue, 8 Nov 2022 22:39:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH, v3] Fortran: ordering of hidden procedure arguments [PR107441] Content-Language: fr To: Harald Anlauf , fortran@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org References: <7d8ddf07-e66d-2678-de99-0e575c70ea17@orange.fr> <327319ac-4ef9-1e48-e993-57113d802d3b@orange.fr> <85a5951a-7ea4-57b3-895a-ff7dbf1ef92e@orange.fr> <93a5f029-4411-3424-f6ee-3b2bcf210050@gmx.de> <8725411a-979b-dd53-d1fe-5b041482a8eb@gmx.de> <91afe6ef-e5f4-d3d8-ad15-3271fd4e61cd@orange.fr> <3ca46ea0-ee6a-cbc6-d3af-99b8db698307@orange.fr> <24c6acfa-6745-c7a3-4bbd-54bd0fa31454@gmx.de> <54c4f997-863d-f850-ddf9-1ed780feedff@orange.fr> <258a3620-5b8e-f508-2c56-863d47ef2502@gmx.de> From: Mikael Morin In-Reply-To: <258a3620-5b8e-f508-2c56-863d47ef2502@gmx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FROM,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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.