| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Tests the fix for PR79676 in which submod_test was private even to the |
| 4 |
! submodule 'my_submod'. |
| 5 |
! |
| 6 |
! Contributed by Adam Hirst <[email protected]> |
| 7 |
! |
| 8 |
module my_mod |
| 9 |
private ! This hid 'submod_test'. |
| 10 |
interface |
| 11 |
module subroutine submod_test(x) |
| 12 |
integer :: x |
| 13 |
end subroutine |
| 14 |
end interface |
| 15 |
integer answer |
| 16 |
public routine1, print_two, answer |
| 17 |
contains |
| 18 |
subroutine routine1(x) |
| 19 |
integer :: x |
| 20 |
call submod_test(x) |
| 21 |
end subroutine |
| 22 |
subroutine print_two() |
| 23 |
integer, parameter :: two = 2 |
| 24 |
answer = answer * two |
| 25 |
end subroutine |
| 26 |
end module |
| 27 |
|
| 28 |
module my_mod_2 |
| 29 |
use my_mod |
| 30 |
contains |
| 31 |
subroutine circular_dependency() |
| 32 |
call print_two() |
| 33 |
end subroutine |
| 34 |
end module |
| 35 |
|
| 36 |
submodule (my_mod) my_submod |
| 37 |
use my_mod_2 |
| 38 |
contains |
| 39 |
module subroutine submod_test(x) |
| 40 |
integer :: x |
| 41 |
answer = x |
| 42 |
call circular_dependency() |
| 43 |
end subroutine |
| 44 |
|
| 45 |
end submodule |
| 46 |
|
| 47 |
program hello |
| 48 |
use my_mod |
| 49 |
implicit none |
| 50 |
call routine1(2) |
| 51 |
if (answer .ne. 4) STOP 1 |
| 52 |
end program |