+2008-05-14 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/35682
+ * trans-array.c (gfc_conv_ss_startstride): Any negative size is
+ the same as zero size.
+ (gfc_conv_loop_setup): Fix size calculation.
+
2008-05-14 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/35685
info->start[n]);
tmp = fold_build2 (FLOOR_DIV_EXPR, gfc_array_index_type, tmp,
info->stride[n]);
+ tmp = fold_build2 (MAX_EXPR, gfc_array_index_type, tmp,
+ build_int_cst (gfc_array_index_type, 0));
/* We remember the size of the first section, and check all the
others against this. */
if (size[n])
for (i = 0; i<=last; i++){...}; */
tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
loop->to[n], loop->from[n]);
- tmp = fold_build2 (TRUNC_DIV_EXPR, gfc_array_index_type,
+ tmp = fold_build2 (FLOOR_DIV_EXPR, gfc_array_index_type,
tmp, info->stride[n]);
+ tmp = fold_build2 (MAX_EXPR, gfc_array_index_type, tmp,
+ build_int_cst (gfc_array_index_type, -1));
loop->to[n] = gfc_evaluate_now (tmp, &loop->pre);
/* Make the loop variable start at 0. */
loop->from[n] = gfc_index_zero_node;
+2008-05-14 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/35682
+ * gfortran.dg/bound_4.f90: New test.
+ * gfortran.dg/bounds_check_14.f90: New test.
+
2008-05-14 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/35685
--- /dev/null
+! { dg-do run }
+
+program test
+ integer x(20)
+ integer, volatile :: n
+ n = 1
+ if (size(x(n:2:-3)) /= 0) call abort
+
+ call ha0020(-3)
+ call ha0020(-1)
+end program test
+
+subroutine ha0020(mf3)
+ implicit none
+ integer xca(1), xda(1), mf3
+
+ xca = 1
+ xda = -1
+
+ xca(1:1) = xda(1:2:mf3)
+
+ if (any (xca /= -1)) call abort
+ if (any(xda(1:2:mf3) /= xda(1:0))) call abort
+ if (size(xda(1:2:mf3)) /= 0) call abort
+ if (any(shape(xda(1:2:mf3)) /= 0)) call abort
+ if (any(ubound(xda(1:2:mf3)) /= 0)) call abort
+ if (ubound(xda(1:2:mf3),1) /= 0) call abort
+ if (lbound(xda(1:2:mf3),1) /= 1) call abort
+
+end subroutine
--- /dev/null
+! { dg-do run }
+! { dg-options "-fbounds-check" }
+
+program test
+ integer x(20)
+ integer, volatile :: n
+ n = 1
+ if (size(x(n:2:-3)) /= 0) call abort
+
+ call ha0020(-3)
+ call ha0020(-1)
+end program test
+
+subroutine ha0020(mf3)
+ implicit none
+ integer xca(1), xda(1), mf3
+
+ xca = 1
+ xda = -1
+
+ xca(1:1) = xda(1:2:mf3)
+
+ if (any (xca /= -1)) call abort
+ if (any(xda(1:2:mf3) /= xda(1:0))) call abort
+ if (size(xda(1:2:mf3)) /= 0) call abort
+ if (any(shape(xda(1:2:mf3)) /= 0)) call abort
+ if (any(ubound(xda(1:2:mf3)) /= 0)) call abort
+ if (ubound(xda(1:2:mf3),1) /= 0) call abort
+ if (lbound(xda(1:2:mf3),1) /= 1) call abort
+
+end subroutine