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 DAC113858298; Thu, 26 Oct 2023 20:43:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DAC113858298 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 DAC113858298 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698352995; cv=none; b=Tfak4y9S8odXo4WQ3XuwYtejiHtRM+O2Y//plRKJLxMx3Eo91C1t46NFeCqwoIvIcFVh/QDI2f+8mZCXw8IcjVotHg8WgfbWDPB9rxDu/Oxj8Hu5F2Ao+fPZIwerD6QE+/W4Yex5m21cjMAAcQ+73HjRAFtiaxvTKj5Qak0bo7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698352995; c=relaxed/simple; bh=cRZSG/BAN8KYIdXNpbBQ/Qf3+yvX9eAgyPjeUK0X2sc=; h=DKIM-Signature:MIME-Version:Message-ID:From:To:Subject:Date; b=rjIVGoWJz0vdvOfbo29TfhsYyrwXQGQMQNmAUteuX/RI7qrSXwgqSWFXVnxh+64JDnekKabcQbIooaDHgXkE++TJteYdovQV2z0Bh37VcGfhpwsnkbOqU+zRKxyv69fVV62kofW1ccV4m4i2IKibSuqEz3Cs12HeFLrtZzux5Nc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1698352992; x=1698957792; i=anlauf@gmx.de; bh=cRZSG/BAN8KYIdXNpbBQ/Qf3+yvX9eAgyPjeUK0X2sc=; h=X-UI-Sender-Class:From:To:Subject:Date; b=BosqJZygdZGcf1FAQlPo2Ax8fawSJGfPmjQaqO32LBDrZrF1hlGIOM+vn0Jsazq7 Agd+7N/Iy5fz0tMD90eXD3HOFnWK6eAlxatv21V/vXcrmbcRZmscdY8ZFaLEqoS0E 3R06F/XAXXPlfmwzmeMLfhS1UP3MJsL7ppy0EP108stFgCf3rtBso1wexdpwZojr2 cKV0X5HUbEbF7X5fj2iIzkauubGvHInEslRmIOcikZUR5JXlV/36CydccUY/V4krc 56Tu7KukyQ+G3+n0uL2LqZSMA72342/qU7e0PhKkchbDfJvqx3+tKoK87Pk51x08f 0ouRgKhnndvn078NYA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.86.162] ([93.207.86.162]) by web-mail.gmx.net (3c-app-gmx-bap25.server.lan [172.19.172.95]) (via HTTP); Thu, 26 Oct 2023 22:43:12 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] Fortran: diagnostics of MODULE PROCEDURE declaration conflicts [PR104649] Content-Type: multipart/mixed; boundary=abmob-a578f4df-d965-4b5b-99ed-4f8cbb7f71ab Date: Thu, 26 Oct 2023 22:43:12 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:sZd0HKTU7dSNqQ0xXdNvNkFi4LohG+77Xd0CrkNBQds+oIQsb93hd8Ccm4hzGgJeAQXZx PiVsvfpGZu84u/YWGYpVcuFj93Ssea9ghGsKnt8qfI2dr5xPmXNoivArQ56Lssov/gsSrAljZaJ/ iCfN3LEwkKSvTRHlVCqAj6I58Qw1gkpLODg3GryE9I88/gDr1REY/0suSIB+rp7akber539QgJsE ORV03+n198rg9ECmhAZb6eF5/Y3M/D+L1wfJ8Dte8Ta9LCQCRanuH8Qk2BRzD7pko2CKBIYRbyRo AA= UI-OutboundReport: notjunk:1;M01:P0:V57z/mRGKCU=;zeDfKIxVwiLY5rtdagnmDYBuG7B Pu5rYashY7UDD2iaJAaMUAwvVvy9smkuyPmF3CG7/dPXLguPGfA0TLaqUyECRkipsg55w0RHG +VrUJYK9/V+NLmb+drIDpnPXiC4xsSzBhsWgNe3Oc6t69yrdPULDY+cIe4FsFQ+NJSXuD9kJw XH5ua9WdEp/Y0IvZwdL7w4R3533G4qo6XosExD4ML2hEHigMm1pJRM0Cam6HVRovNhg7AIqaz aqm2Kv3mNUVyBRL8Er2dBPN6x6fcxocaXe9SIWvnrgqx4FQoPGJet14QNYaJLOO5Mun8phSPl VsB8x5MyqzuAYfLCURf/7roB1jbwoOAwPjEPTHJsP+T0P9+cN2ffPHEZ1z8GI3XiYI0iVO79l zUDXhkz8oVlA8Qb4NBGhxnmXD334izqNkxDyjIrxMC8V5dpmV9H9DQ018p+1r+7WwBfIYeU0q yCM/TFLqmQNTrtXvjMGAYIJ9YP4CRvCbaTSdHtbX26DcmYcD8bJganpsXupMgRkj8UDO38LQC z2TnwVf9Rp2U/RpJ4WRRx14tsCgOPn3Ir3tMH38NXLXdXUu3eEc1S5JdhGV8hAxFt6kU3usYd 0lGH3lsh49Vikb5WL6XElmt2TuZM38bMot97BMru2Ucb+WM6wTkM0e7Bz8kZOggJv5t5cCyUr ITA+2Lb3z7e9OsPYofmd6ccKPcpmR0bqRV+9mB2vSuEHRdPhIzecCs7PV3P1W6NFyc71XZ8DO c1A/5we0rHHkpgO1XWZwnFGR8Fp142KpipQoe9fClkAlFbDW0HRjHS4hl+FMrmbPJnkkvTM9p Rd9C8ebbGl5jcM1Hfspxlzkw== X-Spam-Status: No, score=-11.7 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_H3,RCVD_IN_MSPIKE_WL,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: --abmob-a578f4df-d965-4b5b-99ed-4f8cbb7f71ab Content-Type: text/plain; charset=UTF-8 Dear all, the attached patch improves the diagnostics of MODULE PROCEDURE declaration conflicts, when one of the declarations is an alternate return. We used to ICE before. Steve identified the cause of the issue and provided a partial fix. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald --abmob-a578f4df-d965-4b5b-99ed-4f8cbb7f71ab Content-Type: text/x-patch Content-Disposition: attachment; filename=pr104649.diff Content-Transfer-Encoding: quoted-printable =46rom 9d591a73f070e6090b7c59dca928b84b1c261d92 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 26 Oct 2023 22:32:35 +0200 Subject: [PATCH] Fortran: diagnostics of MODULE PROCEDURE declaration conflicts [PR104649] gcc/fortran/ChangeLog: PR fortran/104649 * decl.cc (gfc_match_formal_arglist): Handle conflicting declarations of a MODULE PROCEDURE when one of the declarations is an alternate return. gcc/testsuite/ChangeLog: PR fortran/104649 * gfortran.dg/pr104649.f90: New test. Co-authored-by: Steven G. Kargl =2D-- gcc/fortran/decl.cc | 21 +++++++++--- gcc/testsuite/gfortran.dg/pr104649.f90 | 44 ++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr104649.f90 diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index bdd3be32a46..4893c582065 100644 =2D-- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -6796,12 +6796,25 @@ ok: || (p->next =3D=3D NULL && q->next !=3D NULL)) arg_count_mismatch =3D true; else if ((p->sym =3D=3D NULL && q->sym =3D=3D NULL) - || strcmp (p->sym->name, q->sym->name) =3D=3D 0) + || (p->sym && q->sym + && strcmp (p->sym->name, q->sym->name) =3D=3D 0)) continue; else - gfc_error_now ("Mismatch in MODULE PROCEDURE formal " - "argument names (%s/%s) at %C", - p->sym->name, q->sym->name); + { + if (q->sym =3D=3D NULL) + gfc_error_now ("MODULE PROCEDURE formal argument %qs " + "conflicts with alternate return at %C", + p->sym->name); + else if (p->sym =3D=3D NULL) + gfc_error_now ("MODULE PROCEDURE formal argument is " + "alternate return and conflicts with " + "%qs in the separate declaration at %C", + q->sym->name); + else + gfc_error_now ("Mismatch in MODULE PROCEDURE formal " + "argument names (%s/%s) at %C", + p->sym->name, q->sym->name); + } } if (arg_count_mismatch) diff --git a/gcc/testsuite/gfortran.dg/pr104649.f90 b/gcc/testsuite/gfortr= an.dg/pr104649.f90 new file mode 100644 index 00000000000..f301ffcde1f =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr104649.f90 @@ -0,0 +1,44 @@ +! { dg-do compile } +! { dg-options "-w" } +! PR fortran/104649 +! Contributed by G.Steinmetz + +module m + interface + module subroutine s(x) + real :: x + end + end interface +end +submodule(m) m2 +contains + module subroutine s(*) ! { dg-error "conflicts with alternate return" } + end +end + +module n + interface + module subroutine s(*) + end + end interface +end +submodule(n) n2 +contains + module subroutine s(x) ! { dg-error "formal argument is alternate retur= n" } + real :: x + end +end + +module p + interface + module subroutine s(x) + real :: x + end + end interface +end +submodule(p) p2 +contains + module subroutine s(y) ! { dg-error "Mismatch in MODULE PROCEDURE forma= l argument names" } + real :: y + end +end =2D- 2.35.3 --abmob-a578f4df-d965-4b5b-99ed-4f8cbb7f71ab--