aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2013-07-15 10:25:48 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2013-07-15 10:25:48 +0200
commitabc2d8074ae190486e3f620075e25498c1b2791c (patch)
treeaf43e59575bb2a233dfe1487ef6186279511baed /gcc/fortran/trans-expr.c
parent895a0c2df3542769fb381f0792cb543da01229ec (diff)
downloadgcc-abc2d8074ae190486e3f620075e25498c1b2791c.zip
gcc-abc2d8074ae190486e3f620075e25498c1b2791c.tar.gz
gcc-abc2d8074ae190486e3f620075e25498c1b2791c.tar.bz2
trans-array.h (gfc_deallocate_alloc_comp_no_caf, [...]): New prototype.
2013-07-15 Tobias Burnus <burnus@net-b.de> * trans-array.h (gfc_deallocate_alloc_comp_no_caf, gfc_reassign_alloc_comp_caf): New prototype. * trans-array.c (enum): Add DEALLOCATE_ALLOC_COMP_NO_CAF and COPY_ALLOC_COMP_CAF. (structure_alloc_comps): Handle it. (gfc_reassign_alloc_comp_caf, gfc_deallocate_alloc_comp_no_caf): New function. (gfc_alloc_allocatable_for_assignment): Call it. * trans-expr.c (gfc_trans_scalar_assign, gfc_trans_arrayfunc_assign, gfc_trans_assignment_1): Ditto. * parse.c (parse_derived): Correctly set coarray_comp. * resolve.c (resolve_symbol): Improve error wording. 2013-07-15 Tobias Burnus <burnus@net-b.de> * gfortran.dg/coarray_lib_realloc_1.f90: New. * gfortran.dg/coarray/lib_realloc_1.f90: New. * gfortran.dg/coarray_6.f90: Add dg-error. From-SVN: r200955
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 0eef2b2..e1ed9d9 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6824,6 +6824,7 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, gfc_typespec ts,
}
else if (ts.type == BT_DERIVED && ts.u.derived->attr.alloc_comp)
{
+ tree tmp_var = NULL_TREE;
cond = NULL_TREE;
/* Are the rhs and the lhs the same? */
@@ -6841,8 +6842,8 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, gfc_typespec ts,
expression. */
if (!l_is_temp && dealloc)
{
- tmp = gfc_evaluate_now (lse->expr, &lse->pre);
- tmp = gfc_deallocate_alloc_comp (ts.u.derived, tmp, 0);
+ tmp_var = gfc_evaluate_now (lse->expr, &lse->pre);
+ tmp = gfc_deallocate_alloc_comp_no_caf (ts.u.derived, tmp_var, 0);
if (deep_copy)
tmp = build3_v (COND_EXPR, cond, build_empty_stmt (input_location),
tmp);
@@ -6855,6 +6856,16 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse, gfc_typespec ts,
gfc_add_modify (&block, lse->expr,
fold_convert (TREE_TYPE (lse->expr), rse->expr));
+ /* Restore pointer address of coarray components. */
+ if (ts.u.derived->attr.coarray_comp && deep_copy)
+ {
+ gcc_assert (tmp_var != NULL_TREE);
+ tmp = gfc_reassign_alloc_comp_caf (ts.u.derived, tmp_var, lse->expr);
+ tmp = build3_v (COND_EXPR, cond, build_empty_stmt (input_location),
+ tmp);
+ gfc_add_expr_to_block (&block, tmp);
+ }
+
/* Do a deep copy if the rhs is a variable, if it is not the
same as the lhs. */
if (deep_copy)
@@ -7196,8 +7207,8 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr * expr2)
&& expr1->ts.u.derived->attr.alloc_comp)
{
tree tmp;
- tmp = gfc_deallocate_alloc_comp (expr1->ts.u.derived, se.expr,
- expr1->rank);
+ tmp = gfc_deallocate_alloc_comp_no_caf (expr1->ts.u.derived, se.expr,
+ expr1->rank);
gfc_add_expr_to_block (&se.pre, tmp);
}
@@ -7762,7 +7773,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
&& expr1->rank && !expr2->rank);
if (scalar_to_array && dealloc)
{
- tmp = gfc_deallocate_alloc_comp (expr2->ts.u.derived, rse.expr, 0);
+ tmp = gfc_deallocate_alloc_comp_no_caf (expr2->ts.u.derived, rse.expr, 0);
gfc_add_expr_to_block (&loop.post, tmp);
}