fix pr/45972
[official-gcc.git] / gcc / testsuite / gfortran.dg / proc_ptr_7.f90
blob8b1ea0a44b38137a31c1ed51f980d9bb98bd18a4
1 ! { dg-do run }
2 ! { dg-additional-sources proc_ptr_7.c }
4 ! PR fortran/32580
5 ! Procedure pointer test
7 ! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
9 program proc_pointer_test
10 use iso_c_binding, only: c_int
11 implicit none
13 interface
14 subroutine assignF(f)
15 import c_int
16 procedure(Integer(c_int)), pointer :: f
17 end subroutine
18 end interface
20 procedure(Integer(c_int)), pointer :: ptr
22 call assignF(ptr)
23 if(ptr() /= 42) call abort()
25 ptr => f55
26 if(ptr() /= 55) call abort()
28 call foo(ptr)
29 if(ptr() /= 65) call abort()
31 contains
33 subroutine foo(a)
34 procedure(integer(c_int)), pointer :: a
35 if(a() /= 55) call abort()
36 a => f65
37 if(a() /= 65) call abort()
38 end subroutine foo
40 integer(c_int) function f55()
41 f55 = 55
42 end function f55
44 integer(c_int) function f65()
45 f65 = 65
46 end function f65
47 end program proc_pointer_test