aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2011-01-30 17:50:01 +0000
committerPaul Thomas <pault@gcc.gnu.org>2011-01-30 17:50:01 +0000
commitdafdf26963a622e074aeeeab399fbe33521d1baa (patch)
treeb8da97f66b986afd0a1f0f8d4f158a5b4dbd22d2 /gcc/fortran
parent7be03a0ef9150f728b5710c0b9ca0962c137a4fc (diff)
downloadgcc-dafdf26963a622e074aeeeab399fbe33521d1baa.zip
gcc-dafdf26963a622e074aeeeab399fbe33521d1baa.tar.gz
gcc-dafdf26963a622e074aeeeab399fbe33521d1baa.tar.bz2
re PR fortran/47523 (Concatenation with deferred length character with lhs variable)
2011-01-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/47523 * trans-expr.c (gfc_trans_assignment_1): If the rhs is an op expr and is assigned to a deferred character length scalar, make sure that the function is called before reallocation, so that the length is available. Include procedure pointer and procedure pointer component rhs as well. 2011-01-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/47523 * trans-expr.c (gfc_trans_assignment_1): If the rhs is an op expr and is assigned to a deferred character length scalar, make sure that the function is called before reallocation, so that the length is available. Include procedure pointer and procedure pointer component rhs as well. PR fortran/45170 PR fortran/35810 PR fortran/47350 * gfortran.dg/allocatable_function_5.f90: New test not added by mistake on 2011-01-28. From-SVN: r169413
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog15
-rw-r--r--gcc/fortran/trans-expr.c9
2 files changed, 22 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index b1df405..ce56256 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-30 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/47523
+ * trans-expr.c (gfc_trans_assignment_1): If the rhs is an op
+ expr and is assigned to a deferred character length scalar,
+ make sure that the function is called before reallocation,
+ so that the length is available. Include procedure pointer
+ and procedure pointer component rhs as well.
+
+ PR fortran/45170
+ PR fortran/35810
+ PR fortran/47350
+ * gfortran.dg/allocatable_function_5.f90: New test not added by
+ mistake on 2011-01-28.
+
2011-01-29 Tobias Burnus <burnus@net-b.de>
PR fortran/47531
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 9bbe791..9682802 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5977,6 +5977,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
stmtblock_t body;
bool l_is_temp;
bool scalar_to_array;
+ bool def_clen_func;
tree string_length;
int n;
@@ -6097,10 +6098,14 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
/* For a deferred character length function, the function call must
happen before the (re)allocation of the lhs, otherwise the character
length of the result is not known. */
+ def_clen_func = (((expr2->expr_type == EXPR_FUNCTION)
+ || (expr2->expr_type == EXPR_COMPCALL)
+ || (expr2->expr_type == EXPR_PPC))
+ && expr2->ts.deferred);
if (gfc_option.flag_realloc_lhs
- && expr2->expr_type == EXPR_FUNCTION
&& expr2->ts.type == BT_CHARACTER
- && expr2->ts.deferred)
+ && (def_clen_func || expr2->expr_type == EXPR_OP)
+ && expr1->ts.deferred)
gfc_add_block_to_block (&block, &rse.pre);
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts,