diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-21 19:54:01 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-21 19:54:01 +0000 |
commit | c3d22aafe2ea6e541c10236456731e16d71e05f5 (patch) | |
tree | 572d0ae3c24e3be1bc0c147e731c9efac7d01182 /libgfortran/generated/reshape_c10.c | |
parent | 89c21b2fa07ccaeefcd9f13f1b0674f7881b79c4 (diff) | |
download | gcc-c3d22aafe2ea6e541c10236456731e16d71e05f5.tar.gz |
2008-04-21 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r134525
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@134526 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/generated/reshape_c10.c')
-rw-r--r-- | libgfortran/generated/reshape_c10.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/libgfortran/generated/reshape_c10.c b/libgfortran/generated/reshape_c10.c index b9eb754481a..28cad4a0b6e 100644 --- a/libgfortran/generated/reshape_c10.c +++ b/libgfortran/generated/reshape_c10.c @@ -81,16 +81,32 @@ reshape_c10 (gfc_array_c10 * const restrict ret, const GFC_COMPLEX_10 *src; int n; int dim; - int sempty, pempty; + int sempty, pempty, shape_empty; + index_type shape_data[GFC_MAX_DIMENSIONS]; + + rdim = shape->dim[0].ubound - shape->dim[0].lbound + 1; + if (rdim != GFC_DESCRIPTOR_RANK(ret)) + runtime_error("rank of return array incorrect in RESHAPE intrinsic"); + + shape_empty = 0; + + for (n = 0; n < rdim; n++) + { + shape_data[n] = shape->data[n * shape->dim[0].stride]; + if (shape_data[n] <= 0) + { + shape_data[n] = 0; + shape_empty = 1; + } + } if (ret->data == NULL) { - rdim = shape->dim[0].ubound - shape->dim[0].lbound + 1; rs = 1; for (n = 0; n < rdim; n++) { ret->dim[n].lbound = 0; - rex = shape->data[n * shape->dim[0].stride]; + rex = shape_data[n]; ret->dim[n].ubound = rex - 1; ret->dim[n].stride = rs; rs *= rex; @@ -99,10 +115,9 @@ reshape_c10 (gfc_array_c10 * const restrict ret, ret->data = internal_malloc_size ( rs * sizeof (GFC_COMPLEX_10)); ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim; } - else - { - rdim = GFC_DESCRIPTOR_RANK (ret); - } + + if (shape_empty) + return; rsize = 1; for (n = 0; n < rdim; n++) @@ -115,8 +130,10 @@ reshape_c10 (gfc_array_c10 * const restrict ret, rcount[n] = 0; rstride[n] = ret->dim[dim].stride; rextent[n] = ret->dim[dim].ubound + 1 - ret->dim[dim].lbound; + if (rextent[n] < 0) + rextent[n] == 0; - if (rextent[n] != shape->data[dim * shape->dim[0].stride]) + if (rextent[n] != shape_data[dim]) runtime_error ("shape and target do not conform"); if (rsize == rstride[n]) |