1! { dg-do run }
2! { dg-options "-fdump-tree-original" }
3!
4! PR 42647: Missed initialization/dealloc of allocatable scalar DT with allocatable component
5!
6! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
7
8module m
9type st
10  integer , allocatable :: a1
11end type st
12type at
13  integer , allocatable :: a2(:)
14end type at
15
16type t1
17  type(st), allocatable :: b1
18end type t1
19type t2
20  type(st), allocatable :: b2(:)
21end type t2
22type t3
23  type(at), allocatable :: b3
24end type t3
25type t4
26  type(at), allocatable :: b4(:)
27end type t4
28end module m
29
30use m
31block ! Start new scoping unit as otherwise the vars are implicitly SAVEd
32type(t1) :: na1, a1, aa1(:)
33type(t2) :: na2, a2, aa2(:)
34type(t3) :: na3, a3, aa3(:)
35type(t4) :: na4, a4, aa4(:)
36
37allocatable :: a1, a2, a3, a4, aa1, aa2, aa3,aa4
38
39if(allocated(a1)) call abort()
40if(allocated(a2)) call abort()
41if(allocated(a3)) call abort()
42if(allocated(a4)) call abort()
43if(allocated(aa1)) call abort()
44if(allocated(aa2)) call abort()
45if(allocated(aa3)) call abort()
46if(allocated(aa4)) call abort()
47
48if(allocated(na1%b1)) call abort()
49if(allocated(na2%b2)) call abort()
50if(allocated(na3%b3)) call abort()
51if(allocated(na4%b4)) call abort()
52end block
53end
54
55! { dg-final { scan-tree-dump-times "__builtin_free" 32 "original" } }
56! { dg-final { cleanup-tree-dump "original" } }
57