Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gfortran.dg / pr19928-2.f90
blob6bfdd0f30b27eff710c5475309276cf2fe3b887d
1 ! Related to PR 19928. Check that foo() is only called once per statement.
2 ! { dg-do run }
3 program main
4 implicit none
5 type t
6 integer, dimension (5) :: field
7 end type t
8 type (t), dimension (2) :: a
9 integer :: calls, i, j
11 forall (i = 1:2, j = 1:5) a(i)%field(j) = i * 100 + j
12 calls = 0
13 if (sum (a%field(foo(calls))) .ne. 304) call abort
14 if (calls .ne. 1) call abort
15 if (sum (a(foo(calls))%field) .ne. 1015) call abort
16 if (calls .ne. 2) call abort
17 contains
18 function foo (calls)
19 integer :: calls, foo
20 calls = calls + 1
21 foo = 2
22 end function foo
23 end program main