aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2008-03-29 08:11:02 +0000
committerPaul Thomas <pault@gcc.gnu.org>2008-03-29 08:11:02 +0000
commit067feae32fe285618807617acf418260c6e9cf12 (patch)
tree4a75eff4d82cbafdd38d6c403013a27b5d32c727 /gcc/fortran
parentdbc518f09c4ac4499dcbf5802e20cd4adb0d9a41 (diff)
downloadgcc-067feae32fe285618807617acf418260c6e9cf12.zip
gcc-067feae32fe285618807617acf418260c6e9cf12.tar.gz
gcc-067feae32fe285618807617acf418260c6e9cf12.tar.bz2
re PR fortran/35698 (lbound and ubound wrong for allocated run-time zero size array)
2008-03-29 Paul Thomas <pault@gcc.gnu.org> PR fortran/35698 * trans-array.c (gfc_array_init_size): Set 'size' zero if negative in one dimension. PR fortran/35702 * trans-expr.c (gfc_trans_string_copy): Only assign a char directly if the lhs and rhs types are the same. 2008-03-29 Paul Thomas <pault@gcc.gnu.org> PR fortran/35698 * gfortran.dg/allocate_zerosize_3.f: New test. PR fortran/35702 * gfortran.dg/character_assign_1.f90: New test. From-SVN: r133710
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog10
-rw-r--r--gcc/fortran/trans-array.c5
-rw-r--r--gcc/fortran/trans-expr.c4
3 files changed, 17 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0658995..6615fd3 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2008-03-29 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/35698
+ * trans-array.c (gfc_array_init_size): Set 'size' zero if
+ negative in one dimension.
+
+ PR fortran/35702
+ * trans-expr.c (gfc_trans_string_copy): Only assign a char
+ directly if the lhs and rhs types are the same.
+
2008-03-28 Daniel Franke <franke.daniel@gmail.com>
Paul Richard Thomas <paul.richard.thomas@gmail.com>
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 30b2a1c..3de1fb71 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -3505,7 +3505,7 @@ gfc_conv_loop_setup (gfc_loopinfo * loop)
size = 1 - lbound;
a.ubound[n] = specified_upper_bound;
a.stride[n] = stride;
- size = ubound + size; //size = ubound + 1 - lbound
+ size = siz >= 0 ? ubound + size : 0; //size = ubound + 1 - lbound
stride = stride * size;
}
return (stride);
@@ -3605,6 +3605,9 @@ gfc_array_init_size (tree descriptor, int rank, tree * poffset,
else
or_expr = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, or_expr, cond);
+ size = fold_build3 (COND_EXPR, gfc_array_index_type, cond,
+ gfc_index_zero_node, size);
+
/* Multiply the stride by the number of elements in this dimension. */
stride = fold_build2 (MULT_EXPR, gfc_array_index_type, stride, size);
stride = gfc_evaluate_now (stride, pblock);
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 9b33d37..0167247 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -2858,7 +2858,9 @@ gfc_trans_string_copy (stmtblock_t * block, tree dlength, tree dest,
dsc = gfc_to_single_character (dlen, dest);
- if (dsc != NULL_TREE && ssc != NULL_TREE)
+ /* Assign directly if the types are compatible. */
+ if (dsc != NULL_TREE && ssc != NULL_TREE
+ && TREE_TYPE (dsc) == TREE_TYPE (ssc))
{
gfc_add_modify_expr (block, dsc, ssc);
return;