aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-07-28 05:29:06 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-07-28 05:29:06 +0000
commitb8247b13893d56a6dc3bc0ae77761b3e826aeac5 (patch)
treedfdc730eb913c4d4badc7744a62fc9b1ab0f8521 /gcc/fortran
parent9587952bbfbcd6b8c25e21da630802c4cffef712 (diff)
downloadgcc-b8247b13893d56a6dc3bc0ae77761b3e826aeac5.zip
gcc-b8247b13893d56a6dc3bc0ae77761b3e826aeac5.tar.gz
gcc-b8247b13893d56a6dc3bc0ae77761b3e826aeac5.tar.bz2
re PR fortran/32880 (User operator & allocatable TYPE components: wrong deallocate)
2007-07-28 Paul Thomas <pault@gcc.gnu.org> PR fortran/32880 * trans-expr.c (gfc_trans_scalar_assign): Revert to fixed order for lse and rse pre expressions, for derived types with allocatable components. Instead, assign the lhs to a temporary and deallocate after the assignment. 2007-07-28 Paul Thomas <pault@gcc.gnu.org> PR fortran/32880 * gfortran.dg/alloc_comp_assign_6.f90: New test. From-SVN: r127011
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/trans-expr.c21
2 files changed, 16 insertions, 13 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 29c134d..5f8e39d 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2007-07-28 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/32880
+ * trans-expr.c (gfc_trans_scalar_assign): Revert to fixed order
+ for lse and rse pre expressions, for derived types with
+ allocatable components. Instead, assign the lhs to a temporary
+ and deallocate after the assignment.
+
2007-07-28 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/32909
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 2436574..528bf39 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -3512,25 +3512,20 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, gfc_typespec ts,
}
/* Deallocate the lhs allocated components as long as it is not
- the same as the rhs. */
+ the same as the rhs. This must be done following the assignment
+ to prevent deallocating data that could be used in the rhs
+ expression. */
if (!l_is_temp)
{
- tmp = gfc_deallocate_alloc_comp (ts.derived, lse->expr, 0);
+ tmp = gfc_evaluate_now (lse->expr, &lse->pre);
+ tmp = gfc_deallocate_alloc_comp (ts.derived, tmp, 0);
if (r_is_var)
tmp = build3_v (COND_EXPR, cond, build_empty_stmt (), tmp);
- gfc_add_expr_to_block (&lse->pre, tmp);
+ gfc_add_expr_to_block (&lse->post, tmp);
}
- if (r_is_var)
- {
- gfc_add_block_to_block (&block, &lse->pre);
- gfc_add_block_to_block (&block, &rse->pre);
- }
- else
- {
- gfc_add_block_to_block (&block, &rse->pre);
- gfc_add_block_to_block (&block, &lse->pre);
- }
+ gfc_add_block_to_block (&block, &rse->pre);
+ gfc_add_block_to_block (&block, &lse->pre);
gfc_add_modify_expr (&block, lse->expr,
fold_convert (TREE_TYPE (lse->expr), rse->expr));