aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/submodule_28.f08
blob: c07ea4580aa7fe2b9f21c1f2097723809fa673a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
! { dg-do run }
!
! Tests the fix for PR79676 in which submod_test was private even to the
! submodule 'my_submod'.
!
! Contributed by Adam Hirst  <adam@aphirst.karoo.co.uk>
!
module my_mod
  private           ! This hid 'submod_test'.
  interface
    module subroutine submod_test(x)
      integer :: x
    end subroutine
  end interface
  integer answer
  public routine1, print_two, answer
contains
  subroutine routine1(x)
    integer :: x
    call submod_test(x)
  end subroutine
  subroutine print_two()
    integer, parameter :: two = 2
    answer = answer * two
  end subroutine
end module

module my_mod_2
  use my_mod
contains
  subroutine circular_dependency()
    call print_two()
  end subroutine
end module

submodule (my_mod) my_submod
  use my_mod_2
contains
module subroutine submod_test(x)
  integer :: x
  answer = x
  call circular_dependency()
end subroutine

end submodule

program hello
  use my_mod
  implicit none
  call routine1(2)
  if (answer .ne. 4) STOP 1
end program