diff options
Diffstat (limited to 'gcc/testsuite/gfortran.dg/proc_ptr_6.f90')
-rw-r--r-- | gcc/testsuite/gfortran.dg/proc_ptr_6.f90 | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_6.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_6.f90 new file mode 100644 index 000000000..6a5c7e5f4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_6.f90 @@ -0,0 +1,39 @@ +! { dg-do run } +! +! PROCEDURE POINTERS as actual/formal arguments +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +subroutine foo(j) + INTEGER, INTENT(OUT) :: j + j = 6 +end subroutine + +program proc_ptr_6 + +PROCEDURE(),POINTER :: ptr1 +PROCEDURE(REAL),POINTER :: ptr2 +EXTERNAL foo +INTEGER :: k = 0 + +ptr1 => foo +call s_in(ptr1,k) +if (k /= 6) call abort() + +call s_out(ptr2) +if (ptr2(-3.0) /= 3.0) call abort() + +contains + +subroutine s_in(p,i) + PROCEDURE(),POINTER,INTENT(IN) :: p + INTEGER, INTENT(OUT) :: i + call p(i) +end subroutine + +subroutine s_out(p) + PROCEDURE(REAL),POINTER,INTENT(OUT) :: p + p => abs +end subroutine + +end program |