2018-03-15 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / realloc_on_assign_23.f90
blob71a28e3902e6c59e3e6bab139d2ba731cf0ad1a9
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) STOP 1
26 contains
27 subroutine foo
28 a = [a, e]
29 end subroutine
30 end