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 407DE3858D35; Tue, 22 Nov 2022 21:53:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 407DE3858D35 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=1669153996; bh=48Z5fdO2+QcsRYhpb5BatKFhof4CNy8PHCqCHJMHTOY=; h=X-UI-Sender-Class:From:To:Subject:Date; b=BcvafYwU8BQLk0AXNoFXS5n/DCBhZ6GD0ozlGbwy3RY8+OZfeOiqmxWc098mH7/i1 WfbK/VmL5Szktbkpr+XHTWbxtm7iYR9hUPqnWMnaTh0dxO1wFSnZSLf3q2ez0ms4S1 Urd44nbtKoYI21YYrY4bOD8GM3eeOg2vYImnhBfviT5LK9ICfcrDWL+alo6f39W8Lp H/1wAe3Nqfaq1WK1t13BHE3loOLLsi31hMpucsPbU2CzcM65ChTxobILkAHfzK0A8c 6JZblWLuOOYP899ERLqZSvEFrCJt9gCIP4BLrT62qnEvJ48d5P/DnPqF+FSdqbGmTo le4Iz+s1h9osw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.84.96] ([93.207.84.96]) by web-mail.gmx.net (3c-app-gmx-bap12.server.lan [172.19.172.82]) (via HTTP); Tue, 22 Nov 2022 22:53:16 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches , kargl@gcc.gnu.org Subject: [PATCH] Fortran: error recovery on associate with bad selector [PR107577] Content-Type: multipart/mixed; boundary=trekuen-b075f9ed-0a3b-45d1-bca4-cfb63bbba684 Date: Tue, 22 Nov 2022 22:53:16 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-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hgSsx7Hmc+OW4aVZW4g4j8q+xMlJ2SNIX jgTPihudBkWofEKXtfHZLAWzwrOnHrXCvA5hS1Gi7wdlzouAruF/UOw3u+vqXucJOaMv3hi/C ObYdZERfve9p7Tg7bqnlb1azsoZLhyApdebjbkv7aIVi4= X-Spam-Status: No, score=-12.4 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_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: --trekuen-b075f9ed-0a3b-45d1-bca4-cfb63bbba684 Content-Type: text/plain; charset=UTF-8 Dear all, please find attached an obvious patch by Steve for a technical regression that resulted from improvements in error recovery of bad uses of associate. Regtested on x86_64-pc-linux-gnu. Will commit soon unless there are comments. As a sidenote: the testcase shows that we resolve the associate names quite often, likely more often than necessary, resulting in many error messages produced for the same line of code. In the present case, each use of the bad name produces two errors, one where it is used, and one at the associate statement. That is probably not helpful for the user. Thanks, Harald --trekuen-b075f9ed-0a3b-45d1-bca4-cfb63bbba684 Content-Type: text/x-patch Content-Disposition: attachment; filename=pr107577.diff Content-Transfer-Encoding: quoted-printable =46rom 9ff8d2ec56d139b54e2f66f747142687a38d2106 Mon Sep 17 00:00:00 2001 From: Steve Kargl Date: Tue, 22 Nov 2022 22:31:51 +0100 Subject: [PATCH] Fortran: error recovery on associate with bad selector [PR107577] gcc/fortran/ChangeLog: PR fortran/107577 * resolve.cc (find_array_spec): Choose appropriate locus either of bad array reference or of non-array entity in error message. gcc/testsuite/ChangeLog: PR fortran/107577 * gfortran.dg/pr107577.f90: New test. =2D-- gcc/fortran/resolve.cc | 3 ++- gcc/testsuite/gfortran.dg/pr107577.f90 | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr107577.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 24e5aa03556..3396c6ce4a7 100644 =2D-- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -5005,8 +5005,9 @@ find_array_spec (gfc_expr *e) case REF_ARRAY: if (as =3D=3D NULL) { + locus loc =3D ref->u.ar.where.lb ? ref->u.ar.where : e->where; gfc_error ("Invalid array reference of a non-array entity at %L", - &ref->u.ar.where); + &loc); return false; } diff --git a/gcc/testsuite/gfortran.dg/pr107577.f90 b/gcc/testsuite/gfortr= an.dg/pr107577.f90 new file mode 100644 index 00000000000..94e6620a0ee =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107577.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! PR fortran/107577 - ICE in find_array_spec +! Contributed by G.Steinmetz + +program p + implicit none + associate (y =3D> f(4)) ! { dg-error "has no IMPLICIT type" = } + if (lbound (y, 1) /=3D 1) stop 1 ! { dg-error "Invalid array referenc= e" } + if (y(1) /=3D 1) stop 2 ! { dg-error "Invalid array referenc= e" } + end associate +end + +! { dg-error "has no type" " " { target *-*-* } 7 } =2D- 2.35.3 --trekuen-b075f9ed-0a3b-45d1-bca4-cfb63bbba684--