2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / recursive_statement_functions.f90
blobbcf51f8d5e99c2d473e32acaa222026a50f2d9be
1 ! { dg-do compile }
2 ! { dg-options "-std=legacy" }
4 ! PR20866 - A statement function cannot be recursive.
5 ! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
7 ! Modified 20051110 to check that regressions PR24655 and PR24755
8 ! are fixed. Thanks to pavarini@pv.infn.it and tdeutsch@cea.fr for
9 ! the tests.
11 INTEGER :: i, st1, st2, st3, lambda, n
12 REAL :: x, z(2,2)
13 character(8) :: ch
14 real(8) :: fi, arg, sigma, dshpfunc
15 real(8), parameter :: one=1d0
17 ! Test check for recursion via other statement functions, string
18 ! length references, function actual arguments and array index
19 ! references.
21 st1 (i) = len (ch(st2 (1):8))
22 st2 (i) = max (st3 (1), 4)
23 st3 (i) = 2 + cos (z(st1 (1), i)) ! { dg-error "is recursive" }
25 ! Test the two regressions.
27 fi (n) = n *one
28 dshpfunc (arg)=-lambda/sigma*(arg/sigma)**(lambda-1)*exp(-(arg/sigma)**lambda)
30 ! References to each statement function.
32 write(6,*) st1 (1), fi (2), dshpfunc (1.0_8)
33 END