view gcc/testsuite/gfortran.dg/derived_init_1.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 }
! Check that allocatable/pointer variables of derived types with initialized
! components are are initialized when allocated
! PR 21625
program test

    implicit none
    type :: t
        integer :: a = 3
    end type t
    type :: s
        type(t), pointer :: p(:)
        type(t), pointer :: p2
    end type s
    type(t), pointer :: p
    type(t), allocatable :: q(:,:)
    type(s) :: z
    type(s) :: x(2)

    allocate(p, q(2,2))
    if (p%a /= 3) STOP 1
    if (any(q(:,:)%a /= 3)) STOP 2

    allocate(z%p2, z%p(2:3))
    if (z%p2%a /= 3) STOP 3
    if (any(z%p(:)%a /= 3)) STOP 4

    allocate(x(1)%p2, x(1)%p(2))
    if (x(1)%p2%a /= 3) STOP 5
    if (any(x(1)%p(:)%a /= 3)) STOP 6
end program test