From patchwork Thu Apr 15 20:52:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1466767 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=xxv6wffG; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FLs3J2xGCz9sVv for ; Fri, 16 Apr 2021 06:52:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3842C388A43C; Thu, 15 Apr 2021 20:52:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3842C388A43C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1618519926; bh=oU6xZ5l0e0FwcnPIAjB3tugqd3SgUVS1QJL/Ak/rRUI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xxv6wffGnsed8KDeLvrQS3j33F1fCEkhXeNykSc/H9BjOArE2SjzwYJE9jrM77DCk LGII6NNEosLqZb3YOxb7HxQhIFh7n4a1tR9zLjJxD0UuJkvey+DTYprTgS7caai+pJ 63GxvJ7shT3amR4plMhCGXSgpJ673hFQ88rCcJYc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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: To: fortran , gcc-patches Subject: [PATCH] PR fortran/63797 - Bogus ambiguous reference to 'sqrt' 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 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. diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 4db0a3ac76d..b4b7b437f86 100644 --- 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)") == 0) + return; + p = find_pointer (sym); if (p == NULL) gfc_internal_error ("write_symtree(): Symbol not written"); diff --git a/gcc/testsuite/gfortran.dg/pr63797.f90 b/gcc/testsuite/gfortran.dg/pr63797.f90 new file mode 100644 index 00000000000..1131e8167b1 --- /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 = sqrt (0.0) + real :: w = 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 => sqrt + end function myroot +end module mod1 + +module mod2 + implicit none + type t + real :: a = 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 = 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 => sqrt +end module mod3 + +program test + use mod1 + use mod2 + use mod3 + implicit none + type(t) :: x, y + procedure(sqrt_ifc), pointer :: root + root => myroot () + y = sqrt (x) + y% a = sqrt (x% a) + z - w + root (x% a) + y% a = real_root (x% a) +end program test