diff gcc/testsuite/gfortran.dg/allocate_with_source_21.f03 @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gfortran.dg/allocate_with_source_21.f03	Fri Oct 27 22:46:09 2017 +0900
@@ -0,0 +1,52 @@
+! { dg-do compile }
+
+! Check fix for pr71936.
+! Contributed by Gerhard Steinmetz
+
+program p
+  type t
+  end type
+
+  call test2()
+  call test4()
+  call test1()
+  call test3()
+contains
+  function f_p()
+    class(t), pointer :: f_p(:)
+    nullify(f_p)
+  end
+
+  function f_a()
+    class(t), allocatable :: f_a(:)
+  end
+
+  subroutine test1()
+    class(t), allocatable :: x(:)
+    allocate (x, mold=f_a())
+    deallocate (x)
+    allocate (x, source=f_a())
+  end subroutine
+
+  subroutine test2()
+    class(t), pointer :: x(:)
+    allocate (x, mold=f_p())
+    deallocate (x)
+    allocate (x, source=f_p())
+  end
+
+  subroutine test3()
+    class(t), pointer :: x(:)
+    allocate (x, mold=f_a())
+    deallocate (x)
+    allocate (x, source=f_a())
+  end
+
+  subroutine test4()
+    class(t), allocatable :: x(:)
+    allocate (x, mold=f_p())
+    deallocate (x)
+    allocate (x, source=f_p())
+  end subroutine
+end
+