diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2007-05-21 22:02:26 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2007-05-21 22:02:26 +0000 |
commit | 244974bd1bb1e486361d7b4ec6fe686239e2e1f1 (patch) | |
tree | c08086a86a965927acdec1f1d221c9d3afc7c69d /gcc/fortran | |
parent | 76dac339660714a2de931e371d89bc54a5cc9782 (diff) | |
download | gcc-244974bd1bb1e486361d7b4ec6fe686239e2e1f1.zip gcc-244974bd1bb1e486361d7b4ec6fe686239e2e1f1.tar.gz gcc-244974bd1bb1e486361d7b4ec6fe686239e2e1f1.tar.bz2 |
re PR fortran/32027 (The "DO" variable isn't consistent after loop)
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.
From-SVN: r124923
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-stmt.c | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 29dd7a3..ab99113 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-05-21 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + + PR fortran/32027 + * trans-stmt.c (gfc_trans_do): Fix the value of loop variable + when the loop ends. + 2007-05-21 H.J. Lu <hongjiu.lu@intel.com> * trans-stmt.c (gfc_trans_do): Fix a typo in comment. diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 02e8dd2..444d880 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); |