From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by sourceware.org (Postfix) with ESMTPS id 9A61E3858C50; Thu, 3 Nov 2022 22:03:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A61E3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1667513020; bh=u3lsqLCppYK3VDzSMyRenreaX10XyXMwJCl1j56StOA=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=keTluEstS94H/I/0gajaKFKHej1sc/ZHv7fsMjujeXIyLwLOFBBIEV/AsQ2jI5y8G JhQM2srdHRJwlhNElmp1UCVp7BcQAVXxnANNxWGbX4jKyTbcoU090Nghm6rNGRKcqg cQe4+dcJEZcsQLBU2jihE5OCOS8R22x3rQFw6cLYaB0BHFHMHlUqdXqcfPMFLCsxhV Cc7TJaiEjEZx3HrvsTtH+vXCd0vhsWFI2KKw+AmaSf9gJghIFIXmWspkEdrtLQ4geL FStC/XL9H5o0vnHOdzYVYWPETviaiidfxZ7YCoeMoGrDSy9gcu6f8oTa3r4knLvcIa W3jtlmp2R8xCw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([93.207.83.232]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N2V4P-1p1bVr2h1L-013raO; Thu, 03 Nov 2022 23:03:40 +0100 Message-ID: Date: Thu, 3 Nov 2022 23:03:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH, v2] Fortran: ordering of hidden procedure arguments [PR107441] To: Mikael Morin , fortran@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Newsgroups: gmane.comp.gcc.fortran,gmane.comp.gcc.patches 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> Content-Language: en-US From: Harald Anlauf In-Reply-To: <91afe6ef-e5f4-d3d8-ad15-3271fd4e61cd@orange.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:MBNd0EnXqtWtVlCnlJE6I6AVoZsIsISOQbzQHl69VJJEbBsUm+l tEIDPNDXYwMnvVxV8dEhaq9znjtOlawJ1MbUyyxWD3gMy1p3miBzLUGuQPUu6wklK+a/9NV aVaV6kTrg1owiIJ8gGYZTCxTWfsq6ZxhjCy2UZWbQGhn5RSfr0bjqikJpqi+3Erzqv5dgzo jfMpMP8/a9fpVnsfgqLvA== UI-OutboundReport: notjunk:1;M01:P0:g8cjxk0fgzk=;8NlfZWu2tCHvrlMbbT25T+hIOGm tm8s4YIBXg0xoZbisn7IFSKqlCEvXN4+sr4cYHPEmGytY8lIwfFJssLU4cqZ2WjnWcxG7mqzX 3FHzIylAWj3imPuF968z+ni5XDohA+XJApZD279D+QieOLSzXKB2Dx6edyJ99AszOep59SP3Z 7PCpV0uKC9reg/6us0pXfGV08bOoany23N4eJvxBMaD9g2MqVcibstlvwrF93UczwnMQjRlk5 FHC7A/osHGzj7v5fwNxxNtBgUhM65I4uhwVlAxKXwbeCU+1ee3uztrCA0PZIJuqBxlaB4rRsM bWF835mQeqf5OMm9Ug9qUuCuF5NR6Xy38hZM2ftezPhJPx4pLzqTafR2uExMVFjX7lBQIrNOH Lzl0qOUKTDh9gtGudOE/cFxdypPor9LpY853k+4nMnSxRwfp8v0neksesKVeXRbjoXJdTpDg6 MBb+Xcee0mMW/loKLLIwvQlamgx/mzq3t4hfO+dqUtWBZS2bw3RVoOJ1DcneWmhMz4qZ8Prtj 0tpV8PRJCukwX+yRE95T8CitAtHWIAvP5kQYjA94xcfYg0L/urDBQ31Zm+6xKYo+m923VTot/ ANunFaRcFL72cWCsMP93M97S4VHqa4gfkRYiuaVzLiBvcPhcrOH+B+J4BnRKxO0V0LUxQhN3h m3bWQaWyNkBjg7+CZQI24+oJRbsBBKTEw60K4mmpWHkRHFW7ijhl+08AdPoKYH2v4WzYnYzPu hDFeN1ZEJSV/hL5kRXo/CQSodzTy7TrNVN9PQOxo/yq1sadDXRQjW3aSORA1UCTiZgtOT5dkt 5ooojv4Y8bj0sCTd9MDnYRW2vXAYRAWyvGjZk5qyFAUUwznht+hevEqSOEPfEVJpaER3isgTZ 0CTtdJT7AQ2UaQsUkkN9HbX1d8EI0Glg0q0OQ7KpSgWS3kS5Etz0vTDo28omoMi9qZeMaUenh 0VagRrPqPlzCoMi7uvLGUHJoov0= X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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: Am 03.11.22 um 11:06 schrieb Mikael Morin: > Le 02/11/2022 =C3=A0 22:19, Harald Anlauf via Fortran a =C3=A9crit=C2=A0= : >> Am 02.11.22 um 18:20 schrieb Mikael Morin: >>> Unfortunately no, the coarray case works, but the other problem remain= s. >>> The type problem is not visible in the definition of S, it is in the >>> declaration of S's prototype in P. >>> >>> S is defined as: >>> >>> void s (character(kind=3D1)[1:_c] & restrict c, integer(kind=3D4) o, >>> logical(kind=3D1) _o, integer(kind=3D8) _c) >>> { >>> ... >>> } >>> >>> but P has: >>> >>> void p () >>> { >>> =C2=A0=C2=A0 static void s (character(kind=3D1)[1:] & restrict, intege= r(kind=3D4), >>> integer(kind=3D8), logical(kind=3D1)); >>> =C2=A0=C2=A0 void (*) (character(kind=3D1)[1:] & restrict, integ= er(kind=3D4), >>> integer(kind=3D8), logical(kind=3D1)) pp; >>> >>> =C2=A0=C2=A0 pp =3D s; >>> ... >>> } >> >> Right, now I see it too.=C2=A0 Simplified case: >> >> program p >> =C2=A0=C2=A0 call s ("abcd") >> contains >> =C2=A0=C2=A0 subroutine s(c, o) >> =C2=A0=C2=A0=C2=A0=C2=A0 character(*) :: c >> =C2=A0=C2=A0=C2=A0=C2=A0 integer, optional, value :: o >> =C2=A0=C2=A0 end subroutine s >> end >> >> I do see what needs to be done in gfc_get_function_type, which seems >> in fact very simple.=C2=A0 But I get really lost in create_function_arg= list >> when trying to get the typelist right. >> >> One thing is I really don't understand how the (hidden_)typelist is >> managed here.=C2=A0 How does that macro TREE_CHAIN work?=C2=A0 Can we s= omehow >> chain two typelists the same way we chain arguments? >> > TREE_CHAIN is just a linked list "next" pointer like there is in the > fortran frontend a "next" pointer in gfc_ref or gfc_actual_arglist > structures. > Yes, we can chain typelists; the implementation of chainon in tree.cc is > just TREE_CHAIN appending under the hood. > >> (Failing that, I tried to split the loop over the dummy arguments in >> create_function_arglist into two passes, one for the optional+value >> variant, and one for the rest.=C2=A0 It turned out to be a bad idea...) >> > Not necessarily a bad idea, but one has to be careful to keep linked > lists synchronized with argument walking. > > The most simple, I think, is to move the hidden_typelist advancement for > optional, value presence arguments from the main loop to a preliminary > loop. > > I hope it helps. > I've spent some time not only staring at create_function_arglist, but trying several variations handling the declared hidden parms, and applying the necessary adjustments to gfc_get_function_type. (Managing linked trees is not the issue, just understanding them.) I've been unable to get the declarations in sync, and would need help how to debug the mess I've created. Dropping my patch for the time being.