fix pr/45972
[official-gcc.git] / gcc / testsuite / gfortran.dg / func_derived_1.f90
blob2cf8e449c7e66ebea6a32baacad293056035d6fa
1 ! { dg-do run }
2 ! { dg-options "-std=legacy" }
4 ! PR 17244
5 ! verifies that functions returning derived type work
6 module m
7 type t
8 integer i
9 real x
10 character*5 c
11 integer arr(5,5)
12 end type t
13 end module m
15 use m
16 type(t) :: r
17 integer arr(5,5), vect(25), vect2(25)
18 do i=1,25
19 vect = 0
20 vect(i) = i
21 arr = reshape (vect, shape(arr))
22 r = f(i,real(i),"HALLO",arr)
24 if (r%i .ne. i) call abort()
25 if (r%x .ne. real(i)) call abort()
26 if (r%c .ne. "HALLO") call abort()
27 vect2 = reshape (r%arr, shape(vect2))
28 if (any(vect2.ne.vect)) call abort()
29 end do
30 contains
32 function f(i,x,c,arr)
33 type(t) :: f
34 character*5 c
35 integer arr(5,5)
37 f = t(i,x,c,arr)
38 end function f
40 end
42 ! { dg-final { cleanup-modules "m" } }