2014-07-12 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / alloc_comp_assign_5.f90
blob3cc3695c4cf81108fa8311a04a6ce5a03f3d49d1
1 ! { dg-do run }
2 ! { dg-options "-O2" }
3 ! Tests the fix for PR29428, in which the assignment of
4 ! a function result would result in the function being
5 ! called twice, if it were not a result by reference,
6 ! because of a spurious nullify in gfc_trans_scalar_assign.
8 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
10 program test
11 implicit none
13 type A
14 integer, allocatable :: j(:)
15 end type A
17 type(A):: x
18 integer :: ctr = 0
20 x = f()
22 if (ctr /= 1) call abort ()
24 contains
26 function f()
27 type(A):: f
28 ctr = ctr + 1
29 f = A ((/1,2/))
30 end function f
32 end program