view gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_3.f03 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 84e7813d76e9
children
line wrap: on
line source

! { dg-do run }
!
! PR fortran/67721
! Check that scalar to array assignments of derived type constructor
! deep copy the value when there are allocatable components.

program p
  implicit none

  type :: t1
    integer :: c1
  end type t1
  type :: t2
    type(t1), allocatable :: c2
  end type t2

  block
    type(t2) :: v(4)

    v = t2(t1(3))
    v(2)%c2%c1 =  7
    v(3)%c2%c1 = 11
    v(4)%c2%c1 = 13

    if (v(1)%c2%c1 /=  3) STOP 1
    if (v(2)%c2%c1 /=  7) STOP 2
    if (v(3)%c2%c1 /= 11) STOP 3
    if (v(4)%c2%c1 /= 13) STOP 4
  end block
end program p