diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2020-05-31 10:26:40 +0200 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2020-05-31 12:00:07 +0200 |
commit | 811f902b764c5a13178cbd7588e96c16b3fab504 (patch) | |
tree | ec0b2e9b0a0ca1429e8158101c49e49dc5694a6c /gcc/fortran/class.c | |
parent | dc8c02ca1cd18f8c22d70cf17b47125fc25ab243 (diff) | |
download | gcc-811f902b764c5a13178cbd7588e96c16b3fab504.zip gcc-811f902b764c5a13178cbd7588e96c16b3fab504.tar.gz gcc-811f902b764c5a13178cbd7588e96c16b3fab504.tar.bz2 |
Finalization depends on the expression, not on the component.
This patch fixes a 8/9/10/11 regression, where finalized types
were not finalized (and deallocated), which led to memory
leaks.
gcc/fortran/ChangeLog:
2020-05-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/94361
* class.c (finalize_component): Use expr->finalized instead of
comp->finalized.
* gfortran.h (gfc_component): Remove finalized member.
(gfc_expr): Add it here instead.
gcc/testsuite/ChangeLog:
2020-05-24 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/94361
* gfortran.dg/finalize_28.f90: Adjusted free counts.
* gfortran.dg/finalize_33.f90: Likewise.
* gfortran.dg/finalize_34.f90: Likewise.
* gfortran.dg/finalize_35.f90: New test.
Diffstat (limited to 'gcc/fortran/class.c')
-rw-r--r-- | gcc/fortran/class.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index afd8885..b176407 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -921,7 +921,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp, if (!comp_is_finalizable (comp)) return; - if (comp->finalized) + if (expr->finalized) return; e = gfc_copy_expr (expr); @@ -1012,6 +1012,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp, } else (*code) = cond; + } else if (comp->ts.type == BT_DERIVED && comp->ts.u.derived->f2k_derived @@ -1051,7 +1052,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp, sub_ns); gfc_free_expr (e); } - comp->finalized = true; + expr->finalized = 1; } |