PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / stfunc_6.f90
blob8fa7eb8622266f0a54de61de4d515047c586cc1d
1 ! { dg-do compile }
2 ! { dg-options "-std=legacy" }
4 ! Tests the fix for the second bit of PR29389, in which the
5 ! statement function would not be recognised as not PURE
6 ! when it referenced a procedure that is not PURE.
8 ! This is based on stfunc_4.f90 with the statement function made
9 ! impure by a reference to 'v'.
11 ! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
13 INTEGER :: st1, i = 99, a(4), q = 6
14 st1 (i) = i * i * i
15 st3 (i) = i * v(i)
16 FORALL(i=1:4) a(i) = st1 (i)
17 FORALL(i=1:4) a(i) = u (a(i)) - a(i)** 2
18 if (any (a .ne. 0)) STOP 1
19 if (i .ne. 99) STOP 2
20 FORALL (i=1:4) a(i) = st3 (i) ! { dg-error "impure function" "impure reference in FORALL" { xfail *-*-*} }
21 FORALL (i=1:4) a(i) = v(i) ! { dg-error "impure function" }
22 contains
23 pure integer function u (x)
24 integer,intent(in) :: x
25 st2 (i) = i * v(i) ! { dg-error "impure function" }
26 u = st2(x)
27 end function
28 integer function v (x)
29 integer,intent(in) :: x
30 v = i
31 end function
32 end