c: Fix up pointer types to may_alias structures [PR114493]
[official-gcc.git] / gcc / testsuite / gfortran.dg / auto_array_1.f90
blobe33e2ced51ae3349fd198cd0d568f10b52a50a95
1 ! { dg-do run }
2 ! PR fortran/17077.
3 ! Automatic arrays are allocated on the heap. When used as an actual argument
4 ! we were passing the address of the pointer, not the pointer itself.
6 program p
7 implicit none
8 integer:: n,m
10 n = 3
11 call foo(n)
12 contains
14 subroutine foo(m)
15 integer:: m,i
16 integer:: z(m,m)
18 z = 0
20 call foo1(m,z)
22 ! Check it worked.
23 if (any (z .ne. reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/)))) &
24 STOP 1
25 end subroutine foo
27 subroutine foo1(n,x)
28 integer:: n,i,j
29 integer:: x(n,n)
31 ! Assign values to x.
32 do i=1,n
33 do j=1,n
34 x(j,i)=j+(i-1)*n
35 enddo
36 enddo
37 end subroutine foo1
38 end program