]> gcc.gnu.org Git - gcc.git/commitdiff
re PR libfortran/35001 (shape for negative sizes)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 2 Feb 2008 13:50:55 +0000 (13:50 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 2 Feb 2008 13:50:55 +0000 (13:50 +0000)
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

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/shape_4.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/generated/shape_i16.c
libgfortran/generated/shape_i4.c
libgfortran/generated/shape_i8.c
libgfortran/m4/shape.m4

index 8a966911f944aad8ba98951c36fe8f62aa62ae34..06cd1b139edeb48e80657bb53dba4ee91a7a7af3 100644 (file)
@@ -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.
 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 (file)
index 0000000..9275b11
--- /dev/null
@@ -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
index b71eb30065eaad8afd7b6e86824cb782aed637cd..432aa56ee44e0306a4b8c0fbb6a6012ccc1c0a0a 100644 (file)
@@ -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
 2008-01-27  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR libfortran/34980
index 77274d6002a8404b0a87943af4e108e6a1338b6f..0ab2654bd8ccf06d9f07c2775343e460d338aa5b 100644 (file)
@@ -45,6 +45,7 @@ shape_16 (gfc_array_i16 * const restrict ret,
 {
   int n;
   index_type stride;
 {
   int n;
   index_type stride;
+  index_type extent;
 
   stride = ret->dim[0].stride;
 
 
   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++)
     {
 
   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 ;
     }
 }
 
     }
 }
 
index 787ba544c21f7fa3a9a5ab78e8ae843810acc916..64a6fcdb994275eb165f95e2e685d8b0d47e6b31 100644 (file)
@@ -45,6 +45,7 @@ shape_4 (gfc_array_i4 * const restrict ret,
 {
   int n;
   index_type stride;
 {
   int n;
   index_type stride;
+  index_type extent;
 
   stride = ret->dim[0].stride;
 
 
   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++)
     {
 
   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 ;
     }
 }
 
     }
 }
 
index f318b170ab9e4a2cd50d49bd2fb335d163c3f5e6..80bef318b81a2bd1cd782cb6170b2f2f4d789dcd 100644 (file)
@@ -45,6 +45,7 @@ shape_8 (gfc_array_i8 * const restrict ret,
 {
   int n;
   index_type stride;
 {
   int n;
   index_type stride;
+  index_type extent;
 
   stride = ret->dim[0].stride;
 
 
   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++)
     {
 
   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 ;
     }
 }
 
     }
 }
 
index 3bda0ad8cbb18114428a5aa02de849f22f64903b..c783270bec7f54f4fcdf2f1f7d98b43f31e729b7 100644 (file)
@@ -46,6 +46,7 @@ shape_'rtype_kind` ('rtype` * const restrict ret,
 {
   int n;
   index_type stride;
 {
   int n;
   index_type stride;
+  index_type extent;
 
   stride = ret->dim[0].stride;
 
 
   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++)
     {
 
   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 ;
     }
 }
 
     }
 }
 
This page took 0.123899 seconds and 5 git commands to generate.