2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / proc_ptr_comp_51.f90
blobcfe9818706f4542c2e918b38246b697e25229102
1 ! { dg-do compile }
2 ! { dg-options "-fdump-tree-original" }
4 ! PR 80983: [F03] memory leak when calling procedure-pointer component with allocatable result
6 ! Contributed by Janus Weil <janus@gcc.gnu.org>
8 program test
9 implicit none
11 type :: concrete_type
12 procedure (alloc_integer), pointer, nopass :: alloc
13 end type
15 procedure (alloc_integer), pointer :: pp
17 type(concrete_type) :: concrete
19 print *, alloc_integer() ! case #1: plain function
21 pp => alloc_integer
22 print *, pp() ! case #2: procedure pointer
24 concrete % alloc => alloc_integer
25 print *, concrete % alloc() ! case #3: procedure-pointer component
27 contains
29 function alloc_integer() result(res)
30 integer, allocatable :: res
31 allocate(res, source=13)
32 end function
34 end
36 ! { dg-final { scan-tree-dump-times "__builtin_free" 3 "original" } }