aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2008-07-21 10:05:32 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2008-07-21 10:05:32 +0000
commitc44109aaf3be31a6816a8a4f3c4454261d8d2622 (patch)
tree9f53b6a50b64cf1ac4935ade62445629885b9613 /libgfortran
parent1bb64668d0fbb2abfa3583918a256420028eea30 (diff)
downloadgcc-c44109aaf3be31a6816a8a4f3c4454261d8d2622.zip
gcc-c44109aaf3be31a6816a8a4f3c4454261d8d2622.tar.gz
gcc-c44109aaf3be31a6816a8a4f3c4454261d8d2622.tar.bz2
re PR libfortran/36773 (zero-sized arrays with cshift and eoshift)
2008-07-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/36773 * intrinsics/cshift0.c (cshift0): Return early if size of array is zero. * intrinsics/eoshift0.c (eoshift0): Return early if size of return array is zero. * intrinsics/eoshift2.c (eoshift2): Likewise. * m4/eoshift1.m4 (eoshift1): Return early if size of array is zero. * m4/eoshift3.m4 (eoshift3): Likewise. * m4/eoshift2.m4 (eoshift2): Return early if size of return array is zero. * m4/eoshift4.m4 (eoshift2): Return early if size of return array is zero. * generated/cshift1_16.c: Regenerated. * generated/cshift1_4.c: Regenerated. * generated/cshift1_8.c: Regenerated. * generated/eoshift1_16.c: Regenerated. * generated/eoshift1_4.c: Regenerated. * generated/eoshift1_8.c: Regenerated. * generated/eoshift3_16.c: Regenerated. * generated/eoshift3_4.c: Regenerated. * generated/eoshift3_8.c: Regenerated. 2008-07-21 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/36773 * gfortran.dg/zero_sized_5.f90: New test case. From-SVN: r138027
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog25
-rw-r--r--libgfortran/generated/cshift1_16.c8
-rw-r--r--libgfortran/generated/cshift1_4.c8
-rw-r--r--libgfortran/generated/cshift1_8.c8
-rw-r--r--libgfortran/generated/eoshift1_16.c5
-rw-r--r--libgfortran/generated/eoshift1_4.c5
-rw-r--r--libgfortran/generated/eoshift1_8.c5
-rw-r--r--libgfortran/generated/eoshift3_16.c5
-rw-r--r--libgfortran/generated/eoshift3_4.c5
-rw-r--r--libgfortran/generated/eoshift3_8.c5
-rw-r--r--libgfortran/intrinsics/cshift0.c61
-rw-r--r--libgfortran/intrinsics/eoshift0.c5
-rw-r--r--libgfortran/intrinsics/eoshift2.c13
-rw-r--r--libgfortran/m4/cshift1.m48
-rw-r--r--libgfortran/m4/eoshift1.m45
-rw-r--r--libgfortran/m4/eoshift3.m45
16 files changed, 143 insertions, 33 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 48a20e9..b485123 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,28 @@
+2008-07-21 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/36773
+ * intrinsics/cshift0.c (cshift0): Return early if size of array
+ is zero.
+ * intrinsics/eoshift0.c (eoshift0): Return early if size of
+ return array is zero.
+ * intrinsics/eoshift2.c (eoshift2): Likewise.
+ * m4/eoshift1.m4 (eoshift1): Return early if size of array
+ is zero.
+ * m4/eoshift3.m4 (eoshift3): Likewise.
+ * m4/eoshift2.m4 (eoshift2): Return early if size of return
+ array is zero.
+ * m4/eoshift4.m4 (eoshift2): Return early if size of return
+ array is zero.
+ * generated/cshift1_16.c: Regenerated.
+ * generated/cshift1_4.c: Regenerated.
+ * generated/cshift1_8.c: Regenerated.
+ * generated/eoshift1_16.c: Regenerated.
+ * generated/eoshift1_4.c: Regenerated.
+ * generated/eoshift1_8.c: Regenerated.
+ * generated/eoshift3_16.c: Regenerated.
+ * generated/eoshift3_4.c: Regenerated.
+ * generated/eoshift3_8.c: Regenerated.
+
2008-07-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/36857
diff --git a/libgfortran/generated/cshift1_16.c b/libgfortran/generated/cshift1_16.c
index 2943c3e..06e2746 100644
--- a/libgfortran/generated/cshift1_16.c
+++ b/libgfortran/generated/cshift1_16.c
@@ -67,6 +67,7 @@ cshift1 (gfc_array_char * const restrict ret,
index_type n;
int which;
GFC_INTEGER_16 sh;
+ index_type arraysize;
if (pwhich)
which = *pwhich - 1;
@@ -76,11 +77,13 @@ cshift1 (gfc_array_char * const restrict ret,
if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
+ arraysize = size0 ((array_t *)array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
@@ -95,6 +98,9 @@ cshift1 (gfc_array_char * const restrict ret,
}
}
+ if (arraysize == 0)
+ return;
+
extent[0] = 1;
count[0] = 0;
n = 0;
diff --git a/libgfortran/generated/cshift1_4.c b/libgfortran/generated/cshift1_4.c
index 3f4f9e0b..3be3c3c 100644
--- a/libgfortran/generated/cshift1_4.c
+++ b/libgfortran/generated/cshift1_4.c
@@ -67,6 +67,7 @@ cshift1 (gfc_array_char * const restrict ret,
index_type n;
int which;
GFC_INTEGER_4 sh;
+ index_type arraysize;
if (pwhich)
which = *pwhich - 1;
@@ -76,11 +77,13 @@ cshift1 (gfc_array_char * const restrict ret,
if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
+ arraysize = size0 ((array_t *)array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
@@ -95,6 +98,9 @@ cshift1 (gfc_array_char * const restrict ret,
}
}
+ if (arraysize == 0)
+ return;
+
extent[0] = 1;
count[0] = 0;
n = 0;
diff --git a/libgfortran/generated/cshift1_8.c b/libgfortran/generated/cshift1_8.c
index 4d246e5..b444a69 100644
--- a/libgfortran/generated/cshift1_8.c
+++ b/libgfortran/generated/cshift1_8.c
@@ -67,6 +67,7 @@ cshift1 (gfc_array_char * const restrict ret,
index_type n;
int which;
GFC_INTEGER_8 sh;
+ index_type arraysize;
if (pwhich)
which = *pwhich - 1;
@@ -76,11 +77,13 @@ cshift1 (gfc_array_char * const restrict ret,
if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
+ arraysize = size0 ((array_t *)array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
@@ -95,6 +98,9 @@ cshift1 (gfc_array_char * const restrict ret,
}
}
+ if (arraysize == 0)
+ return;
+
extent[0] = 1;
count[0] = 0;
n = 0;
diff --git a/libgfortran/generated/eoshift1_16.c b/libgfortran/generated/eoshift1_16.c
index 63b75bd..fd145c1 100644
--- a/libgfortran/generated/eoshift1_16.c
+++ b/libgfortran/generated/eoshift1_16.c
@@ -102,6 +102,11 @@ eoshift1 (gfc_array_char * const restrict ret,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
diff --git a/libgfortran/generated/eoshift1_4.c b/libgfortran/generated/eoshift1_4.c
index 58ce7e9..d78c40a 100644
--- a/libgfortran/generated/eoshift1_4.c
+++ b/libgfortran/generated/eoshift1_4.c
@@ -102,6 +102,11 @@ eoshift1 (gfc_array_char * const restrict ret,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
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 0e9c2f1..06d5532 100644
--- a/libgfortran/generated/eoshift1_8.c
+++ b/libgfortran/generated/eoshift1_8.c
@@ -102,6 +102,11 @@ eoshift1 (gfc_array_char * const restrict ret,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
diff --git a/libgfortran/generated/eoshift3_16.c b/libgfortran/generated/eoshift3_16.c
index 214f378..66a5077 100644
--- a/libgfortran/generated/eoshift3_16.c
+++ b/libgfortran/generated/eoshift3_16.c
@@ -103,6 +103,11 @@ eoshift3 (gfc_array_char * const restrict ret,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
extent[0] = 1;
diff --git a/libgfortran/generated/eoshift3_4.c b/libgfortran/generated/eoshift3_4.c
index e96ef25..3579cff 100644
--- a/libgfortran/generated/eoshift3_4.c
+++ b/libgfortran/generated/eoshift3_4.c
@@ -103,6 +103,11 @@ eoshift3 (gfc_array_char * const restrict ret,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
extent[0] = 1;
diff --git a/libgfortran/generated/eoshift3_8.c b/libgfortran/generated/eoshift3_8.c
index dc39b94..de969a0 100644
--- a/libgfortran/generated/eoshift3_8.c
+++ b/libgfortran/generated/eoshift3_8.c
@@ -103,6 +103,11 @@ eoshift3 (gfc_array_char * const restrict ret,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
extent[0] = 1;
diff --git a/libgfortran/intrinsics/cshift0.c b/libgfortran/intrinsics/cshift0.c
index 76ce97e..ac26e86 100644
--- a/libgfortran/intrinsics/cshift0.c
+++ b/libgfortran/intrinsics/cshift0.c
@@ -97,10 +97,43 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array,
index_type len;
index_type n;
int whichloop;
+ index_type arraysize;
if (which < 1 || which > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument 'DIM' is out of range in call to 'CSHIFT'");
+ arraysize = size0 ((array_t *) array);
+
+ if (ret->data == NULL)
+ {
+ int i;
+
+ ret->offset = 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;
+ }
+
+ if (arraysize > 0)
+ ret->data = internal_malloc_size (size * arraysize);
+ else
+ {
+ ret->data = internal_malloc_size (1);
+ return;
+ }
+ }
+
+ if (arraysize == 0)
+ return;
+
which = which - 1;
sstride[0] = 0;
rstride[0] = 0;
@@ -142,34 +175,6 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array,
soffset = size;
len = 0;
- if (ret->data == NULL)
- {
- int i;
- index_type arraysize = size0 ((array_t *)array);
-
- ret->offset = 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;
- }
-
- if (arraysize > 0)
- ret->data = internal_malloc_size (size * arraysize);
- else
- {
- ret->data = internal_malloc_size (1);
- return;
- }
- }
-
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
{
if (dim == which)
diff --git a/libgfortran/intrinsics/eoshift0.c b/libgfortran/intrinsics/eoshift0.c
index ac7a0ba..fd216b1 100644
--- a/libgfortran/intrinsics/eoshift0.c
+++ b/libgfortran/intrinsics/eoshift0.c
@@ -84,6 +84,11 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * array,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
which = which - 1;
diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c
index 239d971..aa66a8d 100644
--- a/libgfortran/intrinsics/eoshift2.c
+++ b/libgfortran/intrinsics/eoshift2.c
@@ -63,6 +63,7 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
index_type dim;
index_type len;
index_type n;
+ index_type arraysize;
/* The compiler cannot figure out that these are set, initialize
them to avoid warnings. */
@@ -70,11 +71,13 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
soffset = 0;
roffset = 0;
+ arraysize = size0 ((array_t *) array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
@@ -88,6 +91,14 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
+
+ if (arraysize == 0 && filler == NULL)
+ return;
which = which - 1;
diff --git a/libgfortran/m4/cshift1.m4 b/libgfortran/m4/cshift1.m4
index 28fae59..861debe 100644
--- a/libgfortran/m4/cshift1.m4
+++ b/libgfortran/m4/cshift1.m4
@@ -68,6 +68,7 @@ cshift1 (gfc_array_char * const restrict ret,
index_type n;
int which;
'atype_name` sh;
+ index_type arraysize;
if (pwhich)
which = *pwhich - 1;
@@ -77,11 +78,13 @@ cshift1 (gfc_array_char * const restrict ret,
if (which < 0 || (which + 1) > GFC_DESCRIPTOR_RANK (array))
runtime_error ("Argument ''`DIM''` is out of range in call to ''`CSHIFT''`");
+ arraysize = size0 ((array_t *)array);
+
if (ret->data == NULL)
{
int i;
- ret->data = internal_malloc_size (size * size0 ((array_t *)array));
+ ret->data = internal_malloc_size (size * arraysize);
ret->offset = 0;
ret->dtype = array->dtype;
for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
@@ -96,6 +99,9 @@ cshift1 (gfc_array_char * const restrict ret,
}
}
+ if (arraysize == 0)
+ return;
+
extent[0] = 1;
count[0] = 0;
n = 0;
diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4
index 8ce24ef..01ca57e 100644
--- a/libgfortran/m4/eoshift1.m4
+++ b/libgfortran/m4/eoshift1.m4
@@ -103,6 +103,11 @@ eoshift1 (gfc_array_char * const restrict ret,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
n = 0;
for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++)
diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4
index 081ff92..6a6929c 100644
--- a/libgfortran/m4/eoshift3.m4
+++ b/libgfortran/m4/eoshift3.m4
@@ -104,6 +104,11 @@ eoshift3 (gfc_array_char * const restrict ret,
ret->dim[i].stride = (ret->dim[i-1].ubound + 1) * ret->dim[i-1].stride;
}
}
+ else
+ {
+ if (size0 ((array_t *) ret) == 0)
+ return;
+ }
extent[0] = 1;