From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 861533858C53; Wed, 21 Sep 2022 21:07:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 861533858C53 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.net; s=badeba3b8450; t=1663794424; bh=FwS8t8z1I/iWec1lir/qmrmV6ZVUiChZx2B6JLWXONM=; h=X-UI-Sender-Class:From:To:Subject:Date; b=TOVNwVPdDacFInJOxty9WyUROZp43oRNEI2uly1DEQvNhaQf6GMJQuzowF8qcFN0J YIcVYKOG/57qDaYhkr+V/UsURPtfHezHSYg5lvdTK4EmlA4vKWf9rNg6yIsY5qWJbj h0sHRvzDRInhctk6jaS/qwjhFglUyuy92cltjKBU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.89.8] ([93.207.89.8]) by web-mail.gmx.net (3c-app-gmx-bap37.server.lan [172.19.172.107]) (via HTTP); Wed, 21 Sep 2022 23:07:04 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: Proxy ping [PATCH] Fortran: Fix automatic reallocation inside select rank [PR100103] Content-Type: multipart/mixed; boundary=abmob-5ec73c37-1991-4a49-b197-52c6630f2123 Date: Wed, 21 Sep 2022 23:07:04 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:QQt/9iQW7qTGj7HvWu+7s6LcV1p/FB4NZ1HH857RemJM+QVGTFdRL3bJ4QhVpopn+Ur8s 2IRn+RgnN5R527iXlKwbti7RcOT2UjzXlXTSiZIhRR4qenbEQJosRY9JrW9esxXuk9H46x9Sjff8 db72ZSxWUHT+Ch/0PVANKxWHV80VC0TQGMQ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CVD_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: --abmob-5ec73c37-1991-4a49-b197-52c6630f2123 Content-Type: text/plain; charset=UTF-8 Dear all, the patch for this PR was submitted for review by Jose here: https://gcc.gnu.org/pipermail/fortran/2021-April/055934.html but unfortunately was never reviewed. I verified that it works on mainline and x86_64-pc-linux-gnu, and I think that it is fine. Although the above mail suggests that there is a dependency on the fix for another PR with a rather lengthy patch, it appears that this is no longer the case. It might be that the fix for PR100245 (another reallocation issue) already did the necessary job. So OK for mainline? Thanks, Harald --abmob-5ec73c37-1991-4a49-b197-52c6630f2123 Content-Type: text/x-patch Content-Disposition: attachment; filename=pr100103.diff Content-Transfer-Encoding: quoted-printable =46rom 6c93c5058f552f47a3d828d3fb19cca652901299 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Jos=3DC3=3DA9=3D20Rui=3D20Faustino=3D20de=3D20Sousa?=3D Date: Wed, 21 Sep 2022 22:55:02 +0200 Subject: [PATCH] Fortran: Fix automatic reallocation inside select rank [PR100103] gcc/fortran/ChangeLog: PR fortran/100103 * trans-array.cc (gfc_is_reallocatable_lhs): Add select rank temporary associate names as possible targets of automatic reallocation. gcc/testsuite/ChangeLog: PR fortran/100103 * gfortran.dg/PR100103.f90: New test. =2D-- gcc/fortran/trans-array.cc | 4 +- gcc/testsuite/gfortran.dg/PR100103.f90 | 76 ++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/PR100103.f90 diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 05134952db4..795ce14af08 100644 =2D-- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -10378,7 +10378,7 @@ gfc_is_reallocatable_lhs (gfc_expr *expr) /* An allocatable class variable with no reference. */ if (sym->ts.type =3D=3D BT_CLASS - && !sym->attr.associate_var + && (!sym->attr.associate_var || sym->attr.select_rank_temporary) && CLASS_DATA (sym)->attr.allocatable && expr->ref && ((expr->ref->type =3D=3D REF_ARRAY && expr->ref->u.ar.type =3D= =3D AR_FULL @@ -10393,7 +10393,7 @@ gfc_is_reallocatable_lhs (gfc_expr *expr) /* An allocatable variable. */ if (sym->attr.allocatable - && !sym->attr.associate_var + && (!sym->attr.associate_var || sym->attr.select_rank_temporary) && expr->ref && expr->ref->type =3D=3D REF_ARRAY && expr->ref->u.ar.type =3D=3D AR_FULL) diff --git a/gcc/testsuite/gfortran.dg/PR100103.f90 b/gcc/testsuite/gfortr= an.dg/PR100103.f90 new file mode 100644 index 00000000000..21405610a71 =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100103.f90 @@ -0,0 +1,76 @@ +! { dg-do run } +! +! Test the fix for PR100103 +! + +program main_p + implicit none + + integer :: i + integer, parameter :: n =3D 11 + + type :: foo_t + integer :: i + end type foo_t + + type(foo_t), parameter :: a(*) =3D [(foo_t(i), i=3D1,n)] + + type(foo_t), allocatable :: bar_d(:) + class(foo_t), allocatable :: bar_p(:) + class(*), allocatable :: bar_u(:) + + + call foo_d(bar_d) + if(.not.allocated(bar_d)) stop 1 + if(any(bar_d%i/=3Da%i)) stop 2 + deallocate(bar_d) + call foo_p(bar_p) + if(.not.allocated(bar_p)) stop 3 + if(any(bar_p%i/=3Da%i)) stop 4 + deallocate(bar_p) + call foo_u(bar_u) + if(.not.allocated(bar_u)) stop 5 + select type(bar_u) + type is(foo_t) + if(any(bar_u%i/=3Da%i)) stop 6 + class default + stop 7 + end select + deallocate(bar_u) + +contains + + subroutine foo_d(that) + type(foo_t), allocatable, intent(out) :: that(..) + + select rank(that) + rank(1) + that =3D a + rank default + stop 8 + end select + end subroutine foo_d + + subroutine foo_p(that) + class(foo_t), allocatable, intent(out) :: that(..) + + select rank(that) + rank(1) + that =3D a + rank default + stop 9 + end select + end subroutine foo_p + + subroutine foo_u(that) + class(*), allocatable, intent(out) :: that(..) + + select rank(that) + rank(1) + that =3D a + rank default + stop 10 + end select + end subroutine foo_u + +end program main_p =2D- 2.35.3 --abmob-5ec73c37-1991-4a49-b197-52c6630f2123--