PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / proc_ptr_7.f90
blob9ac6cbe21fec4a0a559b9d84182a93208a7b314d
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) STOP 1
25 ptr => f55
26 if(ptr() /= 55) STOP 2
28 call foo(ptr)
29 if(ptr() /= 65) STOP 3
31 contains
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
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