summaryrefslogtreecommitdiff
path: root/libgfortran/generated/reshape_r10.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/generated/reshape_r10.c')
-rw-r--r--libgfortran/generated/reshape_r10.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/libgfortran/generated/reshape_r10.c b/libgfortran/generated/reshape_r10.c
index 5069e45cdb1..c3d414320ad 100644
--- a/libgfortran/generated/reshape_r10.c
+++ b/libgfortran/generated/reshape_r10.c
@@ -37,8 +37,6 @@ Boston, MA 02110-1301, USA. */
typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
-/* The shape parameter is ignored. We can currently deduce the shape from the
- return array. */
extern void reshape_r10 (gfc_array_r10 * const restrict,
gfc_array_r10 * const restrict,
@@ -83,12 +81,13 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
const GFC_REAL_10 *src;
int n;
int dim;
+ int sempty, pempty;
if (ret->data == NULL)
{
rdim = shape->dim[0].ubound - shape->dim[0].lbound + 1;
rs = 1;
- for (n=0; n < rdim; n++)
+ for (n = 0; n < rdim; n++)
{
ret->dim[n].lbound = 0;
rex = shape->data[n * shape->dim[0].stride];
@@ -130,13 +129,17 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
sdim = GFC_DESCRIPTOR_RANK (source);
ssize = 1;
+ sempty = 0;
for (n = 0; n < sdim; n++)
{
scount[n] = 0;
sstride[n] = source->dim[n].stride;
sextent[n] = source->dim[n].ubound + 1 - source->dim[n].lbound;
if (sextent[n] <= 0)
- abort ();
+ {
+ sempty = 1;
+ sextent[n] = 0;
+ }
if (ssize == sstride[n])
ssize *= sextent[n];
@@ -148,13 +151,18 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
{
pdim = GFC_DESCRIPTOR_RANK (pad);
psize = 1;
+ pempty = 0;
for (n = 0; n < pdim; n++)
{
pcount[n] = 0;
pstride[n] = pad->dim[n].stride;
pextent[n] = pad->dim[n].ubound + 1 - pad->dim[n].lbound;
if (pextent[n] <= 0)
- abort ();
+ {
+ pempty = 1;
+ pextent[n] = 0;
+ }
+
if (psize == pstride[n])
psize *= pextent[n];
else
@@ -166,6 +174,7 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
{
pdim = 0;
psize = 1;
+ pempty = 1;
pptr = NULL;
}
@@ -183,6 +192,24 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
rstride0 = rstride[0];
sstride0 = sstride[0];
+ if (sempty && pempty)
+ abort ();
+
+ if (sempty)
+ {
+ /* Switch immediately to the pad array. */
+ src = pptr;
+ sptr = NULL;
+ sdim = pdim;
+ for (dim = 0; dim < pdim; dim++)
+ {
+ scount[dim] = pcount[dim];
+ sextent[dim] = pextent[dim];
+ sstride[dim] = pstride[dim];
+ sstride0 = sstride[0] * sizeof (GFC_REAL_10);
+ }
+ }
+
while (rptr)
{
/* Select between the source and pad arrays. */
@@ -192,6 +219,7 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
src += sstride0;
rcount[0]++;
scount[0]++;
+
/* Advance to the next destination element. */
n = 0;
while (rcount[n] == rextent[n])