From patchwork Tue Aug 23 20:29:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1125789wro; Tue, 23 Aug 2022 13:30:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR7G4yjXjm2qEb0cf4I/SH056QmLEbn2jXl+USZY4Xs3rnvrxO5277kmuUq+Ds6AoKw1D4ss X-Received: by 2002:a17:907:9625:b0:730:ad62:9c86 with SMTP id gb37-20020a170907962500b00730ad629c86mr800152ejc.281.1661286651853; Tue, 23 Aug 2022 13:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661286651; cv=none; d=google.com; s=arc-20160816; b=MsFNTOXjuAnG6wDCB055EokVD3fUvobOJ0brBGUMxuFFfZlfuyQVdI2HOtYg1QZV1W psPBI74rzwIiGl6R2p1VpOu+zf4/0ciH5ssTqdFI5iuXhVfj5swepXdC0ux29IMJCTKd yBlRhTr/XdHg7K1Y7aAtz3n5jdnjpkPPjHEA29jiGJZlWlda921zs2Mpp4VhDkXgUjdm iTEVUjplyEe3r8JmIOl1x7lGwfWDP0cyYplWkkFugq61iv/DOiAguvK5AeAQwgh9Ek5R 1zgY9gUTBf7JwDVCBQ1WSJpUducTZaZrR1SuLuDPTakMwkacf79RjjcOM0bVoXGTP9p3 XkOA== 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:sensitivity :importance:date:subject:to:message-id:mime-version:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=Q33uDgNXaez2xjrku53lJQyLi+26dz2jDB+CrvbZ6e8=; b=b0iF7Uc2dEDvHAxmIkVeRlVkQj4oDnCABDSns1HhIatc9G6mJm2UBWbjuP5YcpGrPT R0ygTwRKV8Dur5laIZJ4QuoCUF68OewpdT9XmD9BDHjhRbmmCZ4kFtPhIMNlYX+kufI1 ubLRrhKcrTlLLu0T0EwRYUifi6WHgk4WNkFzqjVv4Xr1/mgJbsKsJnn8FRwMPIJ4bQCO PbqsuL4QCRx0Yihr0nt8+3ywMDCyg0tWMJi/jkj98Lw2wk668LTCZMsBxwylVqo2Uial 1KqnAo6mR4G0RWRD1iV2XIGT/wViZ7yGieCfD7r2bynb1a/zfjpxC8oBjAcaT42SCQJI v/qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="WH/ar5Mx"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id di5-20020a170906730500b00726b8d2fbc6si520387ejc.504.2022.08.23.13.30.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 13:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="WH/ar5Mx"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 531B73857C71 for ; Tue, 23 Aug 2022 20:30:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 531B73857C71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661286649; bh=Q33uDgNXaez2xjrku53lJQyLi+26dz2jDB+CrvbZ6e8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WH/ar5MxTAWwAFto9NhgP04U86pZ8Ey9y2vHPeDlYoeAH5H/UIgJKMuGEM4b2KW+i mGEvV3EhS0MOtSmzWF010uFswUv5LClJxJUsiG89p9hbFI/mwkPFQY6WCMOPM+HdJq yaKIZ9ZJpIJVO5O7Qic/G/VkO+y4RDuTeAKAbX3Y= 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.20]) by sourceware.org (Postfix) with ESMTPS id 6DEDA3858D1E; Tue, 23 Aug 2022 20:29:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6DEDA3858D1E X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.11.22] ([79.251.11.22]) by web-mail.gmx.net (3c-app-gmx-bap05.server.lan [172.19.172.75]) (via HTTP); Tue, 23 Aug 2022 22:29:43 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: improve error recovery while simplifying size of bad array [PR103694] Date: Tue, 23 Aug 2022 22:29:43 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:f2fP64EZmiyd+SZ9wc8WuXGHlDPMO7JlL6XqBdrK2tFUHjKca6I9DnVtqri/ZNjzSkBaw VAXFRbqLe6mAL6PKz6lWwtyw7+ZLNyH7CD3K/VOXwt0v3YRR0iXlFNHeYE66N7uINKrWKcWJE73N rL5ccsPb+FrAK+Ig3aATf2vjctll88j+j1PS1MQO/GzoP69VkfrrVOl1ScZYKVnABl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F_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.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?1741985311934140101?= X-GMAIL-MSGID: =?utf-8?q?1741985311934140101?= Dear all, the simplification of the size of an array with a bad decl should not be successful. Improve the error recovery for such a situation. The patch is nearly obvious. I therefore intend to commit it in the next few days unless someone comes up with a better solution. Regtested on x86_64-pc-linux-gnu. The PR is marked as a 12/13 regression. Will therefore commit to both. Thanks, Harald From d306c0b171e502e3c87b92b6bc63b532f734e754 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 23 Aug 2022 22:16:14 +0200 Subject: [PATCH] Fortran: improve error recovery while simplifying size of bad array [PR103694] gcc/fortran/ChangeLog: PR fortran/103694 * simplify.cc (simplify_size): The size expression of an array cannot be simplified if an error occurs while resolving the array spec. gcc/testsuite/ChangeLog: PR fortran/103694 * gfortran.dg/pr103694.f90: New test. --- gcc/fortran/simplify.cc | 5 +++-- gcc/testsuite/gfortran.dg/pr103694.f90 | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr103694.f90 diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index f992c31e5d7..bc178d54891 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -7536,8 +7536,9 @@ simplify_size (gfc_expr *array, gfc_expr *dim, int k) } for (ref = array->ref; ref; ref = ref->next) - if (ref->type == REF_ARRAY && ref->u.ar.as) - gfc_resolve_array_spec (ref->u.ar.as, 0); + if (ref->type == REF_ARRAY && ref->u.ar.as + && !gfc_resolve_array_spec (ref->u.ar.as, 0)) + return NULL; if (dim == NULL) { diff --git a/gcc/testsuite/gfortran.dg/pr103694.f90 b/gcc/testsuite/gfortran.dg/pr103694.f90 new file mode 100644 index 00000000000..3ed8b2088da --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103694.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/103694 - ICE in gfc_conv_expr_op +! Contributed by G.Steinmetz + +subroutine s + type t + integer :: a(2) + end type + type(t) :: x((0.)/0) + integer :: n = size(x(1)%a) ! { dg-error "does not reduce to a constant expression" } +end -- 2.35.3