diff options
author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-14 21:20:10 +0000 |
---|---|---|
committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-14 21:20:10 +0000 |
commit | 356056cf069bd1f51b6514b302a0caa17ba4050d (patch) | |
tree | 1c3a56e6dca368522831f733c93f7761f0f54c3f /gcc/fortran/trans-array.c | |
parent | 03910013722cc2e6a1f4cff40a78f5789051315b (diff) | |
download | gcc-356056cf069bd1f51b6514b302a0caa17ba4050d.tar.gz |
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.
* gfortran.dg/bound_4.f90: New test.
* gfortran.dg/bounds_check_14.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135306 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 5fc56883bc9..3c099ddcc9d 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -3083,6 +3083,8 @@ gfc_conv_ss_startstride (gfc_loopinfo * loop) 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]) @@ -3435,8 +3437,10 @@ gfc_conv_loop_setup (gfc_loopinfo * loop) 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; |