diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/proc_ptr_1.f90 | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/proc_ptr_1.f90')
-rw-r--r-- | gcc/testsuite/gfortran.dg/proc_ptr_1.f90 | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_1.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_1.f90 new file mode 100644 index 000000000..fe8e20100 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_ptr_1.f90 @@ -0,0 +1,73 @@ +! { dg-do run } +! +! basic tests of PROCEDURE POINTERS +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +module m +contains + subroutine proc1(arg) + character (5) :: arg + arg = "proc1" + end subroutine + integer function proc2(arg) + integer, intent(in) :: arg + proc2 = arg**2 + end function + complex function proc3(re, im) + real, intent(in) :: re, im + proc3 = complex (re, im) + end function +end module + +subroutine foo1 +end subroutine + +real function foo2() + foo2=6.3 +end function + +program procPtrTest + use m, only: proc1, proc2, proc3 + character (5) :: str + PROCEDURE(proc1), POINTER :: ptr1 + PROCEDURE(proc2), POINTER :: ptr2 + PROCEDURE(proc3), POINTER :: ptr3 => NULL() + PROCEDURE(REAL), SAVE, POINTER :: ptr4 + PROCEDURE(), POINTER :: ptr5,ptr6 + + EXTERNAL :: foo1,foo2 + real :: foo2 + + if(ASSOCIATED(ptr3)) call abort() + + NULLIFY(ptr1) + if (ASSOCIATED(ptr1)) call abort() + ptr1 => proc1 + if (.not. ASSOCIATED(ptr1)) call abort() + call ptr1 (str) + if (str .ne. "proc1") call abort () + + ptr2 => NULL() + if (ASSOCIATED(ptr2)) call abort() + ptr2 => proc2 + if (.not. ASSOCIATED(ptr2,proc2)) call abort() + if (10*ptr2 (10) .ne. 1000) call abort () + + ptr3 => NULL (ptr3) + if (ASSOCIATED(ptr3)) call abort() + ptr3 => proc3 + if (ptr3 (1.0, 2.0) .ne. (1.0, 2.0)) call abort () + + ptr4 => cos + if (ptr4(0.0)/=1.0) call abort() + + ptr5 => foo1 + call ptr5() + + ptr6 => foo2 + if (ptr6()/=6.3) call abort() + +end program + +! { dg-final { cleanup-modules "m" } } |