2 ! { dg-options "-fdump-tree-original" }
4 ! In the course of fixing PR83118, lots of issues came up with class array
5 ! assignment, where temporaries are generated. This testcase checks that
6 ! the use of assignment by allocate with source is OK, especially with array
7 ! constructors using class arrays. While this test did run previously, the
8 ! temporaries for such arrays were malformed with the class as the type and
9 ! element lengths of 72 bytes rather than the 4 bytes of the decalred type.
11 ! Contributed by Dominique d'Humieres <dhumieres.dominique@free.fr>
16 type, extends(t1
) :: t2
20 class(t1
), allocatable
:: a(:), b(:), c(:)
25 if (.not
.check_t1 (a
, [(5, i
= 1, 3)], 2)) stop 1
27 allocate(c
, source
=[a
, b
]) ! F2008, PR 44672
28 if (.not
.check_t1 (c
, [(5, i
= 1, 8)], 1)) stop 2
31 allocate(c(8), source
=[ a
, b
])
32 if (.not
.check_t1 (c
, [(5, i
= 1, 8)], 1)) stop 3
35 c
= [t1
:: a
, b
] ! F2008, PR 43366
36 if (.not
.check_t1 (c
, [(5, i
= 1, 8)], 1)) stop 4
41 logical function check_t1 (arg
, array
, t
)
43 integer :: array (:), t
47 if (any (arg
%i
.ne
. array
)) check_t1
= .false
.
48 if (t
.eq
. 2) check_t1
= .false
.
50 if (any (arg
%i
.ne
. array
)) check_t1
= .false
.
51 if (t
.eq
. 1) check_t1
= .false
.
58 ! { dg-final { scan-tree-dump-times "elem_len=72" 0 "original" } }