2 ! { dg-options "-fdump-tree-original" }
4 ! Test the fix for the array version of PR80477
6 ! Contributed by Stefano Zaghi <stefano.zaghi@cnr.it>
12 real, allocatable
:: y(:)
15 subroutine assign_a_type(lhs
, rhs
)
16 type(a_type_t
), intent(inout
) :: lhs
17 type(a_type_t
), intent(in
) :: rhs(:)
18 lhs
%x
= rhs(1)%x
+ rhs(2)%x
21 function add_a_type(lhs
, rhs
) result( res
)
22 type(a_type_t
), intent(in
) :: lhs
23 type(a_type_t
), intent(in
) :: rhs
24 class(a_type_t
), allocatable
:: res(:)
25 allocate (a_type_t
:: res(2))
26 allocate (res(1)%y(1))
27 allocate (res(2)%y(1))
33 program polymorphic_operators_memory_leaks
36 type(a_type_t
) :: a
= a_type_t(1) , b
= a_type_t(2)
37 call assign_a_type (a
, add_a_type(a
,b
))
40 ! { dg-final { scan-tree-dump-times "builtin_free" 5 "original" } }
41 ! { dg-final { scan-tree-dump-times "builtin_malloc" 7 "original" } }