diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/alloc_comp_assign_2.f90 | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/alloc_comp_assign_2.f90')
-rw-r--r-- | gcc/testsuite/gfortran.dg/alloc_comp_assign_2.f90 | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_assign_2.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_assign_2.f90 new file mode 100644 index 000000000..32c3c82dc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/alloc_comp_assign_2.f90 @@ -0,0 +1,51 @@ +! { dg-do run } +! Test FORALL and WHERE with derived types with allocatable components (PR 20541). +! +! Contributed by Erik Edelmann <eedelmann@gcc.gnu.org> +! and Paul Thomas <pault@gcc.gnu.org> +! + type :: a + integer, allocatable :: i(:) + end type a + + type :: b + type (a), allocatable :: at(:) + end type b + + type(a) :: x(2) + type(b) :: y(2), z(2) + integer i, m(4) + +! Start with scalar and array element assignments in FORALL. + + x(1) = a ((/1, 2, 3, 4/)) + x(2) = a ((/1, 2, 3, 4/) + 10) + forall (j = 1:2, i = 1:4, x(j)%i(i) > 2 + (j-1)*10) x(j)%i(i) = j*4-i + if (any ((/((x(i)%i(j), j = 1,4), i = 1,2)/) .ne. & + (/1, 2, 1, 0, 11, 12, 5, 4/))) call abort () + + y(1) = b ((/x(1),x(2)/)) + y(2) = b ((/x(2),x(1)/)) + forall (k = 1:2, j=1:2, i = 1:4, y(k)%at(j)%i(i) <= 10) + y(k)%at(j)%i(i) = j*4-i+k + end forall + if (any ((/(((y(k)%at(i)%i(j), j = 1,4), i = 1,2), k = 1,2)/) .ne. & + (/4,3,2,1,11,12,6,5,11,12,3,2,9,8,7,6/))) call abort () + +! Now simple assignments in WHERE. + + where (y(1)%at(1)%i > 2) y(1)%at(1)%i = 0 + if (any( (/(((y(k)%at(i)%i(j), j = 1,4), i = 1,2), k = 1,2)/) .ne. & + (/0,0,2,1,11,12,6,5,11,12,3,2,9,8,7,6/))) call abort () + +! Check that temporaries and full array alloctable component assignments +! are correctly handled in FORALL. + + x = (/a ((/1,2,3,4/)),a ((/5,6,7,8/))/) + forall (i=1:2) y(i) = b ((/x(i)/)) + forall (i=1:2) y(i) = y(3-i) ! This needs a temporary. + forall (i=1:2) z(i) = y(i) + if (any ((/(((z(k)%at(i)%i(j), j = 1,4), i = 1,1), k = 1,2)/) .ne. & + (/(/5,6,7,8/),(/1,2,3,4/)/))) call abort () + +end |