aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2015-05-26 10:20:41 +0000
committerPaul Thomas <pault@gcc.gnu.org>2015-05-26 10:20:41 +0000
commit1b961de9db0b7ffb8d7f4614ddf61faf31a544a5 (patch)
tree1b275d36c59aaa9239bd4cce6c1c426681fc6cd5 /gcc/fortran/trans-array.c
parent4a72a6ddd2e9b5d425f53c4e4e99f1d66ca7c46b (diff)
downloadgcc-1b961de9db0b7ffb8d7f4614ddf61faf31a544a5.zip
gcc-1b961de9db0b7ffb8d7f4614ddf61faf31a544a5.tar.gz
gcc-1b961de9db0b7ffb8d7f4614ddf61faf31a544a5.tar.bz2
re PR fortran/66082 (memory leak with automatic array dummy argument with derived type array constructor actual argument)
2015-05-26 Paul Thomas <pault@gcc.gnu.org> PR fortran/66082 * trans-array.c (gfc_conv_array_parameter): Ensure that all non-variable arrays with allocatable components have the components deallocated after the procedure call. 2015-05-26 Paul Thomas <pault@gcc.gnu.org> PR fortran/66082 * gfortran.dg/allocatable_scalar_13.f90: New test From-SVN: r223677
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index e6edf74..c8fab45 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -4458,7 +4458,7 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest,
if (!nDepend && dest_expr->rank > 0
&& dest_expr->ts.type == BT_CHARACTER
&& ss_expr->expr_type == EXPR_VARIABLE)
-
+
nDepend = gfc_check_dependency (dest_expr, ss_expr, false);
continue;
@@ -7267,6 +7267,17 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77,
if (no_pack || array_constructor || good_allocatable || ultimate_alloc_comp)
{
gfc_conv_expr_descriptor (se, expr);
+ /* Deallocate the allocatable components of structures that are
+ not variable. */
+ if ((expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS)
+ && expr->ts.u.derived->attr.alloc_comp
+ && expr->expr_type != EXPR_VARIABLE)
+ {
+ tmp = gfc_deallocate_alloc_comp (expr->ts.u.derived, se->expr, expr->rank);
+
+ /* The components shall be deallocated before their containing entity. */
+ gfc_prepend_expr_to_block (&se->post, tmp);
+ }
if (expr->ts.type == BT_CHARACTER)
se->string_length = expr->ts.u.cl->backend_decl;
if (size)