aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2008-02-02 13:50:55 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2008-02-02 13:50:55 +0000
commitee440dd05de292dde12376f8a977d2a4bf22c2c3 (patch)
tree41b636e47d1922843adc517116bfd40c4acb7428
parent27f56cb1f2c371e33b32e1adb1f0f571c1266c41 (diff)
downloadgcc-ee440dd05de292dde12376f8a977d2a4bf22c2c3.zip
gcc-ee440dd05de292dde12376f8a977d2a4bf22c2c3.tar.gz
gcc-ee440dd05de292dde12376f8a977d2a4bf22c2c3.tar.bz2
re PR libfortran/35001 (shape for negative sizes)
2008-02-02 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/35001 * m4/shape.m4: Return 0 for extents <= 0. * generated/shape_i4.c: Regenerated. * generated/shape_i8.c: Regenerated. * generated/shape_i16.c: Regenerated. 2008-02-02 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/35001 * gfortran.dg/shape_4.f90: New test. Fixed in regression-only mode by special dispense (see the PR). From-SVN: r132070
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/shape_4.f9012
-rw-r--r--libgfortran/ChangeLog8
-rw-r--r--libgfortran/generated/shape_i16.c5
-rw-r--r--libgfortran/generated/shape_i4.c5
-rw-r--r--libgfortran/generated/shape_i8.c5
-rw-r--r--libgfortran/m4/shape.m45
7 files changed, 37 insertions, 8 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8a96691..06cd1b1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-02 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/35001
+ * gfortran.dg/shape_4.f90: New test.
+
2008-02-02 Hans-Peter Nilsson <hp@axis.com>
* gcc.target/cris/torture/pr34773.c: Use __asm__, not asm.
diff --git a/gcc/testsuite/gfortran.dg/shape_4.f90 b/gcc/testsuite/gfortran.dg/shape_4.f90
new file mode 100644
index 0000000..9275b11
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/shape_4.f90
@@ -0,0 +1,12 @@
+! PR 35001 - we need to return 0 for the shapes of
+! negative extents. Test case adapted from Tobias Burnus.
+program main
+ implicit none
+ integer :: i,j, a(10,10),res(2)
+ j = 1
+ i = 10
+ res = shape(a(1:1,i:j:1))
+ if (res(1) /=1 .or. res(2) /= 0) call abort
+ res = shape(a(1:1,j:i:-1))
+ if (res(1) /=1 .or. res(2) /= 0) call abort
+end program main
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index b71eb30..432aa56 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,11 @@
+2008-02-02 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/35001
+ * m4/shape.m4: Return 0 for extents <= 0.
+ * generated/shape_i4.c: Regenerated.
+ * generated/shape_i8.c: Regenerated.
+ * generated/shape_i16.c: Regenerated.
+
2008-01-27 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/34980
diff --git a/libgfortran/generated/shape_i16.c b/libgfortran/generated/shape_i16.c
index 77274d6..0ab2654 100644
--- a/libgfortran/generated/shape_i16.c
+++ b/libgfortran/generated/shape_i16.c
@@ -45,6 +45,7 @@ shape_16 (gfc_array_i16 * const restrict ret,
{
int n;
index_type stride;
+ index_type extent;
stride = ret->dim[0].stride;
@@ -53,8 +54,8 @@ shape_16 (gfc_array_i16 * const restrict ret,
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{
- ret->data[n * stride] =
- array->dim[n].ubound + 1 - array->dim[n].lbound;
+ extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
+ ret->data[n * stride] = extent > 0 ? extent : 0 ;
}
}
diff --git a/libgfortran/generated/shape_i4.c b/libgfortran/generated/shape_i4.c
index 787ba54..64a6fcd 100644
--- a/libgfortran/generated/shape_i4.c
+++ b/libgfortran/generated/shape_i4.c
@@ -45,6 +45,7 @@ shape_4 (gfc_array_i4 * const restrict ret,
{
int n;
index_type stride;
+ index_type extent;
stride = ret->dim[0].stride;
@@ -53,8 +54,8 @@ shape_4 (gfc_array_i4 * const restrict ret,
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{
- ret->data[n * stride] =
- array->dim[n].ubound + 1 - array->dim[n].lbound;
+ extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
+ ret->data[n * stride] = extent > 0 ? extent : 0 ;
}
}
diff --git a/libgfortran/generated/shape_i8.c b/libgfortran/generated/shape_i8.c
index f318b17..80bef31 100644
--- a/libgfortran/generated/shape_i8.c
+++ b/libgfortran/generated/shape_i8.c
@@ -45,6 +45,7 @@ shape_8 (gfc_array_i8 * const restrict ret,
{
int n;
index_type stride;
+ index_type extent;
stride = ret->dim[0].stride;
@@ -53,8 +54,8 @@ shape_8 (gfc_array_i8 * const restrict ret,
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{
- ret->data[n * stride] =
- array->dim[n].ubound + 1 - array->dim[n].lbound;
+ extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
+ ret->data[n * stride] = extent > 0 ? extent : 0 ;
}
}
diff --git a/libgfortran/m4/shape.m4 b/libgfortran/m4/shape.m4
index 3bda0ad..c783270 100644
--- a/libgfortran/m4/shape.m4
+++ b/libgfortran/m4/shape.m4
@@ -46,6 +46,7 @@ shape_'rtype_kind` ('rtype` * const restrict ret,
{
int n;
index_type stride;
+ index_type extent;
stride = ret->dim[0].stride;
@@ -54,8 +55,8 @@ shape_'rtype_kind` ('rtype` * const restrict ret,
for (n = 0; n < GFC_DESCRIPTOR_RANK (array); n++)
{
- ret->data[n * stride] =
- array->dim[n].ubound + 1 - array->dim[n].lbound;
+ extent = array->dim[n].ubound + 1 - array->dim[n].lbound;
+ ret->data[n * stride] = extent > 0 ? extent : 0 ;
}
}