+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
/* 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;
&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);
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
{
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;
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,
+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
if (any(p8 .ne. q8)) call abort ()
end
! Whichever is the default length for array indices will yield
-! parm 9 times, because a temporary is not necessary. The other
-! cases will all yield a temporary, so that atmp appears 27 times.
+! parm 18 times, because a temporary is not necessary. The other
+! cases will all yield a temporary, so that atmp appears 18 times.
! Note that it is the kind conversion that generates the temp.
!
-! { dg-final { scan-tree-dump-times "parm" 9 "original" } }
-! { dg-final { scan-tree-dump-times "atmp" 27 "original" } }
+! { dg-final { scan-tree-dump-times "parm" 18 "original" } }
+! { dg-final { scan-tree-dump-times "atmp" 18 "original" } }
! { dg-final { cleanup-tree-dump "original" } }
--- /dev/null
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+
+subroutine test0(esss,Ix, e_x)
+ real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss
+ real(kind=kind(1.0d0)), dimension(:), intent(in) :: Ix
+ integer(kind=kind(1)), dimension(:), intent(in) :: e_x
+ esss = Ix(e_x)
+end subroutine
+
+subroutine test1(esss,Ix, e_x)
+ real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss
+ real(kind=kind(1.0d0)), dimension(:), intent(in) :: Ix
+ integer(kind=4), dimension(:), intent(in) :: e_x
+ esss = Ix(e_x)
+end subroutine
+
+subroutine test2(esss,Ix, e_x)
+ real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss
+ real(kind=kind(1.0d0)), dimension(:), intent(in) :: Ix
+ integer(kind=8), dimension(:), intent(in) :: e_x
+ esss = Ix(e_x)
+end subroutine
+
+subroutine test3(esss,Ix,Iyz, e_x, ii_ivec)
+ real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss
+ real(kind=kind(1.0d0)), dimension(:), intent(in) :: Ix,Iyz
+ integer(kind=kind(1)), dimension(:), intent(in) :: e_x,ii_ivec
+ esss = esss + Ix(e_x) * Iyz(ii_ivec)
+end subroutine
+
+! { dg-final { scan-tree-dump-not "malloc" "original" } }
+! { dg-final { cleanup-tree-dump "original" } }