| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-fdump-tree-original" } |
| 3 |
! |
| 4 |
! PR 47637: [OOP] Memory leak involving INTENT(OUT) CLASS argument w/ allocatable components |
| 5 |
! |
| 6 |
! Contributed by Rich Townsend <[email protected]> |
| 7 |
|
| 8 |
program test |
| 9 |
|
| 10 |
type :: t |
| 11 |
integer, allocatable :: i(:) |
| 12 |
end type |
| 13 |
|
| 14 |
block ! New block as the main program implies SAVE |
| 15 |
type(t) :: a |
| 16 |
|
| 17 |
call init(a) |
| 18 |
call init(a) |
| 19 |
end block |
| 20 |
contains |
| 21 |
|
| 22 |
subroutine init(x) |
| 23 |
class(t), intent(out) :: x |
| 24 |
allocate(x%i(1000)) |
| 25 |
end subroutine |
| 26 |
|
| 27 |
end program |
| 28 |
|
| 29 |
! { dg-final { scan-tree-dump-times "__builtin_free" 4 "original" } } |
| 30 |
! { dg-final { scan-tree-dump-times "_vptr->_final \\(&desc" 1 "original" } } |