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 <sfilippone@uniroma2.it>
9! Reduced by Janus Weil <janus@gcc.gnu.org>
10
11module mod1
12  type :: t1
13  contains
14    procedure, nopass :: get => my_get
15  end type
16contains
17  subroutine my_get(i)
18    i = 2
19  end subroutine
20end module
21
22module mod2
23contains
24  subroutine my_get(i)    ! must have the same name as the function in mod1
25    i = 5
26  end subroutine
27end module
28
29
30 call test1()
31 call test2()
32
33contains
34
35 subroutine test1()
36  use mod2
37  use mod1
38  type(t1) :: a
39  call a%get(j)
40  if (j /= 2) call abort
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) call abort
49 end subroutine test2
50end
51
52
53
54