diff options
author | Victor Leikehman <lei@il.ibm.com> | 2004-08-08 12:28:25 +0000 |
---|---|---|
committer | Paul Brook <pbrook@gcc.gnu.org> | 2004-08-08 12:28:25 +0000 |
commit | 94538bd12ae8ffa02164399a616ef806e77f797b (patch) | |
tree | 9f3bff0e67ca9e26d25d40bbb89175a03d998121 /gcc/fortran/expr.c | |
parent | 352a77c8dc72715bbe230e04cd72583d5a900291 (diff) | |
download | gcc-94538bd12ae8ffa02164399a616ef806e77f797b.zip gcc-94538bd12ae8ffa02164399a616ef806e77f797b.tar.gz gcc-94538bd12ae8ffa02164399a616ef806e77f797b.tar.bz2 |
simplify.c (gfc_simplify_shape): Bugfix.
2004-08-08 Victor Leikehman <lei@il.ibm.com>
* simplify.c (gfc_simplify_shape): Bugfix.
* expr.c (gfc_copy_shape_excluding): New function.
* gfortran.h (gfc_get_shape): Bugfix.
(gfc_copy_shape_excluding): Added declaration.
* iresolve.c (gfc_resolve_all, gfc_resolve_any, gfc_resolve_count,
gfc_resolve_cshift, gfc_resolve_eoshift, gfc_resolve_lbound,
gfc_resolve_ubound, gfc_resolve_transpose): Added compile
time resolution of shape.
From-SVN: r85685
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index adff08e..99db76d 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -330,6 +330,50 @@ gfc_copy_shape (mpz_t * shape, int rank) } +/* Copy a shape array excluding dimension N, where N is an integer + constant expression. Dimensions are numbered in fortran style -- + starting with ONE. + + So, if the original shape array contains R elements + { s1 ... sN-1 sN sN+1 ... sR-1 sR} + the result contains R-1 elements: + { s1 ... sN-1 sN+1 ... sR-1} + + If anything goes wrong -- N is not a constant, its value is out + of range -- or anything else, just returns NULL. +*/ + +mpz_t * +gfc_copy_shape_excluding (mpz_t * shape, int rank, gfc_expr * dim) +{ + mpz_t *new_shape, *s; + int i, n; + + if (shape == NULL + || rank <= 1 + || dim == NULL + || dim->expr_type != EXPR_CONSTANT + || dim->ts.type != BT_INTEGER) + return NULL; + + n = mpz_get_si (dim->value.integer); + n--; /* Convert to zero based index */ + if (n < 0 && n >= rank) + return NULL; + + s = new_shape = gfc_get_shape (rank-1); + + for (i = 0; i < rank; i++) + { + if (i == n) + continue; + mpz_init_set (*s, shape[i]); + s++; + } + + return new_shape; +} + /* Given an expression pointer, return a copy of the expression. This subroutine is recursive. */ |