aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-04-22 08:34:41 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-04-22 08:34:41 +0000
commit92375a2020b1f32bf7be92025493cebd9b3b4400 (patch)
tree3b644ac3468bdfc3f3d146ccfd9417222f96a056 /gcc/fortran
parentc334c130bd67d51f03327e14a05ca4ba6b38be20 (diff)
downloadgcc-92375a2020b1f32bf7be92025493cebd9b3b4400.zip
gcc-92375a2020b1f32bf7be92025493cebd9b3b4400.tar.gz
gcc-92375a2020b1f32bf7be92025493cebd9b3b4400.tar.bz2
re PR fortran/43829 (Scalarization of reductions)
2010-04-22 Richard Guenther <rguenther@suse.de> PR fortran/43829 * resolve.c (gfc_resolve_index): Wrap around ... (gfc_resolve_index_1): ... this. Add parameter to allow any integer kind index type. (resolve_array_ref): Allow any integer kind for the start index of an array ref. * gfortran.dg/vector_subscript_6.f90: New testcase. * gfortran.dg/assign_10.f90: Adjust. From-SVN: r158632
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog9
-rw-r--r--gcc/fortran/resolve.c21
-rw-r--r--gcc/fortran/trans-array.c1
3 files changed, 27 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 27dab6d..1c77717 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2010-04-22 Richard Guenther <rguenther@suse.de>
+
+ PR fortran/43829
+ * resolve.c (gfc_resolve_index): Wrap around ...
+ (gfc_resolve_index_1): ... this. Add parameter to allow
+ any integer kind index type.
+ (resolve_array_ref): Allow any integer kind for the start
+ index of an array ref.
+
2010-04-21 Jakub Jelinek <jakub@redhat.com>
PR fortran/43836
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index b13edf9..aeccffb 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -3978,8 +3978,9 @@ compare_spec_to_ref (gfc_array_ref *ar)
/* Resolve one part of an array index. */
-gfc_try
-gfc_resolve_index (gfc_expr *index, int check_scalar)
+static gfc_try
+gfc_resolve_index_1 (gfc_expr *index, int check_scalar,
+ int force_index_integer_kind)
{
gfc_typespec ts;
@@ -4007,7 +4008,8 @@ gfc_resolve_index (gfc_expr *index, int check_scalar)
&index->where) == FAILURE)
return FAILURE;
- if (index->ts.kind != gfc_index_integer_kind
+ if ((index->ts.kind != gfc_index_integer_kind
+ && force_index_integer_kind)
|| index->ts.type != BT_INTEGER)
{
gfc_clear_ts (&ts);
@@ -4020,6 +4022,14 @@ gfc_resolve_index (gfc_expr *index, int check_scalar)
return SUCCESS;
}
+/* Resolve one part of an array index. */
+
+gfc_try
+gfc_resolve_index (gfc_expr *index, int check_scalar)
+{
+ return gfc_resolve_index_1 (index, check_scalar, 1);
+}
+
/* Resolve a dim argument to an intrinsic function. */
gfc_try
@@ -4144,7 +4154,10 @@ resolve_array_ref (gfc_array_ref *ar)
{
check_scalar = ar->dimen_type[i] == DIMEN_RANGE;
- if (gfc_resolve_index (ar->start[i], check_scalar) == FAILURE)
+ /* Do not force gfc_index_integer_kind for the start. We can
+ do fine with any integer kind. This avoids temporary arrays
+ created for indexing with a vector. */
+ if (gfc_resolve_index_1 (ar->start[i], check_scalar, 0) == FAILURE)
return FAILURE;
if (gfc_resolve_index (ar->end[i], check_scalar) == FAILURE)
return FAILURE;
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index b03cc94..199eb23 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -2434,6 +2434,7 @@ gfc_conv_array_index_offset (gfc_se * se, gfc_ss_info * info, int dim, int i,
gfc_conv_array_data (desc));
index = gfc_build_array_ref (data, index, NULL);
index = gfc_evaluate_now (index, &se->pre);
+ index = fold_convert (gfc_array_index_type, index);
/* Do any bounds checking on the final info->descriptor index. */
index = gfc_trans_array_bound_check (se, info->descriptor,