aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2011-06-28 18:59:04 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2011-06-28 18:59:04 +0000
commit19b76346c046b95ee4360a5c35d1e3a846aba6f4 (patch)
tree065be10e884faa1cf29e82bd342b95d03ee62f80 /libgfortran
parent6138f9bd8783881a1bd7dcfb917a3bfcefcf8cf9 (diff)
downloadgcc-19b76346c046b95ee4360a5c35d1e3a846aba6f4.zip
gcc-19b76346c046b95ee4360a5c35d1e3a846aba6f4.tar.gz
gcc-19b76346c046b95ee4360a5c35d1e3a846aba6f4.tar.bz2
re PR fortran/49479 (reshape / optionals / zero sized arrays)
2011-06-28 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/49479 * m4/reshape.m4: If source allocation is smaller than one, set it to one. * intrinsics/reshape_generic.c: Likewise. * generated/reshape_r16.c: Regenerated. * generated/reshape_c4.c: Regenerated. * generated/reshape_c16.c: Regenerated. * generated/reshape_c8.c: Regenerated. * generated/reshape_r4.c: Regenerated. * generated/reshape_i4.c: Regenerated. * generated/reshape_r10.c: Regenerated. * generated/reshape_r8.c: Regenerated. * generated/reshape_c10.c: Regenerated. * generated/reshape_i8.c: Regenerated. * generated/reshape_i16.c: Regenerated. 2011-06-28 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/49479 * gfortran.dg/reshape_zerosize_3.f90: New test. From-SVN: r175594
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog18
-rw-r--r--libgfortran/generated/reshape_c10.c10
-rw-r--r--libgfortran/generated/reshape_c16.c10
-rw-r--r--libgfortran/generated/reshape_c4.c10
-rw-r--r--libgfortran/generated/reshape_c8.c10
-rw-r--r--libgfortran/generated/reshape_i16.c10
-rw-r--r--libgfortran/generated/reshape_i4.c10
-rw-r--r--libgfortran/generated/reshape_i8.c10
-rw-r--r--libgfortran/generated/reshape_r10.c10
-rw-r--r--libgfortran/generated/reshape_r16.c10
-rw-r--r--libgfortran/generated/reshape_r4.c10
-rw-r--r--libgfortran/generated/reshape_r8.c10
-rw-r--r--libgfortran/intrinsics/reshape_generic.c11
-rw-r--r--libgfortran/m4/reshape.m410
14 files changed, 136 insertions, 13 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index b0f0666..88ee363 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,21 @@
+2011-06-28 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/49479
+ * m4/reshape.m4: If source allocation is smaller than one, set it
+ to one.
+ * intrinsics/reshape_generic.c: Likewise.
+ * generated/reshape_r16.c: Regenerated.
+ * generated/reshape_c4.c: Regenerated.
+ * generated/reshape_c16.c: Regenerated.
+ * generated/reshape_c8.c: Regenerated.
+ * generated/reshape_r4.c: Regenerated.
+ * generated/reshape_i4.c: Regenerated.
+ * generated/reshape_r10.c: Regenerated.
+ * generated/reshape_r8.c: Regenerated.
+ * generated/reshape_c10.c: Regenerated.
+ * generated/reshape_i8.c: Regenerated.
+ * generated/reshape_i16.c: Regenerated.
+
2011-06-18 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/49296
diff --git a/libgfortran/generated/reshape_c10.c b/libgfortran/generated/reshape_c10.c
index 34eff90..44446eb 100644
--- a/libgfortran/generated/reshape_c10.c
+++ b/libgfortran/generated/reshape_c10.c
@@ -97,6 +97,8 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_COMPLEX_10));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_COMPLEX_10);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_c16.c b/libgfortran/generated/reshape_c16.c
index 569b76ce..ca588dc 100644
--- a/libgfortran/generated/reshape_c16.c
+++ b/libgfortran/generated/reshape_c16.c
@@ -97,6 +97,8 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_COMPLEX_16));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_COMPLEX_16);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_c4.c b/libgfortran/generated/reshape_c4.c
index c8b7355..e16d32c 100644
--- a/libgfortran/generated/reshape_c4.c
+++ b/libgfortran/generated/reshape_c4.c
@@ -97,6 +97,8 @@ reshape_c4 (gfc_array_c4 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_c4 (gfc_array_c4 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_COMPLEX_4));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_COMPLEX_4);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_c8.c b/libgfortran/generated/reshape_c8.c
index 1a390b4..c8da0bc 100644
--- a/libgfortran/generated/reshape_c8.c
+++ b/libgfortran/generated/reshape_c8.c
@@ -97,6 +97,8 @@ reshape_c8 (gfc_array_c8 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_c8 (gfc_array_c8 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_COMPLEX_8));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_COMPLEX_8);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_i16.c b/libgfortran/generated/reshape_i16.c
index 4f69ce0..43fbefc 100644
--- a/libgfortran/generated/reshape_i16.c
+++ b/libgfortran/generated/reshape_i16.c
@@ -97,6 +97,8 @@ reshape_16 (gfc_array_i16 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_16 (gfc_array_i16 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_INTEGER_16));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_INTEGER_16);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_i4.c b/libgfortran/generated/reshape_i4.c
index 53016bd..2c136de 100644
--- a/libgfortran/generated/reshape_i4.c
+++ b/libgfortran/generated/reshape_i4.c
@@ -97,6 +97,8 @@ reshape_4 (gfc_array_i4 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_4 (gfc_array_i4 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_INTEGER_4));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_INTEGER_4);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_i8.c b/libgfortran/generated/reshape_i8.c
index 34620cf..c97b747 100644
--- a/libgfortran/generated/reshape_i8.c
+++ b/libgfortran/generated/reshape_i8.c
@@ -97,6 +97,8 @@ reshape_8 (gfc_array_i8 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_8 (gfc_array_i8 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_INTEGER_8));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_INTEGER_8);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_r10.c b/libgfortran/generated/reshape_r10.c
index 3bf319a..fa3873e 100644
--- a/libgfortran/generated/reshape_r10.c
+++ b/libgfortran/generated/reshape_r10.c
@@ -97,6 +97,8 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_REAL_10));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_REAL_10);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_r16.c b/libgfortran/generated/reshape_r16.c
index 6794b50..c2b6556 100644
--- a/libgfortran/generated/reshape_r16.c
+++ b/libgfortran/generated/reshape_r16.c
@@ -97,6 +97,8 @@ reshape_r16 (gfc_array_r16 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_r16 (gfc_array_r16 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_REAL_16));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_REAL_16);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_r4.c b/libgfortran/generated/reshape_r4.c
index e7bfbfb..2b859fc 100644
--- a/libgfortran/generated/reshape_r4.c
+++ b/libgfortran/generated/reshape_r4.c
@@ -97,6 +97,8 @@ reshape_r4 (gfc_array_r4 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_r4 (gfc_array_r4 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_REAL_4));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_REAL_4);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/generated/reshape_r8.c b/libgfortran/generated/reshape_r8.c
index d0441c0..49b2352 100644
--- a/libgfortran/generated/reshape_r8.c
+++ b/libgfortran/generated/reshape_r8.c
@@ -97,6 +97,8 @@ reshape_r8 (gfc_array_r8 * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -107,7 +109,13 @@ reshape_r8 (gfc_array_r8 * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof (GFC_REAL_8));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof (GFC_REAL_8);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/intrinsics/reshape_generic.c b/libgfortran/intrinsics/reshape_generic.c
index bb1552aa..5b39711 100644
--- a/libgfortran/intrinsics/reshape_generic.c
+++ b/libgfortran/intrinsics/reshape_generic.c
@@ -85,6 +85,8 @@ reshape_internal (parray *ret, parray *source, shape_type *shape,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -95,7 +97,14 @@ reshape_internal (parray *ret, parray *source, shape_type *shape,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * size );
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * size;
+
+ ret->data = internal_malloc_size (alloc_size);
+
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}
diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4
index 4052a5e..d1486f3 100644
--- a/libgfortran/m4/reshape.m4
+++ b/libgfortran/m4/reshape.m4
@@ -101,6 +101,8 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
if (ret->data == NULL)
{
+ index_type alloc_size;
+
rs = 1;
for (n = 0; n < rdim; n++)
{
@@ -111,7 +113,13 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
rs *= rex;
}
ret->offset = 0;
- ret->data = internal_malloc_size ( rs * sizeof ('rtype_name`));
+
+ if (unlikely (rs < 1))
+ alloc_size = 1;
+ else
+ alloc_size = rs * sizeof ('rtype_name`);
+
+ ret->data = internal_malloc_size (alloc_size);
ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
}