[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / gfortran.dg / submodule_28.f08
blobf7b10a6ed83b90a9f25336a05d424e71d8fb29bc
1 ! { dg-do run }
3 ! Tests the fix for PR79676 in which submod_test was private even to the
4 ! submodule 'my_submod'.
6 ! Contributed by Adam Hirst  <adam@aphirst.karoo.co.uk>
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
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
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
45 end submodule
47 program hello
48   use my_mod
49   implicit none
50   call routine1(2)
51   if (answer .ne. 4) call abort
52 end program