PR ipa/83051
[official-gcc.git] / gcc / testsuite / gfortran.dg / ret_pointer_2.f90
blob939411b7bc22c2dcae617e2e499d0d1a494c1ff3
1 ! { dg-do run }
2 ! PR 25806: Functions returning pointers to arrays
3 program a
4 integer, target :: storage(5)
5 integer :: s(3)
8 print *, x(3) ! { dg-output " *1 *2 *3" }
10 if (ssum(x(3)) /= 6) call abort()
12 s = 0
13 s = x(3)
14 if (any(s /= (/1, 2, 3/))) call abort()
16 contains
18 function x(n) result(t)
19 integer, intent(in) :: n
20 integer, pointer :: t(:)
21 integer :: i
23 t => storage(1:n)
24 t = (/ (i, i = 1, n) /)
26 end function x
29 integer function ssum(a)
30 integer, intent(in) :: a(:)
32 ssum = sum(a)
34 end function ssum
36 end program a