Debian Codegraph @

gcc/testsuite/gfortran.dg/finalize_35.f90

raw
1 ! { dg-do compile }
2 ! { dg-additional-options "-fdump-tree-original" }
3 ! PR 94361 - this left open some memory leaks. Original test case by
4 ! Antony Lewis.
5
6 module debug
7 private
8
9 Type TypeWithFinal
10 contains
11 FINAL :: finalizer !No leak if this line is commented
12 end type TypeWithFinal
13
14 Type Tester
15 real, dimension(:), allocatable :: Dat
16 Type(TypeWithFinal) :: X
17 end Type Tester
18
19 Type :: TestType2
20 Type(Tester) :: T
21 end type TestType2
22 public Leaker
23 contains
24
25 subroutine Leaker
26 type(TestType2) :: Test
27
28 allocate(Test%T%Dat(1000))
29 end subroutine Leaker
30
31 subroutine finalizer(this)
32 Type(TypeWithFinal) :: this
33 end subroutine finalizer
34
35 end module debug
36
37
38 program run
39 use debug
40 implicit none
41 integer i
42
43 do i=1, 1000
44 call Leaker()
45 end do
46
47 end program run
48 ! { dg-final { scan-tree-dump-times "__builtin_free\\ \\(ptr2" 2 "original" } }