From patchwork Tue Nov 22 21:53:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 24598 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2455965wrr; Tue, 22 Nov 2022 13:54:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hFzhNLvN/jH6mmLen5RSDD28RShAOdOCnzNJ+8JmYj9KIoJoM46Y6Zy0R5W3jgbuUd38j X-Received: by 2002:a17:906:4bc4:b0:78d:6325:356 with SMTP id x4-20020a1709064bc400b0078d63250356mr21445917ejv.6.1669154044307; Tue, 22 Nov 2022 13:54:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669154044; cv=none; d=google.com; s=arc-20160816; b=JNhdPET/rxjfKDvVAyBHPoOdkWzZjLY7pA9bb4EmKX49HYM/udBK0jjSyKN7BQfREr c2OrJJJwxCTjwsQ189PmYg20pImwqysO2547EpE7WHRA0T4I8xdrZqeu8HSJbYH+Ash9 sP6Hvn+Ngw4TvVF27zc/oOIr4G/H5z4x22DFA2LU584xpahugGEyrTfbIZJ//5eVl0g2 sA/d5Fwoz1+suJZpbTld04Z2mkPo+FsGzYUj2XxuNnl/Z0yX6R2cmYiUlvmecOP487K5 /YYw0BAcjQifDGjbp6pYBWMvhw//2BzbVqR3LVJl230XciH+wPaGbyPoAnkHmXPXY7c2 D4iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=47+HVGAl9SNs9UmKqKrtAxC8mH9GzLd+EfxBBZ3MY7s=; b=MeHmBPy1+jNR+DbGpZUNpq4GbzOFwKUCDkq+lLO2OIQJ0WPBOXRkDWAKxpTPPsqsQB GTeXaAd8s98jdIhON0jqiHYxvQZH4ZzuNdGJKjpkDSG/4IPptVbTafON1SwT5wkcd/x0 UYh5Xp+BUtWrYJSeDaR7iuVGbLLKyD+wzWjhqPO7yQ16C2F0eljdwUD5ZW0qBOXYjrke 1R3LWMX8YtEEM9MY8RSEGmkY6nmBGlngnKmrR0guiJyTfQBIbtAaGg9CS1Luy79zx0G3 gmyVPdmbz04gxxMhpePhOiZRopglVZa8dUqkOXf64L/uBXpENJP9d2mZwUL3UF17ys/l 4enw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hYkeL1hP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z2-20020a1709063ac200b0073d8f141e76si10120963ejd.130.2022.11.22.13.54.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 13:54:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hYkeL1hP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C17EB385843A for ; Tue, 22 Nov 2022 21:54:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C17EB385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669154041; bh=47+HVGAl9SNs9UmKqKrtAxC8mH9GzLd+EfxBBZ3MY7s=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hYkeL1hPUgvX8wAz5IfqMEOdyK2oJgXtP5QTMMfJNr2R12XwhzUmNWlHTG9MBRg3H Pf93WPJqXFVTR+QEoVdW++32Bsa3u5wX/tJOEXbg9qt7HCIPAhNVf2czS0GOLke1Qf KXIRx0qp3Z+tsUSIUHOqsHbNgLfVm/hzbY8mMXYA= 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.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 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: To: fortran , gcc-patches , kargl@gcc.gnu.org Subject: [PATCH] Fortran: error recovery on associate with bad selector [PR107577] Date: Tue, 22 Nov 2022 22:53:16 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:YgHW0JYHltAR61+cYnAHHUgnA1K+qX5maTTK6OqtPpACzYlCTx+qPUZncXxm5r1KCaTbB Xvfm279REAMPoUNGewWItBzrAHU/prbPYzGf1FQ0cKeq6TqQ3DGJfv+gRniUqPmeS9EgDGlfJ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4= 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 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750234870891522995?= X-GMAIL-MSGID: =?utf-8?q?1750234870891522995?= 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 From 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. --- 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 --- 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 == NULL) { + locus loc = 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/gfortran.dg/pr107577.f90 new file mode 100644 index 00000000000..94e6620a0ee --- /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 => f(4)) ! { dg-error "has no IMPLICIT type" } + if (lbound (y, 1) /= 1) stop 1 ! { dg-error "Invalid array reference" } + if (y(1) /= 1) stop 2 ! { dg-error "Invalid array reference" } + end associate +end + +! { dg-error "has no type" " " { target *-*-* } 7 } -- 2.35.3