2007-11-27 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / stfunc_6.f90
blob2ad791d3bbf100aa3f5a475c9dcb68c953b1f4da
1 ! { dg-do compile }
2 ! Tests the fix for the second bit of PR29389, in which the
3 ! statement function would not be recognised as not PURE
4 ! when it referenced a procedure that is not PURE.
6 ! This is based on stfunc_4.f90 with the statement function made
7 ! impure by a reference to 'v'.
9 ! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
11 INTEGER :: st1, i = 99, a(4), q = 6
12 st1 (i) = i * i * i
13 FORALL(i=1:4) a(i) = st1 (i)
14 FORALL(i=1:4) a(i) = u (a(i)) - a(i)** 2
15 if (any (a .ne. 0)) call abort ()
16 if (i .ne. 99) call abort ()
17 contains
18 pure integer function u (x)
19 integer,intent(in) :: x
20 st2 (i) = i * v(i) ! { dg-error "non-PURE procedure" }
21 u = st2(x)
22 end function
23 integer function v (x)
24 integer,intent(in) :: x
25 v = i
26 end function
27 end