diff gcc/testsuite/gfortran.dg/result_default_init_1.f90 @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gfortran.dg/result_default_init_1.f90	Fri Oct 27 22:46:09 2017 +0900
@@ -0,0 +1,26 @@
+! { dg-do run }
+! { dg-options "-O" }
+! Test the fix for PR29216 in which function results did not
+! get default initialization.
+! Contributed by Stephan Kramer  <stephan.kramer@imperial.ac.uk>  
+!
+  type A
+    integer, pointer:: p => null ()
+    integer:: i=3
+  end type A
+  type(A):: x,y
+  if (associated(x%p) .or. x%i /= 3) call abort ()
+  x=f()
+  if (associated(x%p) .or. x%i /= 3) call abort ()
+  x=g()
+  if (associated(x%p) .or. x%i /= 3) call abort ()
+contains
+  function f() result (fr)
+    type(A):: fr
+    if (associated(fr%p) .or. fr%i /= 3) call abort ()
+  end function f
+  function g()
+    type(A):: g
+    if (associated(g%p) .or. g%i /= 3) call abort ()
+  end function g
+end