From patchwork Mon Mar 30 07:30:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Eggleston X-Patchwork-Id: 1263811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=permerror header.from=codethink.co.uk Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48rPJw3mdpz9sPk for ; Mon, 30 Mar 2020 18:31:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F988385C017; Mon, 30 Mar 2020 07:31:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from imap3.hz.codethink.co.uk (imap3.hz.codethink.co.uk [176.9.8.87]) by sourceware.org (Postfix) with ESMTPS id B0A8F385B834; Mon, 30 Mar 2020 07:31:01 +0000 (GMT) Authentication-Results: sourceware.org; dmarc=permerror header.from=codethink.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=mark.eggleston@codethink.co.uk Received: from [2.221.62.41] (helo=[192.168.0.10]) by imap3.hz.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1jIosu-0004E0-4I; Mon, 30 Mar 2020 08:31:00 +0100 To: fortran , gcc-patches From: Mark Eggleston Subject: [PATCH, 8/9/10 Regression] fortran: ICE equivalence with an element of an array PR94030 Message-ID: Date: Mon, 30 Mar 2020 08:30:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-26.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Please find attached patch for PR94030. OK to commit? gcc/fortran/ChangeLog:     Steven G. Kargl      PR fortran/94030     * resolve.c (resolve_equivalence): Correct formatting     around the label "identical_types".  Instead of using     gfc_resolve_array_spec use is_non_constants_shape_array     to determine whether the array can be used in a in an     equivalence statement. gcc/testsuite/ChangeLog:     Mark Eggleston      Steven G. Kargl      PR fortran/94030     * gfortran.dg/pr94030_1.f90: New test.     * gfortran.dg/pr94030_2.f90: New test. From 28562d99f2bc7c9418baf707c602bbf7aefbeec3 Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Fri, 27 Mar 2020 11:30:40 +0000 Subject: [PATCH] fortran: ICE equivalence with an element of an array PR94030 Deferred size arrays can not be used in equivalance statements. gcc/fortran/ChangeLog: PR fortran/94030 * resolve.c (resolve_equivalence): Correct formatting around the label "identical_types". Instead of using gfc_resolve_array_spec use is_non_constants_shape_array to determine whether the array can be used in a in an equivalence statement. gcc/testsuite/ChangeLog: PR fortran/94030 * gfortran.dg/pr94030_1.f90 * gfortran.dg/pr94030_2.f90 --- gcc/fortran/resolve.c | 6 +++--- gcc/testsuite/gfortran.dg/pr94030_1.f90 | 11 +++++++++++ gcc/testsuite/gfortran.dg/pr94030_2.f90 | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr94030_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr94030_2.f90 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 2dcb261fc71..bfafd3de07a 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -16855,7 +16855,8 @@ resolve_equivalence (gfc_equiv *eq) && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where)) continue; - identical_types: +identical_types: + last_ts =&sym->ts; last_where = &e->where; @@ -16863,8 +16864,7 @@ resolve_equivalence (gfc_equiv *eq) continue; /* Shall not be an automatic array. */ - if (e->ref->type == REF_ARRAY - && !gfc_resolve_array_spec (e->ref->u.ar.as, 1)) + if (e->ref->type == REF_ARRAY && is_non_constant_shape_array (sym)) { gfc_error ("Array %qs at %L with non-constant bounds cannot be " "an EQUIVALENCE object", sym->name, &e->where); diff --git a/gcc/testsuite/gfortran.dg/pr94030_1.f90 b/gcc/testsuite/gfortran.dg/pr94030_1.f90 new file mode 100644 index 00000000000..e63d3cc8da4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr94030_1.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! + +subroutine f(n) + integer :: n + integer :: arr(n) + integer :: i + equivalence (i, arr(1)) +end + +! { dg-error "Array 'arr' at .1. with non-constant bounds cannot be an EQUIVALENCE object" " " { target *-*-* } 8 } diff --git a/gcc/testsuite/gfortran.dg/pr94030_2.f90 b/gcc/testsuite/gfortran.dg/pr94030_2.f90 new file mode 100644 index 00000000000..84bfdeaa819 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr94030_2.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! +! Provided by Steve Kargl. + +subroutine foo(n,m) + integer, intent(in) :: n, m + integer a(n) + real b(n) + equivalence(a,b) + if (m /= 2) then + a = 1 + print *, a(1) + else + b = 42. + print *, b(1) + end if +end subroutine + +subroutine bar(m) + integer, intent(in) :: m + integer x(8) + real y(8) + equivalence(x,y) + if (m /= 2) then + x = 1 + print *, x(1) + else + y = 42. + print *, y(1) + end if +end subroutine + +! { dg-error "Array '.' at .1. with non-constant bounds cannot be an EQUIVALENCE object" " " { target *-*-* } 9 } -- 2.11.0