Plugins: Add label-text.h to CPPLIB_H so it will be installed [PR115288]
[official-gcc.git] / gcc / testsuite / gfortran.dg / reshape.f90
blobde9d6c67961cfded237089bff9cb777f022095b0
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)) STOP 1
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)) STOP 2
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 ) STOP 3
31 write (line3,'(6F8.3)') reshape(br(1:12:2),shape(ar),order=(/2,1/))
32 if (line1 /= line3 ) STOP 4
33 end