aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2009-03-31 20:03:23 +0000
committerPaul Thomas <pault@gcc.gnu.org>2009-03-31 20:03:23 +0000
commitbf0d171aead0443d546cf48d714ea84ecbb6ab91 (patch)
treef9137ff38dfef4f8d462e92348dbae3950b9f0b4 /gcc/fortran
parentfba1b95f239ccead8ac1373c61a77e660efaa650 (diff)
downloadgcc-bf0d171aead0443d546cf48d714ea84ecbb6ab91.zip
gcc-bf0d171aead0443d546cf48d714ea84ecbb6ab91.tar.gz
gcc-bf0d171aead0443d546cf48d714ea84ecbb6ab91.tar.bz2
re PR fortran/38915 (wrong results for structure assignment of character components when left and right sides overlap)
2009-03-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38915 * trans-expr.c (gfc_trans_assignment_1): Ensure temporaries have a string_length. 2009-03-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38915 * gfortran.dg/char_length_15.f90: New test. From-SVN: r145370
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-expr.c12
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c7ed02d..ef6d2b5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -137,6 +137,12 @@
Add 2009 to copyright years.
* trans.c (gfc_trans_code): Likewise on both counts.
+2009-03-31 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/38915
+ * trans-expr.c (gfc_trans_assignment_1): Ensure temporaries
+ have a string_length.
+
2009-03-28 Tobias Burnus <burnus@net-b.de>
PR fortran/34656
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 91485d1..dcbccef 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -4585,6 +4585,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;
+ tree string_length;
/* Assignment of the form lhs = rhs. */
gfc_start_block (&block);
@@ -4660,10 +4661,18 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag)
/* Translate the expression. */
gfc_conv_expr (&rse, expr2);
+ /* Stabilize a string length for temporaries. */
+ if (expr2->ts.type == BT_CHARACTER)
+ string_length = gfc_evaluate_now (rse.string_length, &rse.pre);
+ else
+ string_length = NULL_TREE;
+
if (l_is_temp)
{
gfc_conv_tmp_array_ref (&lse);
gfc_advance_se_ss_chain (&lse);
+ if (expr2->ts.type == BT_CHARACTER)
+ lse.string_length = string_length;
}
else
gfc_conv_expr (&lse, expr1);
@@ -4718,6 +4727,9 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag)
gcc_assert (lse.ss == gfc_ss_terminator
&& rse.ss == gfc_ss_terminator);
+ if (expr2->ts.type == BT_CHARACTER)
+ rse.string_length = string_length;
+
tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts,
false, false);
gfc_add_expr_to_block (&body, tmp);