aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.c
diff options
context:
space:
mode:
authorMikael Morin <mikael@gcc.gnu.org>2015-07-17 09:40:29 +0000
committerMikael Morin <mikael@gcc.gnu.org>2015-07-17 09:40:29 +0000
commit0e1f8c6a90834987f63f911a86d78e40d5577e80 (patch)
tree7078210f7a994805cf1f64553e2404f73464f23c /gcc/fortran/trans-array.c
parenta6c51a129328343ba445f1cc663f455c173cdc97 (diff)
downloadgcc-0e1f8c6a90834987f63f911a86d78e40d5577e80.zip
gcc-0e1f8c6a90834987f63f911a86d78e40d5577e80.tar.gz
gcc-0e1f8c6a90834987f63f911a86d78e40d5577e80.tar.bz2
Fix PR61831: Side-effect variable component deallocation
gcc/fortran/ 2015-07-17 Mikael Morin <mikael@gcc.gnu.org> Dominique d'Humieres <dominiq@lps.ens.fr> PR fortran/61831 * trans-array.c (gfc_conv_array_parameter): Guard allocatable component deallocation code generation with descriptorless calling convention flag. * trans-expr.c (gfc_conv_expr_reference): Remove allocatable component deallocation code generation from revision 212329. (expr_may_alias_variables): New function. (gfc_conv_procedure_call): New boolean elemental_proc to factor check for procedure elemental-ness. Rename boolean f to nodesc_arg and declare it in the outer scope. Use expr_may_alias_variables, elemental_proc and nodesc_arg to decide whether generate allocatable component deallocation code. (gfc_trans_subarray_assign): Set deep copy flag. gcc/testsuite/ 2015-07-17 Mikael Morin <mikael@gcc.gnu.org> PR fortran/61831 * gfortran.dg/alloc_comp_auto_array_3.f90: Count the number of generated while loops in the tree dump. * gfortran.dg/derived_constructor_comps_6.f90: New file. Co-Authored-By: Dominique d'Humieres <dominiq@lps.ens.fr> From-SVN: r225926
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r--gcc/fortran/trans-array.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index a520f03..1d5ddd0 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -7395,10 +7395,11 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77,
}
/* 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)
+ not variable, for descriptorless arguments.
+ Arguments with a descriptor are handled in gfc_conv_procedure_call. */
+ if (g77 && (expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS)
+ && expr->ts.u.derived->attr.alloc_comp
+ && expr->expr_type != EXPR_VARIABLE)
{
tmp = build_fold_indirect_ref_loc (input_location, se->expr);
tmp = gfc_deallocate_alloc_comp (expr->ts.u.derived, tmp, expr->rank);