From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2071) id E50A83854808; Wed, 23 Dec 2020 20:14:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E50A83854808 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Harald Anlauf To: gcc-cvs@gcc.gnu.org Subject: [gcc r8-10692] PR fortran/98307 - Dependency check fails when using "allocatable" X-Act-Checkin: gcc X-Git-Author: Harald Anlauf X-Git-Refname: refs/heads/releases/gcc-8 X-Git-Oldrev: edb28850520d1137d12a1cc1c0e89c11e6b0c6ef X-Git-Newrev: 75de7b2ace83028afa46bdb9a286d66ce1fa26b8 Message-Id: <20201223201451.E50A83854808@sourceware.org> Date: Wed, 23 Dec 2020 20:14:51 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Dec 2020 20:14:52 -0000 https://gcc.gnu.org/g:75de7b2ace83028afa46bdb9a286d66ce1fa26b8 commit r8-10692-g75de7b2ace83028afa46bdb9a286d66ce1fa26b8 Author: Harald Anlauf Date: Thu Dec 17 10:31:55 2020 +0100 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. (cherry picked from commit c09deceb534b82ce144af3a345dcb06ab5e49ba4) Diff: --- gcc/fortran/trans-stmt.c | 5 +++-- gcc/testsuite/gfortran.dg/forall_19.f90 | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index acc975b87b3..7a264391082 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -3535,9 +3535,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 == 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 = NULL; diff --git a/gcc/testsuite/gfortran.dg/forall_19.f90 b/gcc/testsuite/gfortran.dg/forall_19.f90 new file mode 100644 index 00000000000..ef05c97ab24 --- /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 = .true. + integer :: s = 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 = 8 + v(2)%s = 6 + + v(1)%p(:) = [1, 2, 3, 4, 5, 6, 7, 8] + v(2)%p(:) = [13, 14, 15, 16, 17, 18, 19, 20] + forall (i=1:2) + v(i)%p(1:v(i)%s) = v(3-i)%p(1:v(i)%s) + end forall + if (any(v(2)%p(:) /= [1, 2, 3, 4, 5, 6, 19, 20])) stop 1 + + v(1)%p(:) = [1, 2, 3, 4, 5, 6, 7, 8] + v(2)%p(:) = [13, 14, 15, 16, 17, 18, 19, 20] + forall (i=1:2, v(i)%valid) + v(i)%p(1:v(i)%s) = v(3-i)%p(1:v(i)%s) + end forall + if (any(v(2)%p(:) /= [1, 2, 3, 4, 5, 6, 19, 20])) stop 2 +end