From: Janus Weil Date: Sat, 24 Jan 2015 10:11:52 +0000 (+0100) Subject: backport: re PR fortran/60922 (Memory leak with allocatable CLASS components) X-Git-Tag: releases/gcc-4.9.3~421 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08cd2ab7e890dad2525bd4bcf074c8bb33a15ddb;p=thirdparty%2Fgcc.git backport: re PR fortran/60922 (Memory leak with allocatable CLASS components) 2015-01-24 Janus Weil Backport from mainline PR fortran/60922 * class.c (finalize_component): Apply the check for 'fini_coarray' only to coarray components. 2015-01-24 Janus Weil Backport from mainline PR fortran/60922 * gfortran.dg/class_allocate_17.f90: New. From-SVN: r220078 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3828f1ab1f70..cb7b7a6bae80 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2015-01-24 Janus Weil + + Backport from mainline + PR fortran/60922 + * class.c (finalize_component): Apply the check for 'fini_coarray' only + to coarray components. + 2015-01-14 Jakub Jelinek Backported from mainline diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 346aee652052..f28c8ad407c1 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -875,7 +875,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp, /* Add IF (fini_coarray). */ if (comp->attr.codimension || (comp->ts.type == BT_CLASS && CLASS_DATA (comp) - && CLASS_DATA (comp)->attr.allocatable)) + && CLASS_DATA (comp)->attr.codimension)) { block = gfc_get_code (EXEC_IF); if (*code) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fd9562a197ee..c2f61d911e61 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-01-24 Janus Weil + + Backport from mainline + PR fortran/60922 + * gfortran.dg/class_allocate_17.f90: New. + 2015-01-20 Marek Polacek Backport from mainline diff --git a/gcc/testsuite/gfortran.dg/class_allocate_17.f90 b/gcc/testsuite/gfortran.dg/class_allocate_17.f90 new file mode 100644 index 000000000000..639ba80ea60f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_allocate_17.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! +! PR 60922: [4.9/5 regression] Memory leak with allocatable CLASS components +! +! Contributed by Salvatore Filippone + +program test_leak + implicit none + + type d_base_vect_type + end type + + type d_vect_type + class(d_base_vect_type), allocatable :: v + end type + + call test() + +contains + + subroutine test() + class(d_vect_type), allocatable :: x + allocate(x) + allocate(x%v) + print *,"allocated!" + end subroutine + +end + +! { dg-final { scan-tree-dump-times "fini_coarray" 1 "original" } } +! { dg-final { cleanup-tree-dump "original" } }