Daily bump.
[official-gcc.git] / gcc / testsuite / gfortran.dg / reshape.f90
blob3dba09892b68c95de36dbec30a17c0dd9909e996
1 ! { dg-do run }
2 ! This tests a few reshape PRs.
3 program resh
4 implicit none
5 real, dimension (2,3) :: a,c
6 real, dimension (12) :: b
7 type foo
8 real :: r
9 end type foo
10 type(foo), dimension (2,3) :: ar
11 type(foo), dimension (12) :: br
13 character (len=80) line1, line2, line3
14 integer :: i
16 ! PR 21108: This used to give undefined results.
17 b = (/(i,i=1,12)/)
18 a = reshape(b(1:12:2),shape(a),order=(/2,1/))
19 c = reshape(b(1:12:2),shape(a),order=(/2,1/))
20 if (any (a /= c)) call abort
22 ! Test generic reshape
23 br%r = b
24 ar = reshape(br(1:12:2),shape(a),order=(/2,1/))
25 if (any (ar%r /= a)) call abort
27 ! Test callee-allocated memory with a write statement
28 write (line1,'(6F8.3)') reshape(b(1:12:2),shape(a),order=(/2,1/))
29 write (line2,'(6F8.3)') a
30 if (line1 /= line2 ) call abort
31 write (line3,'(6F8.3)') reshape(br(1:12:2),shape(ar),order=(/2,1/))
32 if (line1 /= line3 ) call abort
33 end