summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/submodule_30.f08
blob: 25dcbebe6567858611e247dd067863ee2d0505db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
! { dg-do run }
!
! Test the fix for PR82550 in which the reference to 'p' in 'foo'
! was not being correctly handled.
!
! Contributed by Reinhold Bader  <Bader@lrz.de>
!
module m_subm_18_pos
  implicit none
  integer :: i = 0
  interface
    module subroutine foo(fun_ptr)
      procedure(p), pointer, intent(out) :: fun_ptr
    end subroutine
  end interface
contains
  subroutine p()
    i = 1
  end subroutine p
end module m_subm_18_pos
submodule (m_subm_18_pos) subm_18_pos
    implicit none
contains
    module subroutine foo(fun_ptr)
      procedure(p), pointer, intent(out) :: fun_ptr
      fun_ptr => p
    end subroutine
end submodule
program p_18_pos
  use m_subm_18_pos
  implicit none
  procedure(), pointer :: x
  call foo(x)
  call x()
  if (i == 1) then
     write(*,*) 'OK'
  else
     write(*,*) 'FAIL'
     call abort
  end if
end program p_18_pos