2 ! This checks the correct functioning of derived types with default initializers
3 ! and allocatable components.
5 ! Contributed by Salvatore Filippone <salvatore.filippone@uniroma2.it>
10 integer, allocatable :: p(:)
14 type(m_type), allocatable :: av(:)
15 type(m_type), pointer :: ap => null ()
20 type(basep_type), allocatable :: basepv(:)
21 integer :: p1 , p2 = 1
30 type(m_type), target :: a
32 type(basep_type) :: wee
36 a = m_type ((/101,102/))
40 if (associated (wee%ap) .or. wee%i /= 101) call abort ()
42 if (.not.associated (wee%ap) .or. allocated (wee%av)) call abort ()
43 wee = basep_type ((/m_type ((/201, 202, 203/))/), null (), 99)
44 if (.not.allocated (wee%av) .or. associated (wee%ap) .or. (wee%i .ne. 99)) call abort ()
48 ! Check that allocatable components are nullified after allocation.
49 subroutine test_ab8 ()
53 if (.not.allocated(p%basepv)) then
54 allocate(p%basepv(1),stat=ierr)
56 if (allocated (p%basepv) .neqv. .true.) call abort ()
57 if (allocated (p%basepv(1)%av) .neqv. .false.) call abort
58 if (p%basepv(1)%i .ne. 101) call abort ()
60 end subroutine test_ab8
62 subroutine p_bld (a, p)
66 if (any (a%p .ne. (/101,102/))) call abort ()
67 if (allocated (p%basepv) .or. (p%p2 .ne. 1)) call abort ()
71 ! { dg-final { cleanup-modules "p_type_mod" } }