From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 5966F3858D28; Sat, 18 Mar 2023 20:59:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5966F3858D28 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=1679173148; i=anlauf@gmx.de; bh=45XPnbrtI4zAjAziQ4bdgANqFKMAdtNHoI480sFRx2s=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=k64SMNvN1Kin5b80OiI1b0kzdkRrM9O9O1HN71Dam8PP3U+sUBGXVM7kI8jMNTFfa IsglBTeJbeTN+14RCyFffoaZGBTnj/BT6wJ8btAZEJJJbbk6dLVtpVaWd9muGx7ODc zBuhfNaWdCtXj0Cy/OMjnO2f6QZBy50M0UO+yoYXa5JNl1ihEPIS0G1sEuXY04BkBR JSntHIGlLmaQ8uM0BuUAM/NzH+WfUOMFf/pzN3A5C5iMurDAQHiJqA6zPuJUAZEjcN 5JBL5mPCiwqgbv2sssSc5gRWl4jGJiRTgFxP5UZG6ccSnan2ANiUVt2x5XrNOeWTYK zLXzCC6FEai3g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([79.251.1.185]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N8GMq-1qZ1ae15KC-0149pR; Sat, 18 Mar 2023 21:59:08 +0100 Message-ID: Date: Sat, 18 Mar 2023 21:59:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] Fortran: procedures with BIND(C) attribute require explicit interface [PR85877] To: Thomas Koenig , fortran , gcc-patches Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: <3496724e-5ebd-d133-c6f6-807068b175f4@netcologne.de> Content-Language: en-US From: Harald Anlauf In-Reply-To: <3496724e-5ebd-d133-c6f6-807068b175f4@netcologne.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:KOFuj5ASFUzRyuWAbBbQ5WT3vMfgueMGPl5BVFJmkiT9CF1jpfM D87oMNjUCe305cZob9i/gtIVEj6kJYfcYdDA08G7ZJ4XLXQBySXXs+Sg0XWt8GTZpxgA9ug k7O8uEBKbg+fBiZNsgVEcDhao/llB+zrSyfLijv43KtWQgRGjF458F2wdzhvC5v/kPiuyIS fMywWHk/XvCYONWa1si1A== UI-OutboundReport: notjunk:1;M01:P0:Hkk+1KoqD+A=;5Z3UKHgoAg6+QInAxCjwbnPkyNL xWKw2uZ4GsDa9oeDfFz4HmZQZ5A3lKM3Oh/mB14KSfcvNvrSBkr3B52gMu2Y5mXj4f/5w598I sNmTWcO/PfzPWTUBuLWVTnQEKelp2gZ8AZ6fH4BmpG7L7VrLbhsFrNkjOb8lNRJ63ZtJmGJWd xEA5RjuD57j9qe7HnEqaEWB2axJAqcxBxexzGGtlyXOnFxH6Jo24/wWed9DJVXdaqPrVMlCfg BZNp/xEtA47sqzBkLY8BvflArXxactKOIP9zse+fxEKJjQ0or+Uln3wH/hQLGM+2zhmSc1Glq oXnc7mzYOxlomhdribLQhmeGzwB3+rUZTyx1WLiP3OLHnD3jJpSMLG2Sks4rRqk2E949zyu8E gIgjfZ5pphpoBQ7KVJNcgtSQGnAz3ThRxqcoAmtnc3B8YLgJThobcntnppMJ8e4aJm74vOgKq F1eTSsnlhq5FvQfr//K4JXe2XevCMhl5Rh+na15+UIb0qzIRS2zkNXyv1NhdbdQQF+j3UOwTT FS6JIqezuOBkgc+U+MiZdM7EIZnieIwLMV/T/K2iSBifaLw2E3MQdb56/sC+o7MhQPSUrDXoP vz/V6E3C42Mj6WFQAeoc8PoF7ENZBf4a556lh3CWrU4AXbFC8WLWA3e9jm7Onj9J5xWg2KuRO p2WHHeguNxhTOTIvjU+rZB14tlmR2XO2NKmxSNH1Bav0g2EU1fTyrggaFPvFHUISmzb4tfHCX ejq6iWmscMIJZcfpLh/i2zsT3xAK+5okVcAq1uBHct5O2S21GpgjAm3JNvU8lyniLBY8MLcCN dWthmCcz32eIQUQf5jZ5qharToL5QLk16NSI0ndEuTvakcaPe1vzZ9jId+gAb3LD5FeA+Y6OW 2114zKJM/n/8pvdppltPmXvw8Dz1u19XRUJ1DGOmy1oad9PbZBOqAxlOCXVEIGsMzj0/+T5iI SmP4dQSe2xsboW9S5zJmkO9EGak= X-Spam-Status: No, score=-3.8 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: Hi Thomas, Am 18.03.23 um 19:52 schrieb Thomas Koenig via Gcc-patches: > Hi Harald, > >> the Fortran standard requires an explicit procedure interface in certai= n >> situations, such as when they have a BIND(C) attribute (F2018:15.4.2.2)= . >> The attached patch adds a check for this. >> >> Regtested on x86_64-pc-linux-gnu.=C2=A0 OK for mainline? > > While this fixes the ICE, it misses > > function f() bind(c) > =C2=A0 f =3D 42. > end > > subroutine p > =C2=A0 bind(c) f=C2=A0=C2=A0=C2=A0=C2=A0 ! { dg-error "must be explicit= " } > =C2=A0 x =3D f() > end what do you mean by "it misses"? I do not see an explicit interface here, only a global symbol. All compiler I tried with the above code reject it one way or the other, e g. Cray: x =3D f() ^ ftn-954 crayftn: ERROR P, File =3D pr85877-2.f90, Line =3D 12, Column =3D = 3 Procedure "f", referenced at line 6 (pr85877-2.f90) must have an explicit interface because one or more arguments have the BIND attribute. > subroutine s > =C2=A0 interface > =C2=A0=C2=A0=C2=A0=C2=A0 function g() bind(c) > =C2=A0=C2=A0=C2=A0=C2=A0 end function g > =C2=A0 end interface > =C2=A0 x =3D g() > end > > where the interface is picked up via a global symbol. Is it really true that this is in the spirit of the standard? Is the global declaration above really equivalent to an explicit interface? I would expect legal code to be like: function g() bind(c) g =3D 42. end subroutine s interface function g() bind(c) end function g end interface x =3D g() end unless you do it in the context of a module and in the right way. > This code > may not be valid; nagfor rejects it, but I cannot find a > constraint at least in the F2022 draft that prohibits it. I thought that F2018:15.4.2.2 and F2023:15.4.2.2(7) are rather clear and "explicit" on this. IMHO the case of "f" above seems to be excluded and thus not conforming. > Hm... might it be better to check for attr->module_procedure || > attr->if_source =3D=3D IFSRC_IFBODY? Maybe we should find a set of legal and illegal cases that we can agree upon. Thanks, Harald > Best regards > > =C2=A0=C2=A0=C2=A0=C2=A0Thomas > >