mirror of git://gcc.gnu.org/git/gcc.git
re PR fortran/80983 ([F03] memory leak when calling procedure-pointer component with allocatable result)
2017-06-15 Janus Weil <janus@gcc.gnu.org> PR fortran/80983 * trans-expr.c (gfc_conv_procedure_call): Deallocate the result of scalar allocatable procedure-pointer components. 2017-06-15 Janus Weil <janus@gcc.gnu.org> PR fortran/80983 * gfortran.dg/proc_ptr_comp_51.f90: New test. From-SVN: r249227
This commit is contained in:
parent
0356a0749b
commit
d0e7a9fdfc
|
|
@ -1,3 +1,9 @@
|
||||||
|
2017-06-15 Janus Weil <janus@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR fortran/80983
|
||||||
|
* trans-expr.c (gfc_conv_procedure_call): Deallocate the result of
|
||||||
|
scalar allocatable procedure-pointer components.
|
||||||
|
|
||||||
2017-06-10 Thomas Koenig <tkoenig@gcc.gnu.org>
|
2017-06-10 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||||
|
|
||||||
PR fortran/80988
|
PR fortran/80988
|
||||||
|
|
|
||||||
|
|
@ -6132,7 +6132,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
|
||||||
after use. This necessitates the creation of a temporary to
|
after use. This necessitates the creation of a temporary to
|
||||||
hold the result to prevent duplicate calls. */
|
hold the result to prevent duplicate calls. */
|
||||||
if (!byref && sym->ts.type != BT_CHARACTER
|
if (!byref && sym->ts.type != BT_CHARACTER
|
||||||
&& sym->attr.allocatable && !sym->attr.dimension && !comp)
|
&& ((sym->attr.allocatable && !sym->attr.dimension && !comp)
|
||||||
|
|| (comp && comp->attr.allocatable && !comp->attr.dimension)))
|
||||||
{
|
{
|
||||||
tmp = gfc_create_var (TREE_TYPE (se->expr), NULL);
|
tmp = gfc_create_var (TREE_TYPE (se->expr), NULL);
|
||||||
gfc_add_modify (&se->pre, tmp, se->expr);
|
gfc_add_modify (&se->pre, tmp, se->expr);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
2017-06-15 Janus Weil <janus@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR fortran/80983
|
||||||
|
* gfortran.dg/proc_ptr_comp_51.f90: New test.
|
||||||
|
|
||||||
2017-06-15 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
2017-06-15 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
||||||
|
|
||||||
PR lto/69866
|
PR lto/69866
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
! { dg-do compile }
|
||||||
|
!
|
||||||
|
! PR 80983: [F03] memory leak when calling procedure-pointer component with allocatable result
|
||||||
|
!
|
||||||
|
! Contributed by Janus Weil <janus@gcc.gnu.org>
|
||||||
|
|
||||||
|
program test
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
type :: concrete_type
|
||||||
|
procedure (alloc_integer), pointer, nopass :: alloc
|
||||||
|
end type
|
||||||
|
|
||||||
|
procedure (alloc_integer), pointer :: pp
|
||||||
|
|
||||||
|
type(concrete_type) :: concrete
|
||||||
|
|
||||||
|
print *, alloc_integer() ! case #1: plain function
|
||||||
|
|
||||||
|
pp => alloc_integer
|
||||||
|
print *, pp() ! case #2: procedure pointer
|
||||||
|
|
||||||
|
concrete % alloc => alloc_integer
|
||||||
|
print *, concrete % alloc() ! case #3: procedure-pointer component
|
||||||
|
|
||||||
|
contains
|
||||||
|
|
||||||
|
function alloc_integer() result(res)
|
||||||
|
integer, allocatable :: res
|
||||||
|
allocate(res, source=13)
|
||||||
|
end function
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
! { dg-final { scan-tree-dump-times "__builtin_free" 3 "original" } }
|
||||||
Loading…
Reference in New Issue