summaryrefslogtreecommitdiff
path: root/libgfortran/generated/reshape_i4.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/generated/reshape_i4.c')
-rw-r--r--libgfortran/generated/reshape_i4.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/libgfortran/generated/reshape_i4.c b/libgfortran/generated/reshape_i4.c
index fbe16f293a5..b90e56caf4e 100644
--- a/libgfortran/generated/reshape_i4.c
+++ b/libgfortran/generated/reshape_i4.c
@@ -53,6 +53,8 @@ reshape_4 (gfc_array_i4 * ret, gfc_array_i4 * source, shape_type * shape,
index_type rstride0;
index_type rdim;
index_type rsize;
+ index_type rs;
+ index_type rex;
GFC_INTEGER_4 *rptr;
/* s.* indicates the source array. */
index_type scount[GFC_MAX_DIMENSIONS];
@@ -74,8 +76,6 @@ reshape_4 (gfc_array_i4 * ret, gfc_array_i4 * source, shape_type * shape,
int n;
int dim;
- if (ret->dim[0].stride == 0)
- ret->dim[0].stride = 1;
if (source->dim[0].stride == 0)
source->dim[0].stride = 1;
if (shape->dim[0].stride == 0)
@@ -85,7 +85,29 @@ reshape_4 (gfc_array_i4 * ret, gfc_array_i4 * source, shape_type * shape,
if (order && order->dim[0].stride == 0)
order->dim[0].stride = 1;
- rdim = GFC_DESCRIPTOR_RANK (ret);
+ 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];
+ ret->dim[n].ubound = rex - 1;
+ ret->dim[n].stride = rs;
+ rs *= rex;
+ }
+ ret->base = 0;
+ ret->data = internal_malloc_size ( rs * sizeof (GFC_INTEGER_4));
+ ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+ }
+ else
+ {
+ rdim = GFC_DESCRIPTOR_RANK (ret);
+ if (ret->dim[0].stride == 0)
+ ret->dim[0].stride = 1;
+ }
+
rsize = 1;
for (n = 0; n < rdim; n++)
{
@@ -105,7 +127,7 @@ reshape_4 (gfc_array_i4 * ret, gfc_array_i4 * source, shape_type * shape,
rsize *= rextent[n];
else
rsize = 0;
- if (rextent[dim] <= 0)
+ if (rextent[n] <= 0)
return;
}
@@ -127,8 +149,6 @@ reshape_4 (gfc_array_i4 * ret, gfc_array_i4 * source, shape_type * shape,
if (pad)
{
- if (pad->dim[0].stride == 0)
- pad->dim[0].stride = 1;
pdim = GFC_DESCRIPTOR_RANK (pad);
psize = 1;
for (n = 0; n < pdim; n++)