From patchwork Fri Nov 3 18:56:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1859091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=gmx.de header.i=anlauf@gmx.de header.a=rsa-sha256 header.s=s31663417 header.b=LpkyIZeY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SMVN14YQxz1yQq for ; Sat, 4 Nov 2023 05:56:45 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFA9F3858C35 for ; Fri, 3 Nov 2023 18:56:42 +0000 (GMT) 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.15.15]) by sourceware.org (Postfix) with ESMTPS id 2943A3858D32; Fri, 3 Nov 2023 18:56:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2943A3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2943A3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.15.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699037792; cv=none; b=Yt4f6yXazClfgMZXNfD12nLORe+vOPUjY8/Oy+9eyFs+CjU6k6cpCLd7mShOudO/5YQMxOT0rbOSYSb9RR2QFFj3NPM7VzWNx8El3wjUa9qN8NDn9xH4QUC6lynBTfFKKYG9cza3svsAHlNFQb+OMn0RFu+7XDNwssdJD4mrfLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699037792; c=relaxed/simple; bh=lReUVhvJTi0KamrkH23hSGxa0gYP+ivuK/c61i/8Hsw=; h=DKIM-Signature:MIME-Version:Message-ID:From:To:Subject:Date; b=KJ+2NOVoOT11XN32EdFWIzhP8dqoHbhvThVWpanwTDR/BX7WwntnoM3+T25Da9n+pfDg5xTF9bAQQfF5wZh+2wDcLBsMcQMyqpaqZMCcUPoiWBgfjX37I/h/xfiveFOvm4TyOu4/nvnnFV1n3Uxsltcwq2HTmmOd+dDbIUTJvfQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699037781; x=1699642581; i=anlauf@gmx.de; bh=lReUVhvJTi0KamrkH23hSGxa0gYP+ivuK/c61i/8Hsw=; h=X-UI-Sender-Class:From:To:Subject:Date; b=LpkyIZeY5VFiJRvG4mR1nb4NWbry6E+J7KSLWLZEtV0MxmZ2dbBMm8TCSZZ03yeg EYpk8cu46+E088ehV2DoM2yHCkGWszBowEx+Sml8/rBnx7dq2sUuawegvGRyoVlzw /67FMQOEMMVqaLQzniCoCPF8iQJRsBSNC+rtp9OEBjBqoTBPTGtAEiX6ob4e+EYCf BeWCo1S1mVkKmZvFdVI1aLaPiwhRy2whoYYcXY7KkzVhgOjqxZdr7u4iQJLWX3ySf MruxYAyoiLaaWkcgsKtdn9kEsxWiUfL5KFUKm/qI51dEdsKG/QakxwBOq4wJ6W+Ns xCIaXbZt8URQbWCnug== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.86.134] ([93.207.86.134]) by web-mail.gmx.net (3c-app-gmx-bs30.server.lan [172.19.170.82]) (via HTTP); Fri, 3 Nov 2023 19:56:20 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] Fortran: fix issue with multiple references of a procedure pointer [PR97245] Date: Fri, 3 Nov 2023 19:56:20 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:qZsflfRSVPY9A9W5i65QgQgIQ9wAwYgryrJ56BbRY0vhwwhtjigA+9WAz6VygIxODLPGp 3WjKGMyrjHUaN+9YNwo3Nb+oLjj3UzXBUUjNviZ+o7w33ygMg0WwstfqDPf6YW0hxrE7+bd83V+U CAINcvR+aijTkaFzgBVvaMqoC2wChq7l9SG2Z8yESDQ9t44dqqUjY/ZSE3Ct6XpL876pxOt/ybfV CNsai11u+ztVPlKfRmMtyHb3yG3dhqPS+SrS2RV7Lfl8H6eBA6ipG3gS6Ng7BydNxLlpt1FtybGy fI= UI-OutboundReport: notjunk:1;M01:P0:gA2Y4usQa8s=;IXpzl8Stqmj71kzywBm8K75NU/J a/AHxoZRV3bPkewzAfMFfJfLzxIGni7TiuIiD+eKnT2M4OaIKUiD14hxoqLL/GVdCvtZPLnKR KBvxBfnFCdNiVgpYX9T5GrhO0q/1P5RDa8PZ541oW+baIW5ltrbt56QHOtMlUAVezevlDjylY u02aDmlhQKuipKMEQizIaadjmsA2/14cC73K6j16iSzJYUPSnyFIvjfz3Sc8V73z723n1N5qY o8XecMsjkKH7tihaU7gT7SOTAiPUHwOr/i7wIwnoJ2Dwn3ONoRDbYaoKF5k5gErnf37/EQMf2 7AP9Xu34W4zOSBPW/ZB5L0633spmjX/puiJvqb93529c0UBH+bcw5RdlbpFHswjhj2TYil+rB ts6tPXBFaN6IrLTE2uly9Ki7IsNUGXwav/Alecg4jncmP5eGsNgv5Bm5g2Am/HOJ54hR7M45h jVxneHfwLSQmADY8durGGfuRZjPwvgOvMvoJ5MycTEgggYVc0H0dSakTboaHwOQXXvpAZP1c5 4iCOMyIsUomFRFz15H9m6UvyjPlvigkWkR7EpAwCuMlSNh3F8E9FyNCdbABsViLlXyq/hs8HF uEbrh7fdvTw60hxFd6Pynimx0tBNl9ZsJdputIOwjHjDidBwW2KzyywFvWTBrCZfqh4e9bYJf CwswAuJOmdLU3BS7AZKoJjSJ6AKuO6Ct7mB1deAYyZj4fzmBIp6W65JJFcEBeeHGpN8rb8iE5 OJaWeW8IYIX/e267xFefelVUYxri5onJMFeTrHNkjtsbdcAGLWITHjSnsoEB/gqvuAbfp1p4w reQ6VKPjZ0631tl4hBRhKSpy5KSrn9qqgbZH6kL+afAmk= X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Dear all, this is a rather weird bug with a very simple fix. If a procedure pointer is referenced in a CALL, a symbol was created shadowing the original declaration if it was host-associated. Funnily, this affected only references of the procedure pointer after the first CALL. Regtested on x86_64-pc-linux-gnu. OK for mainline? Would it be OK to backport this fix to 13-branch? Thanks, Harald From 1ca323b8d58846d0890a8595ba9fc7bc7eee8fdd Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 3 Nov 2023 19:41:54 +0100 Subject: [PATCH] Fortran: fix issue with multiple references of a procedure pointer [PR97245] gcc/fortran/ChangeLog: PR fortran/97245 * match.cc (gfc_match_call): If a procedure pointer has already been resolved, do not create a new symbol in a procedure reference of the same name shadowing the first one if it is host-associated. gcc/testsuite/ChangeLog: PR fortran/97245 * gfortran.dg/proc_ptr_53.f90: New test. --- gcc/fortran/match.cc | 1 + gcc/testsuite/gfortran.dg/proc_ptr_53.f90 | 35 +++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/proc_ptr_53.f90 diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index f848e52be4c..9e3571d3dbe 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -5064,6 +5064,7 @@ gfc_match_call (void) right association is made. They are thrown out in resolution.) ... */ if (!sym->attr.generic + && !sym->attr.proc_pointer && !sym->attr.subroutine && !sym->attr.function) { diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_53.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_53.f90 new file mode 100644 index 00000000000..29dd08d9f75 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_53.f90 @@ -0,0 +1,35 @@ +! { dg-do compile } +! PR fortran/97245 - ASSOCIATED intrinsic did not recognize a +! pointer variable the second time it is used + +MODULE formulaciones + IMPLICIT NONE + + ABSTRACT INTERFACE + SUBROUTINE proc_void() + END SUBROUTINE proc_void + end INTERFACE + + PROCEDURE(proc_void), POINTER :: pADJSensib => NULL() + +CONTAINS + + subroutine calculo() + PROCEDURE(proc_void), POINTER :: otherprocptr => NULL() + + IF (associated(pADJSensib)) THEN + CALL pADJSensib () + ENDIF + IF (associated(pADJSensib)) THEN ! this was erroneously rejected + CALL pADJSensib () + END IF + + IF (associated(otherprocptr)) THEN + CALL otherprocptr () + ENDIF + IF (associated(otherprocptr)) THEN + CALL otherprocptr () + END IF + end subroutine calculo + +END MODULE formulaciones -- 2.35.3