2 ! { dg-options "-fdump-tree-original" }
4 ! Test the fix for PR86481
6 ! Contributed by Rich Townsend <townsend@astro.wisc.edu>
12 type, abstract
:: foo_t
15 type, extends(foo_t
) :: foo_a_t
16 real(8), allocatable
:: a(:)
19 type, extends(foo_t
) :: bar_t
20 class(foo_t
), allocatable
:: f
23 integer, parameter :: N
= 2
24 integer, parameter :: D
= 3
39 function func_bar (D
) result (b
)
41 integer, intent(in
) :: D
44 allocate(b
%f
, SOURCE
=func_foo(D
))
50 function func_foo (D
) result (f
)
52 integer, intent(in
) :: D
53 class(foo_t
), allocatable
:: f
55 allocate(f
, SOURCE
=func_foo_a(D
)) ! Lose one of these for each allocation
61 function func_foo_a (D
) result (f
)
63 integer, intent(in
) :: D
66 allocate(f
%a(D
)) ! Lose one of these for each allocation => N*D*elem_size(f%a)
68 end function func_foo_a
70 end program simple_leak
71 ! { dg-final { scan-tree-dump-times "\>_final" 6 "original" } }