Debian Codegraph @

gcc/testsuite/gfortran.dg/submodule_11.f08

raw
1 ! { dg-do run }
2 ! Test the fix for PR66993, in which the use associated version of 'i'
3 ! was incorrectly determined to be ambiguous with the 'i', host associated
4 ! in submodule 'sm' from the module 'm'. The principle has been tested with
5 ! the function 'time_two' in addition.
6 !
7 ! Contributed by Mikael Morin <[email protected]>
8 !
9 module m
10 integer, parameter :: i = -1
11 interface
12 module subroutine show_i
13 end subroutine show_i
14 end interface
15 contains
16 integer function times_two (arg)
17 integer :: arg
18 times_two = -2*arg
19 end function
20 end module m
21
22 module n
23 integer, parameter :: i = 2
24 contains
25 integer function times_two (arg)
26 integer :: arg
27 times_two = 2*arg
28 end function
29 end module n
30
31 submodule (m) sm
32 use n
33 contains
34 module subroutine show_i
35 if (i .ne. 2) STOP 1
36 if (times_two (i) .ne. 4) STOP 2
37 end subroutine show_i
38 end submodule sm
39
40 program p
41 use m
42 call show_i
43 if (i .ne. -1) STOP 3
44 if (times_two (i) .ne. 2) STOP 4
45 end program