2 ! Tests the patch for PR27613, in which directly recursive, scalar
3 ! functions were generating an "unclassifiable statement" error
4 ! for the recursive statement(s). This was subsequently determined
5 ! to be wrong code and the error on 'bad_stuff' was removed.
6 ! See 12.5.2.1 of the standard and PR30876.
8 ! Based on PR testcase by Nicolas Bock <nicolasbock@gmail.com>
11 if (original_stuff(1) .ne
. 5) call abort ()
12 if (scalar_stuff(-4) .ne
. 10) call abort ()
13 if (any (array_stuff((/-19,-30/)) .ne
. (/25,25/))) call abort ()
15 recursive function original_stuff(n
)
16 integer :: original_stuff
20 original_stuff
= original_stuff
+ original_stuff (n
+1) ! { dg-error "name of a recursive function" }
22 end function original_stuff
24 recursive function scalar_stuff(n
) result (tmp
)
29 tmp
= tmp
+ scalar_stuff (n
+1)
31 end function scalar_stuff
33 recursive function array_stuff(n
) result (tmp
)
37 if(maxval (n
) < 5) then
38 tmp
= tmp
+ array_stuff (n
+1)
40 end function array_stuff
42 recursive function bad_stuff(n
)
43 integer :: bad_stuff (2)
46 if(maxval (n
) < 5) then
47 bad_stuff
= bad_stuff
+ bad_stuff (n
+1)
49 end function bad_stuff