1! { dg-do link }
2! { dg-options "-fwhole-program -O3 -g" }
3!
4! PR fortran/40873
5!
6      program prog
7        call one()
8        call two()
9        call test()
10      end program prog
11      subroutine one()
12        call three()
13      end subroutine one
14      subroutine two()
15        call three()
16      end subroutine two
17      subroutine three()
18      end subroutine three
19
20SUBROUTINE c()
21 CALL a()
22END SUBROUTINE c
23
24SUBROUTINE a()
25END SUBROUTINE a
26
27MODULE M
28CONTAINS
29 SUBROUTINE b()
30   CALL c()
31 END SUBROUTINE
32END MODULE
33
34subroutine test()
35USE M
36CALL b()
37END
38