| 1 |
! { dg-do run } |
| 2 |
! Check that allocatable/pointer variables of derived types with initialized |
| 3 |
! components are are initialized when allocated |
| 4 |
! PR 21625 |
| 5 |
program test |
| 6 |
|
| 7 |
implicit none |
| 8 |
type :: t |
| 9 |
integer :: a = 3 |
| 10 |
end type t |
| 11 |
type :: s |
| 12 |
type(t), pointer :: p(:) |
| 13 |
type(t), pointer :: p2 |
| 14 |
end type s |
| 15 |
type(t), pointer :: p |
| 16 |
type(t), allocatable :: q(:,:) |
| 17 |
type(s) :: z |
| 18 |
type(s) :: x(2) |
| 19 |
|
| 20 |
allocate(p, q(2,2)) |
| 21 |
if (p%a /= 3) STOP 1 |
| 22 |
if (any(q(:,:)%a /= 3)) STOP 2 |
| 23 |
|
| 24 |
allocate(z%p2, z%p(2:3)) |
| 25 |
if (z%p2%a /= 3) STOP 3 |
| 26 |
if (any(z%p(:)%a /= 3)) STOP 4 |
| 27 |
|
| 28 |
allocate(x(1)%p2, x(1)%p(2)) |
| 29 |
if (x(1)%p2%a /= 3) STOP 5 |
| 30 |
if (any(x(1)%p(:)%a /= 3)) STOP 6 |
| 31 |
end program test |
| 32 |
|