From patchwork Wed Jan 25 19:53:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 48289 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp457071wrn; Wed, 25 Jan 2023 11:54:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXsZ87Cfv+85qKgec7kOH1iUX6y6kzHBmkSIM+J06TqmX/DZTPu4xwxQy16YDlqaQ+a6JLL5 X-Received: by 2002:a17:907:971d:b0:870:d15a:c2dc with SMTP id jg29-20020a170907971d00b00870d15ac2dcmr45805311ejc.74.1674676469172; Wed, 25 Jan 2023 11:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674676469; cv=none; d=google.com; s=arc-20160816; b=qjrC5/mHsQSrqSPlnfKc3Ob0zRfkfFfk/CSbIJEYUs2v8YIzAsVawizlEKOb21DYgx tmRciwhLDDjsu1a0Jwy/tkv1rl7FpIBZ8H05NSh3bCdzKNvW0qO9ea51oldFQ8vdbHU7 p8KNwPSNRLJYSqnp5SrCAedkGlV8Fq+qc4wo2ZisygGqb5eiQwRtt4sPPEnbi6S7lL2v GVtgE3fI1stRxjeJDBFIx7UgpbzlWtyFcarandDRsb9we5rKdAR8WXLnWyCOec7qU2oF /Yo9C4PsitWCfjxX1d1qToNjtZbbPBNWgDu5+GYgF/Ffnqi7plBILHKTGcFwSXbhdLMu XJuw== 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=DRtHzhrkBqwG23jxUWQTuhjSObgV6I1dyFo97kGBtFQ=; b=UdrxVNPsjd+YJVhBVmxNpr032F2SIGQ1WHYRVDQ7dKj6TLX/gG4v531iJcR6weJGT3 ylGwDuqKzNosWslLBqscREQrbzlpXoVi+Q190+px89BJTx6NFmLiQJ5BYJl4g7QTZK2D Q4PRM40ssiXGXG4D2kzAbUMWvyZKM+WdO2Lk7y9/xnWsXKNbfDVAoP/ymKYFcOGskNa1 gAALzReI/snrvdFohNsDH8F4taJdh0L1P3Jsu+uBTX6eoN2hSKvvU4i0Ts2O2ZL0cs27 bOvP7TwOHFE8/KOJluIBts8HD8dfDKQZ1AnEjl9NkYgOgeZQh6jS60z9t+17DkMtlcZ2 8EDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Lxiru3dV; 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 w5-20020a170906968500b0084d0b4b4fcdsi7178748ejx.194.2023.01.25.11.54.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 11:54:29 -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=Lxiru3dV; 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 F00BF3858417 for ; Wed, 25 Jan 2023 19:54:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F00BF3858417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674676462; bh=DRtHzhrkBqwG23jxUWQTuhjSObgV6I1dyFo97kGBtFQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Lxiru3dV0ofb3NBU34Ngjah3EMMWKnSrOg3APR6czs78QJukqMWVIWORSzMB/m1rp 6qYvSdHO5lt+NecydEf3MwkRslOBCiwVNCwtsb2ZmEbxMo0h1vBMgMCCoSysiiUlh1 P0wyXemcVbCuN0N/kl4eX8WrlUg9sMiYqBadFldg= 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 44CAC3858D28; Wed, 25 Jan 2023 19:53:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 44CAC3858D28 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.89.26] ([93.207.89.26]) by web-mail.gmx.net (3c-app-gmx-bs46.server.lan [172.19.170.98]) (via HTTP); Wed, 25 Jan 2023 20:53:36 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: ICE in gfc_compare_array_spec [PR108528] Date: Wed, 25 Jan 2023 20:53:36 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:d0XXjCzeiJrUhfS+RUewo42CWtMjqa9PFZxCa1YC2f1/NIAj6Kl1/Vmq+LD7RpVTUPMwo INzLpY2BdUDVi9rhINFj4sH8ppEoPeJfK99JLu6VcdRJBZ1xts4jEx8MoeY2ocWEwyVZNLy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JY= X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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?1756025553406697732?= X-GMAIL-MSGID: =?utf-8?q?1756025553406697732?= Dear all, I've committed the attached simple and obvious patch by Steve after regtesting on x86_64-pc-linux-gnu. Instead of generating an internal error when wrong types are passed to a bounds comparison, simply return false. Committed: https://gcc.gnu.org/g:9fb9da3d38513d320bfea72050f7a59688595e0b Thanks, Harald From 9fb9da3d38513d320bfea72050f7a59688595e0b Mon Sep 17 00:00:00 2001 From: Steve Kargl Date: Wed, 25 Jan 2023 20:38:43 +0100 Subject: [PATCH] Fortran: ICE in gfc_compare_array_spec [PR108528] gcc/fortran/ChangeLog: PR fortran/108528 * array.cc (compare_bounds): Return false instead of generating an internal error on an invalid argument type. gcc/testsuite/ChangeLog: PR fortran/108528 * gfortran.dg/pr108528.f90: New test. --- gcc/fortran/array.cc | 4 ++-- gcc/testsuite/gfortran.dg/pr108528.f90 | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr108528.f90 diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index e8a2c32a627..be5eb8b6a0f 100644 --- a/gcc/fortran/array.cc +++ b/gcc/fortran/array.cc @@ -967,7 +967,7 @@ gfc_copy_array_spec (gfc_array_spec *src) /* Returns nonzero if the two expressions are equal. - We should not need to support more than constant values, as that’s what is + We should not need to support more than constant values, as that's what is allowed in derived type component array spec. However, we may create types with non-constant array spec for dummy variable class container types, for which the _data component holds the array spec of the variable declaration. @@ -979,7 +979,7 @@ compare_bounds (gfc_expr *bound1, gfc_expr *bound2) if (bound1 == NULL || bound2 == NULL || bound1->ts.type != BT_INTEGER || bound2->ts.type != BT_INTEGER) - gfc_internal_error ("gfc_compare_array_spec(): Array spec clobbered"); + return false; /* What qualifies as identical bounds? We could probably just check that the expressions are exact clones. We avoid rewriting a specific comparison diff --git a/gcc/testsuite/gfortran.dg/pr108528.f90 b/gcc/testsuite/gfortran.dg/pr108528.f90 new file mode 100644 index 00000000000..7a353cb7eab --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr108528.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/108528 - +! Contributed by G.Steinmetz + +function f() ! { dg-error "mismatched array specifications" } + integer :: f((2.)) ! { dg-error "must be of INTEGER type" } + integer :: g((2)) +entry g() +end -- 2.35.3