OSDN Git Service

PR fortran/30964
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / auto_array_1.f90
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.
5
6 program p
7    implicit none
8    integer:: n,m
9
10    n = 3
11    call foo(n)
12 contains
13
14    subroutine foo(m)
15       integer:: m,i
16       integer:: z(m,m)
17     
18       z = 0
19
20       call foo1(m,z)
21     
22       ! Check it worked.
23       if (any (z .ne. reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/)))) &
24         call abort
25     end subroutine foo
26
27     subroutine foo1(n,x)
28        integer:: n,i,j
29        integer:: x(n,n)
30     
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