Debian Codegraph @

gcc/testsuite/gfortran.dg/spec_expr_7.f90

raw
1 ! { dg-do run }
2 !
3 ! PR 60777: [F03] RECURSIVE function rejected in specification expression
4 !
5 ! Contributed by Vladimir Fuka <[email protected]>
6
7 module recur
8 implicit none
9 contains
10
11 pure recursive function f(n) result(answer)
12 integer, intent(in) :: n
13 integer :: answer
14 if (n<2) then
15 answer = 1
16 else
17 answer = f(n-1)*n
18 end if
19 end function
20
21 pure function usef(n)
22 integer,intent(in) :: n
23 character(f(n)) :: usef
24 usef = repeat('*',f(n))
25 end function
26 end module
27
28 program testspecexpr
29 use recur
30 implicit none
31 if (usef(1) /= '*') STOP 1
32 if (usef(2) /= '**') STOP 2
33 if (usef(3) /= '******') STOP 3
34 end