diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2008-02-05 13:33:35 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2008-02-05 13:33:35 +0000 |
commit | 52f5643130fe569c48beef68233e75d9db9b9eb7 (patch) | |
tree | b5d8b0e680f3ba23ddc5185887ed545c9bc188f3 /gcc/fortran/array.c | |
parent | 1db54f4e49894663db378fe462590f7a91ae75ec (diff) | |
download | gcc-52f5643130fe569c48beef68233e75d9db9b9eb7.zip gcc-52f5643130fe569c48beef68233e75d9db9b9eb7.tar.gz gcc-52f5643130fe569c48beef68233e75d9db9b9eb7.tar.bz2 |
re PR fortran/34945 (LBOUND fails for array with KIND(complex) used in zero-sized dimension)
2008-02-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34945
* array.c (match_array_element_spec): Remove check for negative
array size.
(gfc_resolve_array_spec): Add check for negative size.
2008-02-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34945
* gfortran.dg/bounds_check_13.f: New test.
From-SVN: r132121
Diffstat (limited to 'gcc/fortran/array.c')
-rw-r--r-- | gcc/fortran/array.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 0c30b33..75f80ed 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -250,6 +250,21 @@ gfc_resolve_array_spec (gfc_array_spec *as, int check_constant) e = as->upper[i]; if (resolve_array_bound (e, check_constant) == FAILURE) return FAILURE; + + if ((as->lower[i] == NULL) || (as->upper[i] == NULL)) + continue; + + /* If the size is negative in this dimension, set it to zero. */ + if (as->lower[i]->expr_type == EXPR_CONSTANT + && as->upper[i]->expr_type == EXPR_CONSTANT + && mpz_cmp (as->upper[i]->value.integer, + as->lower[i]->value.integer) < 0) + { + gfc_free_expr (as->upper[i]); + as->upper[i] = gfc_copy_expr (as->lower[i]); + mpz_sub_ui (as->upper[i]->value.integer, + as->upper[i]->value.integer, 1); + } } return SUCCESS; @@ -318,15 +333,6 @@ match_array_element_spec (gfc_array_spec *as) if (m == MATCH_NO) return AS_ASSUMED_SHAPE; - /* If the size is negative in this dimension, set it to zero. */ - if ((*lower)->expr_type == EXPR_CONSTANT - && (*upper)->expr_type == EXPR_CONSTANT - && mpz_cmp ((*upper)->value.integer, (*lower)->value.integer) < 0) - { - gfc_free_expr (*upper); - *upper = gfc_copy_expr (*lower); - mpz_sub_ui ((*upper)->value.integer, (*upper)->value.integer, 1); - } return AS_EXPLICIT; } |