summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/proc_ptr_comp_2.f90
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/proc_ptr_comp_2.f90
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.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_comp_2.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/proc_ptr_comp_2.f9058
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_comp_2.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_comp_2.f90
new file mode 100644
index 000000000..33e32aaf6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/proc_ptr_comp_2.f90
@@ -0,0 +1,58 @@
+! { dg-do run }
+!
+! PR39630: Fortran 2003: Procedure pointer components.
+!
+! Basic test for PPCs with FUNCTION interface and NOPASS.
+!
+! Contributed by Janus Weil <janus@gcc.gnu.org>
+
+ type t
+ procedure(fcn), pointer, nopass :: ppc
+ procedure(abstr), pointer, nopass :: ppc1
+ integer :: i
+ end type
+
+ abstract interface
+ integer function abstr(x)
+ integer, intent(in) :: x
+ end function
+ end interface
+
+ type(t) :: obj
+ procedure(fcn), pointer :: f
+ integer :: base
+
+ intrinsic :: iabs
+
+! Check with interface from contained function
+ obj%ppc => fcn
+ base=obj%ppc(2)
+ if (base/=4) call abort
+ call foo (obj%ppc,3)
+
+! Check with abstract interface
+ obj%ppc1 => obj%ppc
+ base=obj%ppc1(4)
+ if (base/=8) call abort
+ call foo (obj%ppc1,5)
+
+! Check compatibility components with non-components
+ f => obj%ppc
+ base=f(6)
+ if (base/=12) call abort
+ call foo (f,7)
+
+contains
+
+ integer function fcn(x)
+ integer, intent(in) :: x
+ fcn = 2 * x
+ end function
+
+ subroutine foo (arg, i)
+ procedure (fcn), pointer :: arg
+ integer :: i
+ if (arg(i)/=2*i) call abort
+ end subroutine
+
+end