view gcc/testsuite/gfortran.dg/realloc_on_assign_28.f90 @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line source

! { dg-do run }
!
! PR fortran/66102
!
! Contributed by Vladimir Fuka  <vladimir.fuka@gmail.com>
!
  type t
    integer,allocatable :: i
  end type

  type(t) :: e
  type(t), allocatable, dimension(:) :: a, b
  integer :: chksum = 0

  do i=1,3   ! Was 100 in original
    e%i = i
    chksum = chksum + i
    if (.not.allocated(a)) then
      a = [e]
      b = first_arg([e], [e])
    else
      call foo
    end if
  end do

  if (sum ([(a(i)%i, i=1,size(a))]) .ne. chksum) STOP 1
  if (any([(a(i)%i, i=1,size(a))] /= [(i, i=1,size(a))])) STOP 2
  if (size(a) /= size(b)) STOP 3
  if (any([(b(i)%i, i=1,size(b))] /= [(i, i=1,size(b))])) STOP 4
contains
  subroutine foo
    b = first_arg([b, e], [a, e])
    a = [a, e]
  end subroutine
  elemental function first_arg(arg1, arg2)
    type(t), intent(in) :: arg1, arg2
    type(t)             :: first_arg
    first_arg = arg1
  end function first_arg
end