From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- gcc/testsuite/gfortran.dg/pointer_intent_1.f90 | 77 ++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pointer_intent_1.f90 (limited to 'gcc/testsuite/gfortran.dg/pointer_intent_1.f90') diff --git a/gcc/testsuite/gfortran.dg/pointer_intent_1.f90 b/gcc/testsuite/gfortran.dg/pointer_intent_1.f90 new file mode 100644 index 000000000..1bdab241c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_intent_1.f90 @@ -0,0 +1,77 @@ +! { dg-do run } +! { dg-options "-std=f2003 -fall-intrinsics" } +! Pointer intent test +! PR fortran/29624 +! +! Valid program +program test + implicit none + type myT + integer :: x + integer, pointer :: point + end type myT + integer, pointer :: p + type(myT), pointer :: t + type(myT) :: t2 + allocate(p,t) + allocate(t%point) + t%point = 55 + p = 33 + call a(p,t) + deallocate(p) + nullify(p) + call a(p,t) + t2%x = 5 + allocate(t2%point) + t2%point = 42 + call nonpointer(t2) + if(t2%point /= 7) call abort() +contains + subroutine a(p,t) + integer, pointer,intent(in) :: p + type(myT), pointer, intent(in) :: t + integer, pointer :: tmp + if(.not.associated(p)) return + if(p /= 33) call abort() + p = 7 + if (associated(t)) then + ! allocating is valid as we don't change the status + ! of the pointer "t", only of it's target + t%x = -15 + if(.not.associated(t%point)) call abort() + if(t%point /= 55) call abort() + nullify(t%point) + allocate(tmp) + t%point => tmp + deallocate(t%point) + t%point => null(t%point) + tmp => null(tmp) + allocate(t%point) + t%point = 27 + if(t%point /= 27) call abort() + if(t%x /= -15) call abort() + call foo(t) + if(t%x /= 32) call abort() + if(t%point /= -98) call abort() + end if + call b(p) + if(p /= 5) call abort() + end subroutine + subroutine b(v) + integer, intent(out) :: v + v = 5 + end subroutine b + subroutine foo(comp) + type(myT), intent(inout) :: comp + if(comp%x /= -15) call abort() + if(comp%point /= 27) call abort() + comp%x = 32 + comp%point = -98 + end subroutine foo + subroutine nonpointer(t) + type(myT), intent(in) :: t + if(t%x /= 5 ) call abort() + if(t%point /= 42) call abort() + t%point = 7 + end subroutine nonpointer +end program -- cgit v1.2.3