diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2016-11-25 12:23:43 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2016-11-25 12:23:43 +0000 |
commit | 3cae214f76deaf8271e26b094d6d14a31e537e00 (patch) | |
tree | 8fab2ee64998246794f0a8a8a5297074ab5045fd /gcc/fortran | |
parent | ae22bc5d4ad22aa0a8f21323bb576e6485ffbd4d (diff) | |
download | gcc-3cae214f76deaf8271e26b094d6d14a31e537e00.zip gcc-3cae214f76deaf8271e26b094d6d14a31e537e00.tar.gz gcc-3cae214f76deaf8271e26b094d6d14a31e537e00.tar.bz2 |
[multiple changes]
2016-11-25 Andre Vehreschild <vehre@gcc.gnu.org>
Paul Thomas <pault@gcc.gnu.org>
PR fortran/78293
* trans-expr.c (gfc_conv_procedure_call): Prepend deallocation
of alloctable components to post, rather than adding to
se->post.
* trans-stmt.c (gfc_trans_allocate): Move deallocation of expr3
allocatable components so that all expr3s are visited.
2016-11-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/78293
* gfortran.dg/allocatable_function_10.f90: New test.
* gfortran.dg/class_array_15.f03: Increase builtin_free count
from 11 to 12.
From-SVN: r242875
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 2 | ||||
-rw-r--r-- | gcc/fortran/trans-stmt.c | 25 |
3 files changed, 32 insertions, 12 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4c27f1b..737a22c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,20 @@ +2016-11-25 Andre Vehreschild <vehre@gcc.gnu.org> + Paul Thomas <pault@gcc.gnu.org> + + PR fortran/78293 + * trans-expr.c (gfc_conv_procedure_call): Prepend deallocation + of alloctable components to post, rather than adding to + se->post. + * trans-stmt.c (gfc_trans_allocate): Move deallocation of expr3 + allocatable components so that all expr3s are visited. + +2016-11-25 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/78293 + * gfortran.dg/allocatable_function_10.f90: New test. + * gfortran.dg/class_array_15.f03: Increase builtin_free count + from 11 to 12. + 2016-11-24 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/78500 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 1331b07..1c2d5e1 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -5568,7 +5568,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, tmp = gfc_deallocate_alloc_comp (e->ts.u.derived, tmp, parm_rank); - gfc_add_expr_to_block (&se->post, tmp); + gfc_prepend_expr_to_block (&post, tmp); } /* Add argument checking of passing an unallocated/NULL actual to diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 490b18d..19ecf68 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -5684,17 +5684,6 @@ gfc_trans_allocate (gfc_code * code) } gfc_add_modify_loc (input_location, &block, var, tmp); - /* Deallocate any allocatable components after all the allocations - and assignments of expr3 have been completed. */ - if (code->expr3->ts.type == BT_DERIVED - && code->expr3->rank == 0 - && code->expr3->ts.u.derived->attr.alloc_comp) - { - tmp = gfc_deallocate_alloc_comp (code->expr3->ts.u.derived, - var, 0); - gfc_add_expr_to_block (&post, tmp); - } - expr3 = var; if (se.string_length) /* Evaluate it assuming that it also is complicated like expr3. */ @@ -5705,6 +5694,20 @@ gfc_trans_allocate (gfc_code * code) expr3 = se.expr; expr3_len = se.string_length; } + + /* Deallocate any allocatable components in expressions that use a + temporary, i.e. are not of expr-type EXPR_VARIABLE or force the + use of a temporary, after the assignment of expr3 is completed. */ + if ((code->expr3->ts.type == BT_DERIVED + || code->expr3->ts.type == BT_CLASS) + && (code->expr3->expr_type != EXPR_VARIABLE || temp_var_needed) + && code->expr3->ts.u.derived->attr.alloc_comp) + { + tmp = gfc_deallocate_alloc_comp (code->expr3->ts.u.derived, + expr3, code->expr3->rank); + gfc_prepend_expr_to_block (&post, tmp); + } + /* Store what the expr3 is to be used for. */ if (e3_is == E3_UNSET) e3_is = expr3 != NULL_TREE ? |