From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id C4960388A432; Thu, 15 Apr 2021 20:52:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C4960388A432 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.80.229] ([93.207.80.229]) by web-mail.gmx.net (3c-app-gmx-bap12.server.lan [172.19.172.82]) (via HTTP); Thu, 15 Apr 2021 22:52:01 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] PR fortran/63797 - Bogus ambiguous reference to 'sqrt' Content-Type: multipart/mixed; boundary=sgnirk-ad754819-bea5-4fc3-915c-a381b9820c8a Date: Thu, 15 Apr 2021 22:52:01 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:Lvj93qSc3hrZj0xJmTnSedK9Z/O/UOqOTz2aIFlPFHtF+s9UkqyS9ldwKi/gEhpXyDbBY 3RJPakpaCwci/A4ZkV7pJhCJLlbTYrp+YCZGRoUjwVZIgx3/l0voV1kzpaab8DwGr6WHE4Q4x6uP 3IWX5mmi4coi1WQhNamO31yZ3wxh8XAVOudw0puSfd+OiYLq3DULdiK4kxadvhoEbdhZSvh4WsHI Yj7ZsqWciBMUowrcqFKadX/dRGxwUyyFPcz8u19gbbOImtJdRsjqsjgZ1W0jIWBkZNna9xIcJ+vK S8= X-UI-Out-Filterresults: notjunk:1;V03:K0:qjWPmo4bYUY=:2RIyaLb/JGdXPGlsh6pvCX wfx5R/OYB6uB8EeAMKEIjvtulTMzMHZlRwt8o4P6Nv2T7mnV/oCFXut5n9BhaESx9/d2u/WBs VkA4g8walpi0WJuHas3i615qoJoJhhiDpoZPxTdhWqbMqu4U5/3JN/YVMszJdUduVdB/7+tB2 C7fejF1Jgd5CgeSEl4ScUGJvfnvqv638KYT2qdWfIkXCLodUQDi+spzN9M+y1vwbslowHF8Ee oMYLdAArwp08Nl5ed7R3R4yP67Bbc0f3CIq7M2yX46KzXkmVW2xF5Jz9gmgetmSQ3tQE83u/c 4q6uaQQh1mKnWAXT1xuIWEboTVj1/Rh7jGd2ufU7wC08DrtuncWXDtM+PLkcR+FJXkHSwCik3 cTe0zKqET4bfXvY822f30nrG/gU09aejkyV3GMFPA+UUATXxa3LTFKjLuBeAUz80Cc8ugRsHj vzuyFuB3Ae8BfStlGuwju+gju2CmyKGYLNj/LpPQ+4UZFSYKFVrA9YHzwAAGzw4yG88P1nhIg yejSU1dNTW6Q5NXzr7koH41Q+HwzotdixuUWaVCUnR1cx2ZJQgVVTuav3MbixzHKscz+/kooP 60NnNCAR+bFval8O0Z4jbEtBRBphgRQM3C+FJx+3C23HY33rx2VGfCECws6hDHIKcBXXfbBOR 0uI0aZSB/Nu2IY2Ay2thXrWbz6C/gVR1BRc8PfkAC+SaEO99+2xUDcFIJNydE2EaEaW1zqfxi ZWTbJGAhlL58ntE+ag4hiZJSDfVhDIfKJ44rqjhxxrgWRjiio0RtDYuYAl0JEv1m4fyYT32i5 VHc1Zf+RUxBlfgBhZJjnsUjNtA44E7jCZPALy3ivsZhYf//FKEnJnKEubqD7vPi+QdDPqgaOA 3MsDf73URb8dpRUaxsueatCRUB7UOdaO4G/FVJ8tgfEM1GyDurUUR4+uVouBA8 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Apr 2021 20:52:04 -0000 --sgnirk-ad754819-bea5-4fc3-915c-a381b9820c8a Content-Type: text/plain; charset=UTF-8 Hello everybody, we currently write the interface for intrinsic procedures to module files although that should not be necessary. (F2018:15.4.2.1 actually states that interfaces e.g. of intrinsic procedures are 'explicit'.) This lead to bogus errors due to an apparently bogus ambiguity. A simple solution is to just avoid writing that (redundant) information to the module file. Regtested on x86_64-pc-linux-gnu. OK for (current) mainline? Or rather wait after 11 release? Thanks, Harald PR fortran/63797 - Bogus ambiguous reference to 'sqrt' The interface of an intrinsic procedure is automatically explicit. Do not write it to the module file. gcc/fortran/ChangeLog: * module.c (write_symtree): Do not write interface of intrinsic procedure to module file. gcc/testsuite/ChangeLog: * gfortran.dg/pr63797.f90: New test. --sgnirk-ad754819-bea5-4fc3-915c-a381b9820c8a Content-Type: text/x-patch Content-Disposition: attachment; filename=pr63797.patch Content-Transfer-Encoding: quoted-printable diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 4db0a3ac76d..b4b7b437f86 100644 =2D-- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -6218,6 +6218,9 @@ write_symtree (gfc_symtree *st) if (check_unique_name (st->name)) return; + if (strcmp (sym->module, "(intrinsic)") =3D=3D 0) + return; + p =3D find_pointer (sym); if (p =3D=3D NULL) gfc_internal_error ("write_symtree(): Symbol not written"); diff --git a/gcc/testsuite/gfortran.dg/pr63797.f90 b/gcc/testsuite/gfortra= n.dg/pr63797.f90 new file mode 100644 index 00000000000..1131e8167b1 =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr63797.f90 @@ -0,0 +1,60 @@ +! { dg-do compile } +! PR63797 - Bogus ambiguous reference to 'sqrt' + +module mod1 + implicit none + real, parameter :: z =3D sqrt (0.0) + real :: w =3D sqrt (1.0) + interface + pure real function sqrt_ifc (x) + real, intent(in) :: x + end function sqrt_ifc + end interface +contains + pure function myroot () result (f) + procedure(sqrt_ifc), pointer :: f + intrinsic :: sqrt + f =3D> sqrt + end function myroot +end module mod1 + +module mod2 + implicit none + type t + real :: a =3D 0. + end type + interface sqrt + module procedure sqrt + end interface +contains + elemental function sqrt (a) + type(t), intent(in) :: a + type(t) :: sqrt + sqrt% a =3D a% a + end function sqrt +end module mod2 + +module mod3 + implicit none + abstract interface + function real_func (x) + real :: real_func + real, intent (in) :: x + end function real_func + end interface + intrinsic :: sqrt + procedure(real_func), pointer :: real_root =3D> sqrt +end module mod3 + +program test + use mod1 + use mod2 + use mod3 + implicit none + type(t) :: x, y + procedure(sqrt_ifc), pointer :: root + root =3D> myroot () + y =3D sqrt (x) + y% a =3D sqrt (x% a) + z - w + root (x% a) + y% a =3D real_root (x% a) +end program test --sgnirk-ad754819-bea5-4fc3-915c-a381b9820c8a--