diff options
author | Mikael Morin <mikael.morin@tele2.fr> | 2008-12-09 20:20:18 +0100 |
---|---|---|
committer | Mikael Morin <mikael@gcc.gnu.org> | 2008-12-09 19:20:18 +0000 |
commit | 138b3340e66b3e030d30bfbbeb30b9a10f4677c0 (patch) | |
tree | 772db53e97ac15092efa5a199e22ce3096439b2c /gcc | |
parent | fe7a047c75f5a96456ea750a9f91ff41786a23e9 (diff) | |
download | gcc-138b3340e66b3e030d30bfbbeb30b9a10f4677c0.zip gcc-138b3340e66b3e030d30bfbbeb30b9a10f4677c0.tar.gz gcc-138b3340e66b3e030d30bfbbeb30b9a10f4677c0.tar.bz2 |
re PR fortran/37469 (invalid GMP usage on gfortran.dg/parameter_array_init_3.f90)
2008-12-09 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/37469
* expr.c (find_array_element): Simplify array bounds.
Assert that both bounds are constant expressions.
From-SVN: r142606
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 17 |
2 files changed, 19 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a46e79a..5c71e8f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 2008-12-09 Mikael Morin <mikael.morin@tele2.fr> + PR fortran/37469 + * expr.c (find_array_element): Simplify array bounds. + Assert that both bounds are constant expressions. + +2008-12-09 Mikael Morin <mikael.morin@tele2.fr> + PR fortran/35983 * trans-expr.c (gfc_trans_subcomponent_assign): Add se's pre and post blocks to current block. diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 07dfc7a..4bdee7c 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1028,6 +1028,14 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar, mpz_init_set_ui (span, 1); for (i = 0; i < ar->dimen; i++) { + if (gfc_reduce_init_expr (ar->as->lower[i]) == FAILURE + || gfc_reduce_init_expr (ar->as->upper[i]) == FAILURE) + { + t = FAILURE; + cons = NULL; + goto depart; + } + e = gfc_copy_expr (ar->start[i]); if (e->expr_type != EXPR_CONSTANT) { @@ -1035,14 +1043,15 @@ find_array_element (gfc_constructor *cons, gfc_array_ref *ar, goto depart; } + gcc_assert (ar->as->upper[i]->expr_type == EXPR_CONSTANT + && ar->as->lower[i]->expr_type == EXPR_CONSTANT); + /* Check the bounds. */ if ((ar->as->upper[i] - && ar->as->upper[i]->expr_type == EXPR_CONSTANT && mpz_cmp (e->value.integer, ar->as->upper[i]->value.integer) > 0) - || (ar->as->lower[i]->expr_type == EXPR_CONSTANT - && mpz_cmp (e->value.integer, - ar->as->lower[i]->value.integer) < 0)) + || (mpz_cmp (e->value.integer, + ar->as->lower[i]->value.integer) < 0)) { gfc_error ("Index in dimension %d is out of bounds " "at %L", i + 1, &ar->c_where[i]); |