PR ipa/83051
[official-gcc.git] / gcc / testsuite / gfortran.dg / proc_ptr_6.f90
blob6a5c7e5f462505f444d48e930037945d0956f524
1 ! { dg-do run }
3 ! PROCEDURE POINTERS as actual/formal arguments
5 ! Contributed by Janus Weil <janus@gcc.gnu.org>
7 subroutine foo(j)
8 INTEGER, INTENT(OUT) :: j
9 j = 6
10 end subroutine
12 program proc_ptr_6
14 PROCEDURE(),POINTER :: ptr1
15 PROCEDURE(REAL),POINTER :: ptr2
16 EXTERNAL foo
17 INTEGER :: k = 0
19 ptr1 => foo
20 call s_in(ptr1,k)
21 if (k /= 6) call abort()
23 call s_out(ptr2)
24 if (ptr2(-3.0) /= 3.0) call abort()
26 contains
28 subroutine s_in(p,i)
29 PROCEDURE(),POINTER,INTENT(IN) :: p
30 INTEGER, INTENT(OUT) :: i
31 call p(i)
32 end subroutine
34 subroutine s_out(p)
35 PROCEDURE(REAL),POINTER,INTENT(OUT) :: p
36 p => abs
37 end subroutine
39 end program