2008-07-06 Kai Tietz <kai.tietz@onevision.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / alloc_comp_assign_4.f90
blobb204106da2d1de9b9373a718097c7b44396a62de
1 ! { dg-do run }
2 ! Test assignments of nested derived types with character allocatable
3 ! components(PR 20541). Subroutine test_ab6 checks out a bug in a test
4 ! version of gfortran's allocatable arrays.
6 ! Contributed by Erik Edelmann <eedelmann@gcc.gnu.org>
7 ! and Paul Thomas <pault@gcc.gnu.org>
9 type :: a
10 character(4), allocatable :: ch(:)
11 end type a
13 type :: b
14 type (a), allocatable :: at(:)
15 end type b
17 type(a) :: x(2)
18 type(b) :: y(2), z(2)
20 character(4) :: chr1(4) = (/"abcd","efgh","ijkl","mnop"/)
21 character(4) :: chr2(4) = (/"qrst","uvwx","yz12","3456"/)
23 x(1) = a(chr1)
25 ! Check constructor with character array constructors.
26 x(2) = a((/"qrst","uvwx","yz12","3456"/))
28 y(1) = b((/x(1),x(2)/))
29 y(2) = b((/x(2),x(1)/))
31 y(2) = y(1)
33 if (any((/((y(2)%at(i)%ch(j),j=1,4),i=1,2)/) .ne. &
34 (/chr1, chr2/))) call abort ()
36 call test_ab6 ()
38 contains
40 subroutine test_ab6 ()
41 ! This subroutine tests the presence of a scalar derived type, intermediate
42 ! in a chain of derived types with allocatable components.
43 ! Contributed by Salvatore Filippone <salvatore.filippone@uniroma2.it>
45 type b
46 type(a) :: a
47 end type b
49 type c
50 type(b), allocatable :: b(:)
51 end type c
53 type(c) :: p
54 type(b) :: bv
56 p = c((/b(a((/"Mary","Lamb"/)))/))
57 bv = p%b(1)
59 if (any ((bv%a%ch(:)) .ne. (/"Mary","Lamb"/))) call abort ()
61 end subroutine test_ab6
63 end