Fortran: Fix memory problems with assumed rank formal args [PR98342].
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 24 Feb 2021 16:00:51 +0000 (16:00 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 24 Feb 2021 16:01:08 +0000 (16:01 +0000)
commit5159b88ef1a1774ec8851c6b92794ae2bf6e0b74
tree777a8c1edad455148d80dd771ad40a8ac6028d49
parentbe30dd89926d5dd19d72f90c1586b0e2557fde43
Fortran: Fix memory problems with assumed rank formal args [PR98342].

2021-02-24  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/98342
* trans-expr.c (gfc_conv_derived_to_class): Add optional arg.
'derived_array' to hold the fixed, parmse expr in the case of
assumed rank formal arguments. Deal with optional arguments.
(gfc_conv_procedure_call): Null 'derived' array for each actual
argument. Add its address to the call to gfc_conv_derived_to_
class. Access the 'data' field of scalar descriptors before
deallocating allocatable components. Also strip NOPs before the
calls to gfc_deallocate_alloc_comp. Use 'derived' array as the
input to gfc_deallocate_alloc_comp if it is available.
* trans.h : Include the optional argument 'derived_array' to
the prototype of gfc_conv_derived_to_class. The default value
is NULL_TREE.

gcc/testsuite/
PR fortran/98342
* gfortran.dg/assumed_rank_21.f90 : New test.
gcc/fortran/trans-expr.c
gcc/fortran/trans.h
gcc/testsuite/gfortran.dg/assumed_rank_21.f90 [new file with mode: 0644]