aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Koenig <Thomas.Koenig@online.de>2005-06-25 09:56:37 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2005-06-25 09:56:37 +0000
commit0e6d033bc892f6f79683dcbbda0e6a1987685bf4 (patch)
tree0bfeede6e9240f3c069b66974e9813ec2385f821
parent366ccddb2bc50711bd3a11c1dee97b50e8ef1677 (diff)
downloadgcc-0e6d033bc892f6f79683dcbbda0e6a1987685bf4.zip
gcc-0e6d033bc892f6f79683dcbbda0e6a1987685bf4.tar.gz
gcc-0e6d033bc892f6f79683dcbbda0e6a1987685bf4.tar.bz2
[multiple changes]
2005-06-25 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/22144 * m4/cshift1.m4: Remove const from argument ret. Populate return array descriptor if ret->data is NULL. * m4/eoshift1.m4: Likewise. * m4/eoshift3.m4: Likewise. * generated/cshift1_4.c: Regenerated. * generated/cshift1_8.c: Regenerated. * generated/eoshift1_4.c: Regenerated. * generated/eoshift1_8.c: Regenerated. * generated/eoshift3_4.c: Regenerated. * generated/eoshift3_8.c: Regenerated. 2005-06-25 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/21144 * gfortran.dg/shift-alloc.f90: New testcase. From-SVN: r101318
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/shift-alloc.f9018
-rw-r--r--libgfortran/ChangeLog14
-rw-r--r--libgfortran/generated/cshift1_4.c23
-rw-r--r--libgfortran/generated/cshift1_8.c23
-rw-r--r--libgfortran/generated/eoshift1_4.c24
-rw-r--r--libgfortran/generated/eoshift1_8.c24
-rw-r--r--libgfortran/generated/eoshift3_4.c19
-rw-r--r--libgfortran/generated/eoshift3_8.c19
-rw-r--r--libgfortran/m4/cshift1.m423
-rw-r--r--libgfortran/m4/eoshift1.m424
-rw-r--r--libgfortran/m4/eoshift3.m419
12 files changed, 223 insertions, 12 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 70b830b..419e012 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-06-25 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR libfortran/21144
+ * gfortran.dg/shift-alloc.f90: New testcase.
+
2005-06-25 Kelley Cook <kcook@gcc.gnu.org>
* all files: Update FSF address in copyright headers.
diff --git a/gcc/testsuite/gfortran.dg/shift-alloc.f90 b/gcc/testsuite/gfortran.dg/shift-alloc.f90
new file mode 100644
index 0000000..2d66031
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/shift-alloc.f90
@@ -0,0 +1,18 @@
+! { dg do-run }
+! PR 22144: eoshift1, eoshift3 and cshift1 used to lack memory
+! allocation, which caused the writes to segfault.
+program main
+ implicit none
+ integer, dimension (:,:),allocatable :: a
+ integer, dimension (3) :: sh, bo
+ character(len=80) line1, line2
+ integer :: i
+
+ allocate (a(3,3))
+ a = reshape((/(i,i=1,9)/),shape(a))
+ sh = (/ 2, -1, -2 /)
+ bo = (/ -3, -2, -1 /)
+ write(unit=line1,fmt='(10I5)') cshift(a, shift=sh)
+ write(unit=line1,fmt='(10I5)') eoshift(a, shift=sh)
+ write(unit=line1,fmt='(10I5)') eoshift(a, shift=sh, boundary=bo)
+end program main
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 06c3e4b..9b2ddec 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,17 @@
+2005-06-25 Thomas Koenig <Thomas.Koenig@online.de>
+
+ PR libfortran/22144
+ * m4/cshift1.m4: Remove const from argument ret.
+ Populate return array descriptor if ret->data is NULL.
+ * m4/eoshift1.m4: Likewise.
+ * m4/eoshift3.m4: Likewise.
+ * generated/cshift1_4.c: Regenerated.
+ * generated/cshift1_8.c: Regenerated.
+ * generated/eoshift1_4.c: Regenerated.
+ * generated/eoshift1_8.c: Regenerated.
+ * generated/eoshift3_4.c: Regenerated.
+ * generated/eoshift3_8.c: Regenerated.
+
2005-06-24 Jerry DeLisle <jvdelisle@verizon.net>
PR libfortran/21915
diff --git a/libgfortran/generated/cshift1_4.c b/libgfortran/generated/cshift1_4.c
index 683ce70..b86f9e5 100644
--- a/libgfortran/generated/cshift1_4.c
+++ b/libgfortran/generated/cshift1_4.c
@@ -34,13 +34,13 @@ Boston, MA 02111-1307, USA. */
#include <string.h>
#include "libgfortran.h"
-void cshift1_4 (const gfc_array_char * ret,
+void cshift1_4 (gfc_array_char * ret,
const gfc_array_char * array,
const gfc_array_i4 * h, const GFC_INTEGER_4 * pwhich);
export_proto(cshift1_4);
void
-cshift1_4 (const gfc_array_char * ret,
+cshift1_4 (gfc_array_char * ret,
const gfc_array_char * array,
const gfc_array_i4 * h, const GFC_INTEGER_4 * pwhich)
{
@@ -80,6 +80,25 @@ cshift1_4 (const gfc_array_char * ret,
size = GFC_DESCRIPTOR_SIZE (ret);
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
extent[0] = 1;
count[0] = 0;
size = GFC_DESCRIPTOR_SIZE (array);
diff --git a/libgfortran/generated/cshift1_8.c b/libgfortran/generated/cshift1_8.c
index 6513b91..24c1b6e 100644
--- a/libgfortran/generated/cshift1_8.c
+++ b/libgfortran/generated/cshift1_8.c
@@ -34,13 +34,13 @@ Boston, MA 02111-1307, USA. */
#include <string.h>
#include "libgfortran.h"
-void cshift1_8 (const gfc_array_char * ret,
+void cshift1_8 (gfc_array_char * ret,
const gfc_array_char * array,
const gfc_array_i8 * h, const GFC_INTEGER_8 * pwhich);
export_proto(cshift1_8);
void
-cshift1_8 (const gfc_array_char * ret,
+cshift1_8 (gfc_array_char * ret,
const gfc_array_char * array,
const gfc_array_i8 * h, const GFC_INTEGER_8 * pwhich)
{
@@ -80,6 +80,25 @@ cshift1_8 (const gfc_array_char * ret,
size = GFC_DESCRIPTOR_SIZE (ret);
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
extent[0] = 1;
count[0] = 0;
size = GFC_DESCRIPTOR_SIZE (array);
diff --git a/libgfortran/generated/eoshift1_4.c b/libgfortran/generated/eoshift1_4.c
index 3503f82..833efa2 100644
--- a/libgfortran/generated/eoshift1_4.c
+++ b/libgfortran/generated/eoshift1_4.c
@@ -37,14 +37,14 @@ Boston, MA 02111-1307, USA. */
static const char zeros[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-extern void eoshift1_4 (const gfc_array_char *,
+extern void eoshift1_4 (gfc_array_char *,
const gfc_array_char *,
const gfc_array_i4 *, const char *,
const GFC_INTEGER_4 *);
export_proto(eoshift1_4);
void
-eoshift1_4 (const gfc_array_char *ret,
+eoshift1_4 (gfc_array_char *ret,
const gfc_array_char *array,
const gfc_array_i4 *h, const char *pbound,
const GFC_INTEGER_4 *pwhich)
@@ -95,6 +95,26 @@ eoshift1_4 (const gfc_array_char *ret,
extent[0] = 1;
count[0] = 0;
size = GFC_DESCRIPTOR_SIZE (array);
+
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
diff --git a/libgfortran/generated/eoshift1_8.c b/libgfortran/generated/eoshift1_8.c
index bfa6088..75d0f1e 100644
--- a/libgfortran/generated/eoshift1_8.c
+++ b/libgfortran/generated/eoshift1_8.c
@@ -37,14 +37,14 @@ Boston, MA 02111-1307, USA. */
static const char zeros[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-extern void eoshift1_8 (const gfc_array_char *,
+extern void eoshift1_8 (gfc_array_char *,
const gfc_array_char *,
const gfc_array_i8 *, const char *,
const GFC_INTEGER_8 *);
export_proto(eoshift1_8);
void
-eoshift1_8 (const gfc_array_char *ret,
+eoshift1_8 (gfc_array_char *ret,
const gfc_array_char *array,
const gfc_array_i8 *h, const char *pbound,
const GFC_INTEGER_8 *pwhich)
@@ -95,6 +95,26 @@ eoshift1_8 (const gfc_array_char *ret,
extent[0] = 1;
count[0] = 0;
size = GFC_DESCRIPTOR_SIZE (array);
+
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
diff --git a/libgfortran/generated/eoshift3_4.c b/libgfortran/generated/eoshift3_4.c
index 964d98b..14c38b7 100644
--- a/libgfortran/generated/eoshift3_4.c
+++ b/libgfortran/generated/eoshift3_4.c
@@ -90,6 +90,25 @@ eoshift3_4 (gfc_array_char *ret, gfc_array_char *array,
which = 0;
size = GFC_DESCRIPTOR_SIZE (ret);
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
extent[0] = 1;
count[0] = 0;
diff --git a/libgfortran/generated/eoshift3_8.c b/libgfortran/generated/eoshift3_8.c
index c17b588..77617b0 100644
--- a/libgfortran/generated/eoshift3_8.c
+++ b/libgfortran/generated/eoshift3_8.c
@@ -90,6 +90,25 @@ eoshift3_8 (gfc_array_char *ret, gfc_array_char *array,
which = 0;
size = GFC_DESCRIPTOR_SIZE (ret);
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
extent[0] = 1;
count[0] = 0;
diff --git a/libgfortran/m4/cshift1.m4 b/libgfortran/m4/cshift1.m4
index 308c3dc..dd7653a 100644
--- a/libgfortran/m4/cshift1.m4
+++ b/libgfortran/m4/cshift1.m4
@@ -35,13 +35,13 @@ Boston, MA 02111-1307, USA. */
#include "libgfortran.h"'
include(iparm.m4)dnl
-void cshift1_`'atype_kind (const gfc_array_char * ret,
+void cshift1_`'atype_kind (gfc_array_char * ret,
const gfc_array_char * array,
const atype * h, const atype_name * pwhich);
export_proto(cshift1_`'atype_kind);
void
-cshift1_`'atype_kind (const gfc_array_char * ret,
+cshift1_`'atype_kind (gfc_array_char * ret,
const gfc_array_char * array,
const atype * h, const atype_name * pwhich)
{
@@ -81,6 +81,25 @@ cshift1_`'atype_kind (const gfc_array_char * ret,
size = GFC_DESCRIPTOR_SIZE (ret);
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
extent[0] = 1;
count[0] = 0;
size = GFC_DESCRIPTOR_SIZE (array);
diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4
index b21c6d3..1d13f48 100644
--- a/libgfortran/m4/eoshift1.m4
+++ b/libgfortran/m4/eoshift1.m4
@@ -38,14 +38,14 @@ include(iparm.m4)dnl
static const char zeros[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-extern void eoshift1_`'atype_kind (const gfc_array_char *,
+extern void eoshift1_`'atype_kind (gfc_array_char *,
const gfc_array_char *,
const atype *, const char *,
const atype_name *);
export_proto(eoshift1_`'atype_kind);
void
-eoshift1_`'atype_kind (const gfc_array_char *ret,
+eoshift1_`'atype_kind (gfc_array_char *ret,
const gfc_array_char *array,
const atype *h, const char *pbound,
const atype_name *pwhich)
@@ -96,6 +96,26 @@ eoshift1_`'atype_kind (const gfc_array_char *ret,
extent[0] = 1;
count[0] = 0;
size = GFC_DESCRIPTOR_SIZE (array);
+
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4
index 6cbb87c..5001756 100644
--- a/libgfortran/m4/eoshift3.m4
+++ b/libgfortran/m4/eoshift3.m4
@@ -91,6 +91,25 @@ eoshift3_`'atype_kind (gfc_array_char *ret, gfc_array_char *array,
which = 0;
size = GFC_DESCRIPTOR_SIZE (ret);
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->base = 0;
+ ret->dtype = array->dtype;
+ for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
+ {
+ ret->dim[i].lbound = 0;
+ ret->dim[i].ubound = array->dim[i].ubound - array->dim[i].lbound;
+
+ if (i == 0)
+ ret->dim[i].stride = 1;
+ else
+ ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
+ }
+ }
+
extent[0] = 1;
count[0] = 0;