From 652960d1809b326ad20adcaac1b5a72796413a2e Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Fri, 23 Jan 2015 09:32:09 +0100 Subject: [PATCH] re PR fortran/60922 (Memory leak with allocatable CLASS components) 2015-01-23 Janus Weil PR fortran/60922 * class.c (finalize_component): Apply the check for 'fini_coarray' only to coarray components. 2015-01-23 Janus Weil PR fortran/60922 * gfortran.dg/class_allocate_17.f90: New. From-SVN: r220029 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/class.c | 2 +- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gfortran.dg/class_allocate_17.f90 | 32 +++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/class_allocate_17.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 51d7b59..0695b22 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2015-01-23 Janus Weil + + PR fortran/60922 + * class.c (finalize_component): Apply the check for 'fini_coarray' only + to coarray components. + 2015-01-23 Tobias Burnus PR fortran/64726 diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index a9b65e6..55e7ef4 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -928,7 +928,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 20528c3..efcbc86 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-23 Janus Weil + + PR fortran/60922 + * gfortran.dg/class_allocate_17.f90: New. + 2015-01-23 Tobias Burnus PR fortran/64726 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 0000000..639ba80 --- /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" } } -- 2.7.4