gnu/gcc/95dbc32189ab0433283f337b4b490bfcec0bd475 Fortran: Fix asan problems with PDT testcases [PR121972]
Co-authored-by: Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/121972
gcc/fortran
* expr.cc (has_parameterized_comps): Return false if the DT
is neither a pdt_type nor has PDT components. Correct the
logic for a PDT component.
* trans-expr.cc (alloc_scalar_allocatable_for_assignment): Use
calloc for types with paramterized components as well as those
with allocatable components.
* trans-stmt.cc (gfc_trans_allocate): Merge the allocation of
parameterized components of PDTs and class PDTs into one block
If an allocate type_spec is present that has allocatable comps
where the class declared type does not, nullify the allocatable
components.
gcc/testsuite/
* gfortran.dg/asan/pdt_46.f03: Copy of original with tree dump
for counts of frees, mallocs and callocs removed.
* gfortran.dg/asan/pdt_77.f03: Ditto.
* gfortran.dg/pdt_46.f03: Calloc count added, corresponding to
reduction in mallocs..
* gfortran.dg/pdt_50.f03: Ditto.
7 files changed