Finalization depends on the expression, not on the component.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 31 May 2020 08:26:40 +0000 (10:26 +0200)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 31 May 2020 10:00:07 +0000 (12:00 +0200)
commit811f902b764c5a13178cbd7588e96c16b3fab504
treeec0b2e9b0a0ca1429e8158101c49e49dc5694a6c
parentdc8c02ca1cd18f8c22d70cf17b47125fc25ab243
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.
gcc/fortran/class.c
gcc/fortran/gfortran.h
gcc/testsuite/gfortran.dg/finalize_28.f90
gcc/testsuite/gfortran.dg/finalize_33.f90
gcc/testsuite/gfortran.dg/finalize_34.f90
gcc/testsuite/gfortran.dg/finalize_35.f90 [new file with mode: 0644]