OSDN Git Service

PR debug/43329
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / whole_file_9.f90
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.
5 !
6 ! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr>
7 !
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/))
20
21 end program test
22
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