aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2006-12-05 19:32:59 +0000
committerPaul Thomas <pault@gcc.gnu.org>2006-12-05 19:32:59 +0000
commitbab651ad74c5b68cbb1405fe407934d1d9f8aa77 (patch)
tree86e3992ce63ff1b46d60b5b210ed049b7e036c03 /gcc/fortran
parent66087ed002040eb81038cf79937500809590dadd (diff)
downloadgcc-bab651ad74c5b68cbb1405fe407934d1d9f8aa77.zip
gcc-bab651ad74c5b68cbb1405fe407934d1d9f8aa77.tar.gz
gcc-bab651ad74c5b68cbb1405fe407934d1d9f8aa77.tar.bz2
re PR fortran/29912 ([4.1 only] Gfortran: string array functions behaving incorrectly...)
2006-12-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/29912 * trans-expr.c (gfc_trans_arrayfunc_assign): Return NULL if the lhs and rhs character lengths are not constant and equal for character array valued functions. 2006-12-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/29912 * gfortran.dg/char_result_12.f90: New test. From-SVN: r119554
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/trans-expr.c17
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index eeaaa48..a65b4a7 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2006-12-05 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/29912
+ * trans-expr.c (gfc_trans_arrayfunc_assign): Return NULL if the
+ lhs and rhs character lengths are not constant and equal for
+ character array valued functions.
+
2006-12-04 Tobias Burnus <burnus@net-b.de>
PR fortran/29962
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 3505236..7c064ff 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -3382,6 +3382,23 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr * expr2)
|| expr2->symtree->n.sym->attr.allocatable)
return NULL;
+ /* Character array functions need temporaries unless the
+ character lengths are the same. */
+ if (expr2->ts.type == BT_CHARACTER && expr2->rank > 0)
+ {
+ if (expr1->ts.cl->length == NULL
+ || expr1->ts.cl->length->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ if (expr2->ts.cl->length == NULL
+ || expr2->ts.cl->length->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ if (mpz_cmp (expr1->ts.cl->length->value.integer,
+ expr2->ts.cl->length->value.integer) != 0)
+ return NULL;
+ }
+
/* Check that no LHS component references appear during an array
reference. This is needed because we do not have the means to
span any arbitrary stride with an array descriptor. This check