OSDN Git Service

2010-04-22 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Apr 2010 08:34:41 +0000 (08:34 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 04:38:52 +0000 (13:38 +0900)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158632 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/fortran/trans-array.c
gcc/testsuite/ChangeLog

index 27dab6d..1c77717 100644 (file)
@@ -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
index b13edf9..aeccffb 100644 (file)
@@ -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;
index b03cc94..199eb23 100644 (file)
@@ -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,
index 2e6da4e..74480cb 100644 (file)
@@ -1,3 +1,9 @@
+2010-04-22  Richard Guenther  <rguenther@suse.de>
+
+       PR fortran/43829
+       * gfortran.dg/vector_subscript_6.f90: New testcase.
+       * gfortran.dg/assign_10.f90: Adjust.
+
 2010-04-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/43836