1! { dg-do run }
2! Test alternate entry points in a module procedure
3! Also check that references to sibling entry points are resolved correctly.
4module m
5contains
6subroutine indirecta (p)
7  call p (3, 4)
8end subroutine
9subroutine indirectb (p)
10  call p (5)
11end subroutine
12
13subroutine test1
14  implicit none
15  call indirecta (foo)
16  call indirectb (bar)
17end subroutine
18
19subroutine foo(a, b)
20  integer a, b
21  logical, save :: was_foo = .false.
22  if ((a .ne. 3) .or. (b .ne. 4)) call abort
23  was_foo = .true.
24entry bar(a)
25  if (was_foo) then
26    if ((a .ne. 3) .or. (b .ne. 4)) call abort
27  else
28    if (a .ne. 5) call abort
29  end if
30  was_foo = .false.
31end subroutine
32
33subroutine test2
34  call foo (3, 4)
35  call bar (5)
36end subroutine
37end module
38
39program p
40  use m
41  call foo (3, 4)
42  call bar (5)
43  call test1 ()
44  call test2 ()
45end program
46