OSDN Git Service

2011-01-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.fortran-torture / execute / stack_varsize.f90
1 ! Program to test the stack variable size limit.
2 program stack
3    call sub1
4    call sub2 (1)
5 contains
6
7    ! Local variables larger than 32768 in byte size shall be placed in static
8    ! storage area, while others be put on stack by default.
9    subroutine sub1
10       real a, b(32768/4), c(32768/4+1) 
11       integer m, n(1024,4), k(1024,1024)
12       a = 10.0
13       b = 20.0
14       c = 30.0
15       m = 10
16       n = 20
17       k = 30
18       if ((a .ne. 10.0).or.(b(1) .ne. 20.0).or.(c(1) .ne. 30.0)) call abort
19       if ((m .ne. 10).or.(n(256,4) .ne. 20).or.(k(1,1024) .ne. 30)) call abort
20    end subroutine
21
22    ! Local variables defined in recursive subroutine are always put on stack.
23    recursive subroutine sub2 (n)
24       real a (32769)
25       a (1) = 42
26       if (n .ge. 1) call sub2 (n-1)
27       if (a(1) .ne. 42) call abort
28       a (1) = 0
29    end subroutine
30 end