diff options
author | Nicolas Koenig <koenigni@student.ethz.ch> | 2017-05-14 01:38:36 +0200 |
---|---|---|
committer | Nicolas Koenig <koenigni@gcc.gnu.org> | 2017-05-13 23:38:36 +0000 |
commit | 28ae01cd23d05ce79307db054782e576ab01f3b7 (patch) | |
tree | 3ca978cfd162f79396bf4315f9080c971680cedb /gcc/fortran/data.c | |
parent | 364490206eaee4e4da9f66e63169cc0c0ddfe40e (diff) | |
download | gcc-28ae01cd23d05ce79307db054782e576ab01f3b7.zip gcc-28ae01cd23d05ce79307db054782e576ab01f3b7.tar.gz gcc-28ae01cd23d05ce79307db054782e576ab01f3b7.tar.bz2 |
re PR fortran/80442 (Rejects DATA statement with array slice)
2017-05-09 Nicolas Koenig <koenigni@student.ethz.ch>
PR fortran/80442
* array.c (gfc_ref_dimen_size): Simplify stride
expression
* data.c (gfc_advance_section): Simplify start,
end and stride expressions
(gfc_advance_section): Simplify start and end
expressions
(gfc_get_section_index): Simplify start expression
2017-05-09 Nicolas Koenig <koenigni@student.ethz.ch>
PR fortran/80442
* gfortran.dg/impl_do_var_data.f90: New Test
From-SVN: r248012
Diffstat (limited to 'gcc/fortran/data.c')
-rw-r--r-- | gcc/fortran/data.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c index 184e53d..587161f 100644 --- a/gcc/fortran/data.c +++ b/gcc/fortran/data.c @@ -539,6 +539,7 @@ gfc_advance_section (mpz_t *section_index, gfc_array_ref *ar, mpz_t tmp; bool forwards; int cmp; + gfc_expr *start, *end, *stride; for (i = 0; i < ar->dimen; i++) { @@ -547,12 +548,16 @@ gfc_advance_section (mpz_t *section_index, gfc_array_ref *ar, if (ar->stride[i]) { + stride = gfc_copy_expr(ar->stride[i]); + if(!gfc_simplify_expr(stride, 1)) + gfc_internal_error("Simplification error"); mpz_add (section_index[i], section_index[i], - ar->stride[i]->value.integer); - if (mpz_cmp_si (ar->stride[i]->value.integer, 0) >= 0) - forwards = true; - else - forwards = false; + stride->value.integer); + if (mpz_cmp_si (stride->value.integer, 0) >= 0) + forwards = true; + else + forwards = false; + gfc_free_expr(stride); } else { @@ -561,7 +566,13 @@ gfc_advance_section (mpz_t *section_index, gfc_array_ref *ar, } if (ar->end[i]) - cmp = mpz_cmp (section_index[i], ar->end[i]->value.integer); + { + end = gfc_copy_expr(ar->end[i]); + if(!gfc_simplify_expr(end, 1)) + gfc_internal_error("Simplification error"); + cmp = mpz_cmp (section_index[i], end->value.integer); + gfc_free_expr(end); + } else cmp = mpz_cmp (section_index[i], ar->as->upper[i]->value.integer); @@ -569,7 +580,13 @@ gfc_advance_section (mpz_t *section_index, gfc_array_ref *ar, { /* Reset index to start, then loop to advance the next index. */ if (ar->start[i]) - mpz_set (section_index[i], ar->start[i]->value.integer); + { + start = gfc_copy_expr(ar->start[i]); + if(!gfc_simplify_expr(start, 1)) + gfc_internal_error("Simplification error"); + mpz_set (section_index[i], start->value.integer); + gfc_free_expr(start); + } else mpz_set (section_index[i], ar->as->lower[i]->value.integer); } @@ -679,6 +696,7 @@ gfc_get_section_index (gfc_array_ref *ar, mpz_t *section_index, mpz_t *offset) int i; mpz_t delta; mpz_t tmp; + gfc_expr *start; mpz_set_si (*offset, 0); mpz_init (tmp); @@ -692,11 +710,15 @@ gfc_get_section_index (gfc_array_ref *ar, mpz_t *section_index, mpz_t *offset) case DIMEN_RANGE: if (ar->start[i]) { - mpz_sub (tmp, ar->start[i]->value.integer, + start = gfc_copy_expr(ar->start[i]); + if(!gfc_simplify_expr(start, 1)) + gfc_internal_error("Simplification error"); + mpz_sub (tmp, start->value.integer, ar->as->lower[i]->value.integer); mpz_mul (tmp, tmp, delta); mpz_add (*offset, tmp, *offset); - mpz_set (section_index[i], ar->start[i]->value.integer); + mpz_set (section_index[i], start->value.integer); + gfc_free_expr(start); } else mpz_set (section_index[i], ar->as->lower[i]->value.integer); |