Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gfortran.dg / whole_file_9.f90
blob64dce42ee2134dd3d0b4ce9a74e57e96d8ca4d78
1 ! { dg-do compile }
2 ! { dg-options "-fwhole-file" }
3 ! Test the fix for the fourth problem in PR40011, where the
4 ! entries were not resolved, resulting in a segfault.
6 ! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
8 program test
9 interface
10 function bad_stuff(n)
11 integer :: bad_stuff (2)
12 integer :: n(2)
13 end function bad_stuff
14 recursive function rec_stuff(n) result (tmp)
15 integer :: n(2), tmp(2)
16 end function rec_stuff
17 end interface
18 integer :: res(2)
19 res = bad_stuff((/-19,-30/))
21 end program test
23 recursive function bad_stuff(n)
24 integer :: bad_stuff (2)
25 integer :: n(2), tmp(2), ent = 0, sent = 0
26 save ent, sent
27 ent = -1
28 entry rec_stuff(n) result (tmp)
29 if (ent == -1) then
30 sent = ent
31 ent = 0
32 end if
33 ent = ent + 1
34 tmp = 1
35 if(maxval (n) < 5) then
36 tmp = tmp + rec_stuff (n+1)
37 ent = ent - 1
38 endif
39 if (ent == 1) then
40 if (sent == -1) then
41 bad_stuff = tmp + bad_stuff (1)
42 end if
43 ent = 0
44 sent = 0
45 end if
46 end function bad_stuff