summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-stmt.c
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2007-05-21 22:02:26 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2007-05-21 22:02:26 +0000
commit92a4c76352df940c1e3aa9bd0f6bee004d604e64 (patch)
treec08086a86a965927acdec1f1d221c9d3afc7c69d /gcc/fortran/trans-stmt.c
parenta205ddf73004a62ecc1db036077da83e117d404e (diff)
downloadgcc-92a4c76352df940c1e3aa9bd0f6bee004d604e64.tar.gz
PR fortran/32027
* trans-stmt.c (gfc_trans_do): Fix the value of loop variable when the loop ends. * gfortran.dg/do_3.F90: Add checks for the final value of the loop variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124923 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-stmt.c')
-rw-r--r--gcc/fortran/trans-stmt.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 02e8dd26b84..444d880964f 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -947,6 +947,10 @@ gfc_trans_do (gfc_code * code)
gfc_add_expr_to_block (&body, tmp);
}
+ /* Increment the loop variable. */
+ tmp = build2 (PLUS_EXPR, type, dovar, step);
+ gfc_add_modify_expr (&body, dovar, tmp);
+
/* End with the loop condition. Loop until countm1 == 0. */
cond = fold_build2 (EQ_EXPR, boolean_type_node, countm1,
build_int_cst (utype, 0));
@@ -955,10 +959,6 @@ gfc_trans_do (gfc_code * code)
cond, tmp, build_empty_stmt ());
gfc_add_expr_to_block (&body, tmp);
- /* Increment the loop variable. */
- tmp = build2 (PLUS_EXPR, type, dovar, step);
- gfc_add_modify_expr (&body, dovar, tmp);
-
/* Decrement the loop count. */
tmp = build2 (MINUS_EXPR, utype, countm1, build_int_cst (utype, 1));
gfc_add_modify_expr (&body, countm1, tmp);