Debian Codegraph @

gcc/testsuite/gfortran.dg/use_24.f90

raw
1 ! { dg-do run }
2 !
3 ! PR fortran/42769
4 ! The static resolution of A%GET used to be incorrectly simplified to MOD2's
5 ! MY_GET instead of the original MOD1's MY_GET, depending on the order in which
6 ! MOD1 and MOD2 were use-associated.
7 !
8 ! Original testcase by Salvator Filippone <[email protected]>
9 ! Reduced by Janus Weil <[email protected]>
10
11 module mod1
12 type :: t1
13 contains
14 procedure, nopass :: get => my_get
15 end type
16 contains
17 subroutine my_get(i)
18 i = 2
19 end subroutine
20 end module
21
22 module mod2
23 contains
24 subroutine my_get(i) ! must have the same name as the function in mod1
25 i = 5
26 end subroutine
27 end module
28
29
30 call test1()
31 call test2()
32
33 contains
34
35 subroutine test1()
36 use mod2
37 use mod1
38 type(t1) :: a
39 call a%get(j)
40 if (j /= 2) STOP 1
41 end subroutine test1
42
43 subroutine test2()
44 use mod1
45 use mod2
46 type(t1) :: a
47 call a%get(j)
48 if (j /= 2) STOP 2
49 end subroutine test2
50 end
51
52
53