OSDN Git Service

ChangeLogs fixed, again.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / stfunc_6.f90
1 ! { dg-do compile }
2 ! { dg-options "-std=legacy" }
3 !
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.
7 !
8 ! This is based on stfunc_4.f90 with the statement function made
9 ! impure by a reference to 'v'.
10 !
11 ! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
12
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)) call abort ()
19   if (i .ne. 99) call abort ()
20   FORALL (i=1:4) a(i) = st3 (i) ! { dg-error "non-PURE function" "non-PURE reference in FORALL" { xfail *-*-*} }
21   FORALL (i=1:4) a(i) = v(i) ! { dg-error "non-PURE function" }
22 contains
23   pure integer function u (x)
24     integer,intent(in) :: x
25     st2 (i) = i * v(i) ! { dg-error "non-PURE procedure" }
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