diff options
author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-14 23:59:00 +0000 |
---|---|---|
committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-07-14 23:59:00 +0000 |
commit | 32f03745d2d62b11430efda3aad5e441eceb9a6e (patch) | |
tree | 2c7ec1151f8d0b27f09195b5c55c57e8ba9c9a34 /gcc/fortran/trans-array.c | |
parent | 4ccd5f95f19d90935dbb048430cbc0b1fc75203f (diff) | |
download | gcc-32f03745d2d62b11430efda3aad5e441eceb9a6e.tar.gz |
PR fortran/32036
* trans-array.c (gfc_conv_array_ref): Only evaluate index once.
* gfortran.dg/bounds_check_8.f90: New test.
* gfortran.dg/do_iterator_2.f90: Make code legal Fortran.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126647 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 8a2365813ba..16f95777ee7 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2278,6 +2278,9 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, gfc_symbol * sym, tree cond; char *msg; + /* Evaluate the indexse.expr only once. */ + indexse.expr = save_expr (indexse.expr); + /* Lower bound. */ tmp = gfc_conv_array_lbound (se->expr, n); cond = fold_build2 (LT_EXPR, boolean_type_node, |