From e8300d6eaf5937e3cd56b41f620f4380a21dab97 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Fri, 26 May 2006 23:18:45 +0200 Subject: [PATCH] re PR libfortran/27524 (-fbounds-check interacts with array function) PR fortran/27524 * trans-array.c (gfc_trans_dummy_array_bias): Don't use stride as a temporary variable when -fbounds-check is enabled, since its value will be needed later. * gfortran.dg/bounds_check_1.f90: New test. From-SVN: r114142 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/trans-array.c | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/bounds_check_1.f90 | 12 ++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/bounds_check_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index eed3e0edf29..e4e2db25721 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2006-05-26 Francois-Xavier Coudert + + PR fortran/27524 + * trans-array.c (gfc_trans_dummy_array_bias): Don't use stride as + a temporary variable when -fbounds-check is enabled, since its + value will be needed later. + 2006-05-26 Thomas Koenig PR fortran/23151 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 32283a3df06..34742c3f702 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -3564,7 +3564,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) tree dumdesc; tree tmp; tree stmt; - tree stride; + tree stride, stride2; tree stmt_packed; tree stmt_unpacked; tree partial; @@ -3711,9 +3711,9 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, ubound, lbound); - stride = build2 (MINUS_EXPR, gfc_array_index_type, + stride2 = build2 (MINUS_EXPR, gfc_array_index_type, dubound, dlbound); - tmp = fold_build2 (NE_EXPR, gfc_array_index_type, tmp, stride); + tmp = fold_build2 (NE_EXPR, gfc_array_index_type, tmp, stride2); gfc_trans_runtime_check (tmp, gfc_strconst_bounds, &block); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e45fa3bc5b0..4910f76c3e6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-05-26 Francois-Xavier Coudert + + PR fortran/27524 + * gfortran.dg/bounds_check_1.f90: New test. + 2006-05-26 Ulrich Weigand PR rtl-optimization/27661 diff --git a/gcc/testsuite/gfortran.dg/bounds_check_1.f90 b/gcc/testsuite/gfortran.dg/bounds_check_1.f90 new file mode 100644 index 00000000000..c05f4456a11 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bounds_check_1.f90 @@ -0,0 +1,12 @@ +! { dg-do run } +! { dg-options "-fbounds-check" } +! PR fortran/27524 + integer :: res(1) + res = F() + if (res(1) /= 1) call abort + contains + function F() + integer :: F(1) + f = 1 + end function F + end -- 2.30.2