1! { dg-do run } 2! { dg-additional-sources proc_ptr_7.c } 3! 4! PR fortran/32580 5! Procedure pointer test 6! 7! Contributed by Tobias Burnus <burnus@gcc.gnu.org> 8 9program proc_pointer_test 10 use iso_c_binding, only: c_int 11 implicit none 12 13 interface 14 subroutine assignF(f) 15 import c_int 16 procedure(Integer(c_int)), pointer :: f 17 end subroutine 18 end interface 19 20 procedure(Integer(c_int)), pointer :: ptr 21 22 call assignF(ptr) 23 if(ptr() /= 42) STOP 1 24 25 ptr => f55 26 if(ptr() /= 55) STOP 2 27 28 call foo(ptr) 29 if(ptr() /= 65) STOP 3 30 31contains 32 33 subroutine foo(a) 34 procedure(integer(c_int)), pointer :: a 35 if(a() /= 55) STOP 4 36 a => f65 37 if(a() /= 65) STOP 5 38 end subroutine foo 39 40 integer(c_int) function f55() 41 f55 = 55 42 end function f55 43 44 integer(c_int) function f65() 45 f65 = 65 46 end function f65 47end program proc_pointer_test 48