summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/pointer_check_4.f90
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-06 13:17:06 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-06 13:17:06 +0000
commit903a187914a19de9b6e5f34603c6f0553251a338 (patch)
tree6ba1a49474b7c3ae0e9ca2188aef521596b817da /gcc/testsuite/gfortran.dg/pointer_check_4.f90
parent506ce9fced0523910f9a486e75b3a4edfd5fea4f (diff)
downloadgcc-903a187914a19de9b6e5f34603c6f0553251a338.tar.gz
* SVN merge from the trunk
* Deleted no longer needed libgfortran/ChangeLog.dev Merged revisions 148767-148770,148774-148777,148779-148796,148798-148801,148804,148806, 148808-148811,148813-148817,148821,148823,148825-148828,148831, 148833-148852,148857,148861-148862,148868-148870,148872,148877,148880, 148883,148885,148888-148890,148892-148893,148895-148906,148909-148910, 148913-148917,148919,148925-148938,148941-148942,148946-148953,148955, 148958-148959,148961-148968,148971,148975-148984,148986-148987,148996, 148999,149002,149004-149014,149017-149018,149022-149023,149031-149038, 149043,149046-149048,149054,149057,149059-149060,149062-149070, 149073-149076,149078-149080,149082-149090,149093-149094,149098, 149100-149103,149108-149109,149112-149115,149117,149119-149121, 149126,149128,149135-149138,149140-149141,149144-149155,149157-149158, 149162-149167,149169-149171,149176,149178-149179,149182,149188,149190, 149195,149199,149204-149207,149209-149212,149216-149217,149222-149228, 149234-149236,149238-149239,149241-149243,149246-149247,149260,149262, 149268,149276-149277,149279 via svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/fortran-dev@149280 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gfortran.dg/pointer_check_4.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/pointer_check_4.f9086
1 files changed, 86 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/pointer_check_4.f90 b/gcc/testsuite/gfortran.dg/pointer_check_4.f90
new file mode 100644
index 00000000000..97eb6fad51e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pointer_check_4.f90
@@ -0,0 +1,86 @@
+! { dg-do run }
+! { dg-options "-fcheck=pointer" }
+! { dg-shouldfail "Unassociated/unallocated actual argument" }
+!
+! { dg-output ".*At line 66.*Proc-pointer actual argument 'pptr' is not associated" }
+!
+! PR fortran/40580
+!
+! Run-time check of passing deallocated/nonassociated actuals
+! to nonallocatable/nonpointer dummies.
+!
+! Check for variable actuals
+!
+
+subroutine test1(a)
+ integer :: a
+ a = 4444
+end subroutine test1
+
+subroutine test2(a)
+ integer :: a(2)
+ a = 4444
+end subroutine test2
+
+subroutine ppTest(f)
+ implicit none
+ external f
+ call f()
+end subroutine ppTest
+
+Program RunTimeCheck
+ implicit none
+ external :: test1, test2, ppTest
+ integer, pointer :: ptr1, ptr2(:)
+ integer, allocatable :: alloc2(:)
+ procedure(), pointer :: pptr
+
+ allocate(ptr1,ptr2(2),alloc2(2))
+ pptr => sub
+ ! OK
+ call test1(ptr1)
+ call test3(ptr1)
+
+ call test2(ptr2)
+ call test2(alloc2)
+ call test4(ptr2)
+ call test4(alloc2)
+ call ppTest(pptr)
+ call ppTest2(pptr)
+
+ ! Invalid 1:
+ deallocate(alloc2)
+! call test2(alloc2)
+! call test4(alloc2)
+
+ ! Invalid 2:
+ deallocate(ptr1,ptr2)
+ nullify(ptr1,ptr2)
+! call test1(ptr1)
+! call test3(ptr1)
+! call test2(ptr2)
+! call test4(ptr2)
+
+ ! Invalid 3:
+ nullify(pptr)
+ call ppTest(pptr)
+! call ppTest2(pptr)
+
+contains
+ subroutine test3(b)
+ integer :: b
+ b = 333
+ end subroutine test3
+ subroutine test4(b)
+ integer :: b(2)
+ b = 333
+ end subroutine test4
+ subroutine sub()
+ print *, 'Hello World'
+ end subroutine sub
+ subroutine ppTest2(f)
+ implicit none
+ procedure(sub) :: f
+ call f()
+ end subroutine ppTest2
+end Program RunTimeCheck