Plugins: Add label-text.h to CPPLIB_H so it will be installed [PR115288]
[official-gcc.git] / gcc / testsuite / gfortran.dg / alloc_comp_assign_5.f90
blobf8e7f596a53984b4e0c165c1f87c5f5d1c3aeffd
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) STOP 1
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