annotate gcc/testsuite/gfortran.dg/array_alloc_2.f90 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! Like array_alloc_1.f90, but check cases in which the array length is
kono
parents:
diff changeset
2 ! not a literal constant.
kono
parents:
diff changeset
3 ! { dg-do run }
kono
parents:
diff changeset
4 program main
kono
parents:
diff changeset
5 implicit none
kono
parents:
diff changeset
6 integer, parameter :: n = 100
kono
parents:
diff changeset
7 call test (n, f1 ())
kono
parents:
diff changeset
8 call test (47, f2 (50))
kono
parents:
diff changeset
9 call test (n, f3 (f1 ()))
kono
parents:
diff changeset
10 contains
kono
parents:
diff changeset
11 subroutine test (expected, x)
kono
parents:
diff changeset
12 integer, dimension (:) :: x
kono
parents:
diff changeset
13 integer :: i, expected
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
14 if (size (x, 1) .ne. expected) STOP 1
111
kono
parents:
diff changeset
15 do i = 1, expected
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
16 if (x (i) .ne. i * 100) STOP 2
111
kono
parents:
diff changeset
17 end do
kono
parents:
diff changeset
18 end subroutine test
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 function f1 ()
kono
parents:
diff changeset
21 integer, dimension (n) :: f1
kono
parents:
diff changeset
22 integer :: i
kono
parents:
diff changeset
23 forall (i = 1:n) f1 (i) = i * 100
kono
parents:
diff changeset
24 end function f1
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 function f2 (howmuch)
kono
parents:
diff changeset
27 integer :: i, howmuch
kono
parents:
diff changeset
28 integer, dimension (4:howmuch) :: f2
kono
parents:
diff changeset
29 forall (i = 4:howmuch) f2 (i) = i * 100 - 300
kono
parents:
diff changeset
30 end function f2
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 function f3 (x)
kono
parents:
diff changeset
33 integer, dimension (:) :: x
kono
parents:
diff changeset
34 integer, dimension (size (x, 1)) :: f3
kono
parents:
diff changeset
35 integer :: i
kono
parents:
diff changeset
36 forall (i = 1:size(x)) f3 (i) = i * 100
kono
parents:
diff changeset
37 end function f3
kono
parents:
diff changeset
38 end program main