PR fortran/44235
* array.c (gfc_ref_dimen_size): Add end argument.
If end is non-NULL, calculate it.
(ref_size): Adjust call to gfc_ref_dimen_size.
(gfc_array_dimen_size): Likewise.
(gfc_array_res_shape): Likewise.
* gfortran.h: Adjust prototype for gfc_ref_dimen_size.
* resolve.c (resolve_array_ref): For stride not equal to -1,
fill in the lowest possible end.
2010-08-09 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/44235
* gfortran.dg/dependency_32.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163041
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-08-09 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/44235
+ * array.c (gfc_ref_dimen_size): Add end argument.
+ If end is non-NULL, calculate it.
+ (ref_size): Adjust call to gfc_ref_dimen_size.
+ (gfc_array_dimen_size): Likewise.
+ (gfc_array_res_shape): Likewise.
+ * gfortran.h: Adjust prototype for gfc_ref_dimen_size.
+ * resolve.c (resolve_array_ref): For stride not equal to -1,
+ fill in the lowest possible end.
+
2010-08-09 Janus Weil <janus@gcc.gnu.org>
* intrinsic.texi: Correct documentation of ASINH, ACOSH and ATANH.
}
-/* Get the number of elements in an array section. */
+/* Get the number of elements in an array section. Optionally, also supply
+ the end value. */
gfc_try
-gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result)
+gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result, mpz_t *end)
{
mpz_t upper, lower, stride;
gfc_try t;
mpz_set_ui (*result, 0);
t = SUCCESS;
+ if (end)
+ {
+ mpz_init (*end);
+
+ mpz_sub_ui (*end, *result, 1UL);
+ mpz_mul (*end, *end, stride);
+ mpz_add (*end, *end, lower);
+ }
+
cleanup:
mpz_clear (upper);
mpz_clear (lower);
for (d = 0; d < ar->dimen; d++)
{
- if (gfc_ref_dimen_size (ar, d, &size) == FAILURE)
+ if (gfc_ref_dimen_size (ar, d, &size, NULL) == FAILURE)
{
mpz_clear (*result);
return FAILURE;
if (ref->u.ar.dimen_type[i] != DIMEN_ELEMENT)
dimen--;
- return gfc_ref_dimen_size (&ref->u.ar, i - 1, result);
+ return gfc_ref_dimen_size (&ref->u.ar, i - 1, result, NULL);
}
}
{
if (ar->dimen_type[i] != DIMEN_ELEMENT)
{
- if (gfc_ref_dimen_size (ar, i, &shape[d]) == FAILURE)
+ if (gfc_ref_dimen_size (ar, i, &shape[d], NULL) == FAILURE)
goto cleanup;
d++;
}
gfc_try spec_dimen_size (gfc_array_spec *, int, mpz_t *);
int gfc_is_compile_time_shape (gfc_array_spec *);
-gfc_try gfc_ref_dimen_size (gfc_array_ref *, int dimen, mpz_t *);
+gfc_try gfc_ref_dimen_size (gfc_array_ref *, int dimen, mpz_t *, mpz_t *);
/* interface.c -- FIXME: some of these should be in symbol.c */
&ar->c_where[i], e->rank);
return FAILURE;
}
+
+ /* Fill in the upper bound, which may be lower than the
+ specified one for something like a(2:10:5), which is
+ identical to a(2:7:5). Only relevant for strides not equal
+ to one. */
+ if (ar->dimen_type[i] == DIMEN_RANGE
+ && ar->stride[i] != NULL && ar->stride[i]->expr_type == EXPR_CONSTANT
+ && mpz_cmp_si (ar->stride[i]->value.integer, 1L) != 0)
+ {
+ mpz_t size, end;
+
+ if (gfc_ref_dimen_size (ar, i, &size, &end) == SUCCESS)
+ {
+ if (ar->end[i] == NULL)
+ {
+ ar->end[i] =
+ gfc_get_constant_expr (BT_INTEGER, gfc_index_integer_kind,
+ &ar->where);
+ mpz_set (ar->end[i]->value.integer, end);
+ }
+ else if (ar->end[i]->ts.type == BT_INTEGER
+ && ar->end[i]->expr_type == EXPR_CONSTANT)
+ {
+ mpz_set (ar->end[i]->value.integer, end);
+ }
+ else
+ gcc_unreachable ();
+
+ mpz_clear (size);
+ mpz_clear (end);
+ }
+ }
}
if (ar->type == AR_FULL && ar->as->rank == 0)
{
if (upper)
{
- if (gfc_ref_dimen_size (&ref->u.ar, d-1, &result->value.integer)
+ if (gfc_ref_dimen_size (&ref->u.ar, d-1, &result->value.integer, NULL)
!= SUCCESS)
goto returnNull;
}
+2010-08-09 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/44235
+ * gfortran.dg/dependency_32.f90: New test.
+
2010-08-09 Richard Guenther <rguenther@suse.de>
PR middle-end/44632
--- /dev/null
+! { dg-do compile }
+! { dg-options "-Warray-temporaries" }
+! PR 44235
+! No temporary should be created for this, as the upper bounds
+! are effectively identical.
+program main
+ real a(10)
+ a = 0.
+ a(1:10:4) = a(1:9:4)
+end program main