From: Paul Thomas Date: Sun, 10 Sep 2006 04:53:18 +0000 (+0000) Subject: re PR fortran/28914 (Code inside loop hangs; outside loop runs normally; runs OK... X-Git-Tag: releases/gcc-4.2.0~1472 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bfa7a1e994988ef5827505e0e7540b810150f984;p=thirdparty%2Fgcc.git re PR fortran/28914 (Code inside loop hangs; outside loop runs normally; runs OK on other compilers) 2006-09-09 Paul Thomas PR fortran/28914 * trans-array.c (gfc_trans_array_constructor_value): Create a temporary loop variable to hold the current loop variable in case it is modified by the array constructor. From-SVN: r116808 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a80892600a8e..6fbec9372922 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2006-09-09 Paul Thomas + + PR fortran/28914 + * trans-array.c (gfc_trans_array_constructor_value): Create a temporary + loop variable to hold the current loop variable in case it is modified + by the array constructor. + 2006-09-07 Steven G. Kargl * gfortran.h (gfc_integer_info): Eliminate max_int. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index a976cb909318..bf8e6879dba3 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -1252,6 +1252,7 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, tree exit_label; tree loopbody; tree tmp2; + tree tmp_loopvar; loopbody = gfc_finish_block (&body); @@ -1260,6 +1261,11 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, gfc_add_block_to_block (pblock, &se.pre); loopvar = se.expr; + /* Make a temporary, store the current value in that + and return it, once the loop is done. */ + tmp_loopvar = gfc_create_var (TREE_TYPE (loopvar), "loopvar"); + gfc_add_modify_expr (pblock, tmp_loopvar, loopvar); + /* Initialize the loop. */ gfc_init_se (&se, NULL); gfc_conv_expr_val (&se, c->iterator->start); @@ -1327,6 +1333,9 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, /* Add the exit label. */ tmp = build1_v (LABEL_EXPR, exit_label); gfc_add_expr_to_block (pblock, tmp); + + /* Restore the original value of the loop counter. */ + gfc_add_modify_expr (pblock, loopvar, tmp_loopvar); } } mpz_clear (size);