aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-05-21 13:16:06 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-05-21 13:16:06 +0000
commitc4ba884897fc5aa644f3d43990431e023ed618f4 (patch)
treec5e95ad910c1fbf82bdcaff914302cf400079f67 /gcc/fortran
parent4d8a8a0a223f8e65a810bdb4ec3fe7496a964699 (diff)
downloadgcc-c4ba884897fc5aa644f3d43990431e023ed618f4.zip
gcc-c4ba884897fc5aa644f3d43990431e023ed618f4.tar.gz
gcc-c4ba884897fc5aa644f3d43990431e023ed618f4.tar.bz2
re PR fortran/31867 ([4.2 only] function result with character LEN computed at run time)
2007-05-21 Paul Thomas <pault@gcc.gnu.org> PR fortran/31867 PR fortran/31994 * trans-array.c (gfc_conv_expr_descriptor): Obtain the stored offset for non-descriptor, source arrays and correct for stride not equal to one before writing to field of output descriptor. 2007-05-21 Paul Thomas <pault@gcc.gnu.org> PR fortran/31867 * gfortran.dg/char_length_5.f90: New test. PR fortran/31994 * gfortran.dg/array_reference_1.f90: New test. From-SVN: r124903
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/trans-array.c21
2 files changed, 26 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0e7bc69..10886d7 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2007-05-21 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/31867
+ PR fortran/31994
+ * trans-array.c (gfc_conv_expr_descriptor): Obtain the stored
+ offset for non-descriptor, source arrays and correct for stride
+ not equal to one before writing to field of output descriptor.
+
2007-05-20 Daniel Franke <franke.daniel@gmail.com>
PR fortran/32001
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index dfbdef0..e7e091f 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -4595,6 +4595,8 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
if (se->direct_byref)
base = gfc_index_zero_node;
+ else if (GFC_ARRAY_TYPE_P (TREE_TYPE (desc)))
+ base = gfc_evaluate_now (gfc_conv_array_offset (desc), &loop.pre);
else
base = NULL_TREE;
@@ -4668,8 +4670,20 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
stride, info->stride[dim]);
if (se->direct_byref)
- base = fold_build2 (MINUS_EXPR, TREE_TYPE (base),
- base, stride);
+ {
+ base = fold_build2 (MINUS_EXPR, TREE_TYPE (base),
+ base, stride);
+ }
+ else if (GFC_ARRAY_TYPE_P (TREE_TYPE (desc)))
+ {
+ tmp = gfc_conv_array_lbound (desc, n);
+ tmp = fold_build2 (MINUS_EXPR, TREE_TYPE (base),
+ tmp, loop.from[dim]);
+ tmp = fold_build2 (MULT_EXPR, TREE_TYPE (base),
+ tmp, gfc_conv_array_stride (desc, n));
+ base = fold_build2 (PLUS_EXPR, TREE_TYPE (base),
+ tmp, base);
+ }
/* Store the new stride. */
tmp = gfc_conv_descriptor_stride (parm, gfc_rank_cst[dim]);
@@ -4690,7 +4704,8 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
gfc_conv_descriptor_data_set (&loop.pre, parm, offset);
}
- if (se->direct_byref && !se->data_not_needed)
+ if ((se->direct_byref || GFC_ARRAY_TYPE_P (TREE_TYPE (desc)))
+ && !se->data_not_needed)
{
/* Set the offset. */
tmp = gfc_conv_descriptor_offset (parm);