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 4DDD6388A83A; Wed, 16 Dec 2020 21:12:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4DDD6388A83A X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.83.66] ([93.207.83.66]) by web-mail.gmx.net (3c-app-gmx-bs18.server.lan [172.19.170.70]) (via HTTP); Wed, 16 Dec 2020 22:12:28 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH] PR fortran/98307 - Dependency check fails when using "allocatable" Content-Type: multipart/mixed; boundary=trekuen-5ef68f4d-1732-46f0-8c4b-335d3255cf19 Date: Wed, 16 Dec 2020 22:12:28 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:6K86DfYkG3eJXTrLJgoVwbanvzK4zOIjOLTI/sgxTHKghSl91pCq3+RtqjHNcfqH91vCv epfr+2aORRiVDMOvsVkrt6/yFQ+5GS7BCXMpGpZIIRlGx+hS7DQAIWVwz3qo2vBSg9zrg0cTv1Qi vTOMLw9N6Kl5ZX7eaiNhYSmE1vKCfj47RVgeybXkg91AJ9lYf6QqX8PXqaN+Hhloy+iUomT3Wq2f RoQUP+aV0OXQ1vVQ+tjYtSfJLAuINMzOe3Koo5B5Aq/s+Mm2dHzzHZxOwtvA0ihkg7GajdrRcaBB sA= X-UI-Out-Filterresults: notjunk:1;V03:K0:V2e4wPYVaf4=:CD0me60jNsumNKryxgCW+x 0NY0oEOeFxAQ94yrepFiwVA4QSHPMa1chfpu7T7Wha1wQemEabmctF/gyJn4nirxMbNcVQHTw 6r7lJKxP+hv9xCoJLuKUCRA0Epdtz5KJaoXUXolV0jGtcouDBnbkEoyte5hpXrWbA4TrwhODB q3FVH35dsfAmuFO5UttQ3h+AZepDN043DI96tPukbgtiUTrusieZSyJyrqbPLih32bpVR0In1 uVIHeTdC/m/RX5JqaMeqety1gFcXxCSkpCYyGeKX2x5eKRgp7cS2lBbm37lTF3vIvadVdQNwG GRnx94uo4ik0hKY91QRV0/Ulkk5Cyei5JVuznzSoU+9yiLDGIviHufv1chkbSC9RF2OFkWO2j CmMmKwNVcl3LfXKhJTsDkRHTc7XEmmkBaGUh+Fb81DED3gcgWHXrzwE1sKn6XQl/tZSFsJHsQ 8TRm2gq+n9RjPiHg4ZBN/T8QlWN67G6maBORhQfAVvW58zlFDywLm2IuAk0d+3YeMnCymfGCy UL/Jh9uZjg9TTE/DW1x7umBQ6H/ckfVIKQUd9UqNSqyh9u9Qe5jtjbRYywGF12SKf61lpgal0 KJZKu/KF7caxg= X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Dec 2020 21:12:32 -0000 --trekuen-5ef68f4d-1732-46f0-8c4b-335d3255cf19 Content-Type: text/plain; charset=UTF-8 Dear all, since the introduction of check_forall_dependencies() we mishandled the dependencies of ALLOCATABLE components of derived types, while POINTER was dealt with. Fix that. Regtested on x86_64-pc-linux-gnu. OK for master? Since we generate wrong code under the given circumstances, what do people think about backports? Thanks, Harald PR fortran/98307 - Dependency check fails when using "allocatable" The dependency check for FORALL constructs already handled pointer components to derived types, but missed allocatables. Fix that. gcc/fortran/ChangeLog: PR fortran/98307 * trans-stmt.c (check_forall_dependencies): Extend dependency check to allocatable components of derived types. gcc/testsuite/ChangeLog: PR fortran/98307 * gfortran.dg/forall_19.f90: New test. --trekuen-5ef68f4d-1732-46f0-8c4b-335d3255cf19 Content-Type: text/x-patch Content-Disposition: attachment; filename=pr98307.patch Content-Transfer-Encoding: quoted-printable diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index adc6b8fefb5..112a4e8ead9 100644 =2D-- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -3949,9 +3949,10 @@ check_forall_dependencies (gfc_code *c, stmtblock_t= *pre, stmtblock_t *post) point to the copy instead. Note that the shallow copy of the variable will not suffice for derived types with pointer components. We therefore leave these to their - own devices. */ + own devices. Likewise for allocatable components. */ if (lsym->ts.type =3D=3D BT_DERIVED - && lsym->ts.u.derived->attr.pointer_comp) + && (lsym->ts.u.derived->attr.pointer_comp + || lsym->ts.u.derived->attr.alloc_comp)) return need_temp; new_symtree =3D NULL; diff --git a/gcc/testsuite/gfortran.dg/forall_19.f90 b/gcc/testsuite/gfort= ran.dg/forall_19.f90 new file mode 100644 index 00000000000..ef05c97ab24 =2D-- /dev/null +++ b/gcc/testsuite/gfortran.dg/forall_19.f90 @@ -0,0 +1,32 @@ +! { dg-do run } +! PR fortran/98307 - Dependency check fails when using "allocatable" + +program forall_deps + implicit none + type t + logical :: valid =3D .true. + integer :: s =3D 0 + integer, allocatable :: p(:) + end type + type(t) :: v(2) + integer :: i + + allocate (v(1)%p(8)) + allocate (v(2)%p(8)) + v(1)%s =3D 8 + v(2)%s =3D 6 + + v(1)%p(:) =3D [1, 2, 3, 4, 5, 6, 7, 8] + v(2)%p(:) =3D [13, 14, 15, 16, 17, 18, 19, 20] + forall (i=3D1:2) + v(i)%p(1:v(i)%s) =3D v(3-i)%p(1:v(i)%s) + end forall + if (any(v(2)%p(:) /=3D [1, 2, 3, 4, 5, 6, 19, 20])) stop 1 + + v(1)%p(:) =3D [1, 2, 3, 4, 5, 6, 7, 8] + v(2)%p(:) =3D [13, 14, 15, 16, 17, 18, 19, 20] + forall (i=3D1:2, v(i)%valid) + v(i)%p(1:v(i)%s) =3D v(3-i)%p(1:v(i)%s) + end forall + if (any(v(2)%p(:) /=3D [1, 2, 3, 4, 5, 6, 19, 20])) stop 2 +end --trekuen-5ef68f4d-1732-46f0-8c4b-335d3255cf19--