annotate gcc/testsuite/gfortran.dg/alloc_comp_initializer_1.f90 @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! { dg-do run }
kono
parents:
diff changeset
2 ! This checks the correct functioning of derived types with default initializers
kono
parents:
diff changeset
3 ! and allocatable components.
kono
parents:
diff changeset
4 !
kono
parents:
diff changeset
5 ! Contributed by Salvatore Filippone <salvatore.filippone@uniroma2.it>
kono
parents:
diff changeset
6 !
kono
parents:
diff changeset
7 module p_type_mod
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 type m_type
kono
parents:
diff changeset
10 integer, allocatable :: p(:)
kono
parents:
diff changeset
11 end type m_type
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 type basep_type
kono
parents:
diff changeset
14 type(m_type), allocatable :: av(:)
kono
parents:
diff changeset
15 type(m_type), pointer :: ap => null ()
kono
parents:
diff changeset
16 integer :: i = 101
kono
parents:
diff changeset
17 end type basep_type
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 type p_type
kono
parents:
diff changeset
20 type(basep_type), allocatable :: basepv(:)
kono
parents:
diff changeset
21 integer :: p1 , p2 = 1
kono
parents:
diff changeset
22 end type p_type
kono
parents:
diff changeset
23 end module p_type_mod
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 program foo
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 use p_type_mod
kono
parents:
diff changeset
28 implicit none
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 type(m_type), target :: a
kono
parents:
diff changeset
31 type(p_type) :: pre
kono
parents:
diff changeset
32 type(basep_type) :: wee
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 call test_ab8 ()
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 a = m_type ((/101,102/))
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 call p_bld (a, pre)
kono
parents:
diff changeset
39
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
40 if (associated (wee%ap) .or. wee%i /= 101) STOP 1
111
kono
parents:
diff changeset
41 wee%ap => a
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
42 if (.not.associated (wee%ap) .or. allocated (wee%av)) STOP 2
111
kono
parents:
diff changeset
43 wee = basep_type ((/m_type ((/201, 202, 203/))/), null (), 99)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
44 if (.not.allocated (wee%av) .or. associated (wee%ap) .or. (wee%i .ne. 99)) STOP 3
111
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 contains
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 ! Check that allocatable components are nullified after allocation.
kono
parents:
diff changeset
49 subroutine test_ab8 ()
kono
parents:
diff changeset
50 type(p_type) :: p
kono
parents:
diff changeset
51 integer :: ierr
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 if (.not.allocated(p%basepv)) then
kono
parents:
diff changeset
54 allocate(p%basepv(1),stat=ierr)
kono
parents:
diff changeset
55 endif
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
56 if (allocated (p%basepv) .neqv. .true.) STOP 4
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
57 if (allocated (p%basepv(1)%av) .neqv. .false.) STOP 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
58 if (p%basepv(1)%i .ne. 101) STOP 5
111
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 end subroutine test_ab8
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 subroutine p_bld (a, p)
kono
parents:
diff changeset
63 use p_type_mod
kono
parents:
diff changeset
64 type (m_type) :: a
kono
parents:
diff changeset
65 type(p_type) :: p
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
66 if (any (a%p .ne. (/101,102/))) STOP 6
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
67 if (allocated (p%basepv) .or. (p%p2 .ne. 1)) STOP 7
111
kono
parents:
diff changeset
68 end subroutine p_bld
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 end program foo