summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_present.f90
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_present.f90')
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_present.f9040
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_present.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_present.f90
new file mode 100644
index 000000000..d2e998135
--- /dev/null
+++ b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_present.f90
@@ -0,0 +1,40 @@
+! Program to test the PRESENT intrinsic
+program intrinsic_present
+ implicit none
+ integer a
+ integer, pointer :: b
+ integer, dimension(10) :: c
+ integer, pointer, dimension(:) :: d
+
+ if (testvar()) call abort ()
+ if (.not. testvar(a)) call abort ()
+ if (testptr()) call abort ()
+ if (.not. testptr(b)) call abort ()
+ if (testarray()) call abort ()
+ if (.not. testarray(c)) call abort ()
+ if (testparray()) call abort ()
+ if (.not. testparray(d)) call abort ()
+
+contains
+logical function testvar (p)
+ integer, optional :: p
+ testvar = present(p)
+end function
+
+logical function testptr (p)
+ integer, pointer, optional :: p
+ testptr = present(p)
+end function
+
+logical function testarray (p)
+ integer, dimension (10), optional :: p
+ testarray = present(p)
+end function
+
+logical function testparray (p)
+ integer, pointer, dimension(:), optional :: p
+ testparray = present(p)
+end function
+
+end program
+