2013-12-01 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / realloc_on_assign_23.f90
blobf9897f17401ee45c2f639fa02a4d90faf7f29c7f
1 ! { dg-do run }
3 ! PR fortran/57354
5 ! Contributed by Vladimir Fuka <vladimir.fuka@gmail.com>
7 type t
8 integer,allocatable :: i
9 end type
11 type(t) :: e
12 type(t), allocatable :: a(:)
13 integer :: chksum = 0
15 do i=1,3 ! Was 100 in original
16 e%i = i
17 chksum = chksum + i
18 if (.not.allocated(a)) then
19 a = [e]
20 else
21 call foo
22 end if
23 end do
25 if (sum ([(a(i)%i, i=1,size(a))]) .ne. chksum) call abort
26 contains
27 subroutine foo
28 a = [a, e]
29 end subroutine
30 end