comparison 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
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 ! { dg-do run }
2 ! { dg-options "-O" }
3 ! Test the fix for PR29216 in which function results did not
4 ! get default initialization.
5 ! Contributed by Stephan Kramer <stephan.kramer@imperial.ac.uk>
6 !
7 type A
8 integer, pointer:: p => null ()
9 integer:: i=3
10 end type A
11 type(A):: x,y
12 if (associated(x%p) .or. x%i /= 3) call abort ()
13 x=f()
14 if (associated(x%p) .or. x%i /= 3) call abort ()
15 x=g()
16 if (associated(x%p) .or. x%i /= 3) call abort ()
17 contains
18 function f() result (fr)
19 type(A):: fr
20 if (associated(fr%p) .or. fr%i /= 3) call abort ()
21 end function f
22 function g()
23 type(A):: g
24 if (associated(g%p) .or. g%i /= 3) call abort ()
25 end function g
26 end