]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/21594 ([4.0 only] FAIL: gfortran.dg/eoshift.f90 -O0 execution test)
authorThomas Koenig <Thomas.Koenig@online.de>
Thu, 7 Jul 2005 22:01:41 +0000 (22:01 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Thu, 7 Jul 2005 22:01:41 +0000 (22:01 +0000)
2005-07-07  Thomas Koenig  <Thomas.Koenig@online.de>

PR libfortran/21594
* intrinsics/eoshift0.c:  If abs(shift) > len, fill the
the whole array with the boundary value, but don't overrun it.
* intrinsics/eoshift2.c:  Likewise.
* m4/eoshift1.m4:  Likewise.
* m4/eoshift3.m4:  Likewise.
* generated/eoshift1_4.c:  Regenerated.
* generated/eoshift1_8.c:  Regenerated.
* generated/eoshift3_4.c:  Regenerated.
* generated/eoshift3_8.c:  Regenerated.

2005-07-07  Thomas Koenig  <Thomas.Koenig@online.de>

PR libfortran/21594
* gfortran.fortran-torture/execute/intrinsic_eoshift.f90:
Add test cases where the shift length is greater than the
array length.

From-SVN: r101738

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_eoshift.f90
libgfortran/ChangeLog
libgfortran/generated/eoshift1_4.c
libgfortran/generated/eoshift1_8.c
libgfortran/generated/eoshift3_4.c
libgfortran/generated/eoshift3_8.c
libgfortran/intrinsics/eoshift0.c
libgfortran/intrinsics/eoshift2.c
libgfortran/m4/eoshift1.m4
libgfortran/m4/eoshift3.m4

index 29ed4af2853ed7ede446b45a86d67d7412ff1bfa..1804874c4de968601f9e3919dcec246a02498ed1 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-07  Thomas Koenig  <Thomas.Koenig@online.de>
+
+       PR libfortran/21594
+       * gfortran.fortran-torture/execute/intrinsic_eoshift.f90:
+       Add test cases where the shift length is greater than the
+       array length.
+
 2005-07-07  Ziemowit Laski  <zlaski@apple.com>
 
        * obj-c++.dg/gnu-runtime-2.mm: Compile, do not run.
index 872422d2f086fb78cd7792a25bf923de79dd2549..c4bbcdd689c3be94bdb364c696333eec9e04d4c3 100644 (file)
@@ -10,17 +10,30 @@ program intrinsic_eoshift
    if (any (a .ne. reshape ((/2, 3, 99, 5, 6, 99, 8, 9, 99/), (/3, 3/)))) &
       call abort
 
+   a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
+   a = eoshift (a, 9999, 99, 1)
+   if (any (a .ne. 99)) call abort
+
    a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
    a = eoshift (a, -2, dim = 2)
    if (any (a .ne. reshape ((/0, 0, 0, 0, 0, 0, 1, 2, 3/), (/3, 3/)))) &
       call abort
 
+   a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
+   a = eoshift (a, -9999, 99, 1)
+   if (any (a .ne. 99)) call abort
+
    ! Array shift and scalar bound.
    a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
    a = eoshift (a, (/1, 0, -1/), 99, 1)
    if (any (a .ne. reshape ((/2, 3, 99, 4, 5, 6, 99, 7, 8/), (/3, 3/)))) &
       call abort
 
+   a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
+   a = eoshift (a, (/9999, 0, -9999/), 99, 1)
+   if (any (a .ne. reshape ((/99, 99, 99, 4, 5, 6, 99, 99, 99/), (/3, 3/)))) &
+      call abort
+
    a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
    a = eoshift (a, (/2, -2, 0/), dim = 2)
    if (any (a .ne. reshape ((/7, 0, 3, 0, 0, 6, 0, 2, 9/), (/3, 3/)))) &
@@ -32,6 +45,16 @@ program intrinsic_eoshift
    if (any (a .ne. reshape ((/2, 3, 99, 5, 6, -1, 8, 9, 42/), (/3, 3/)))) &
       call abort
 
+   a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
+   a = eoshift (a, 9999, (/99, -1, 42/), 1)
+   if (any (a .ne. reshape ((/99, 99, 99, -1, -1, -1, 42, 42, 42/), &
+       (/3, 3/)))) call abort
+
+   a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
+   a = eoshift (a, -9999, (/99, -1, 42/), 1)
+   if (any (a .ne. reshape ((/99, 99, 99, -1, -1, -1, 42, 42, 42/), &
+       (/3, 3/)))) call abort
+
    a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
    a = eoshift (a, -2, (/99, -1, 42/), 2)
    if (any (a .ne. reshape ((/99, -1, 42, 99, -1, 42, 1, 2, 3/), (/3, 3/)))) &
@@ -61,6 +84,11 @@ program intrinsic_eoshift
    if (any (a .ne. reshape ((/ -999, -999, -999, -99, 4, 5, -9, -9, -9 /), &
         shape(a)))) call abort
 
+   a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
+   a = eoshift (a, (/9999, -9999, 0/), (/99, -1, 42/), 2)
+   if (any (a .ne. reshape ((/99, -1, 3, 99, -1, 6, 99, -1, 9/), (/3, 3/)))) &
+      call abort
+
    ! Test arrays > rank 2
    b(:, :, 1) = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
    b(:, :, 2) = 10 + reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/))
index 242bd3c8910afa1e378bfaf7560ffad5ee3b58ec..b1256797e6247f1c0d87439437acf5ee0b1952f8 100644 (file)
@@ -1,3 +1,16 @@
+2005-07-07  Thomas Koenig  <Thomas.Koenig@online.de>
+
+       PR libfortran/21594
+       * intrinsics/eoshift0.c:  If abs(shift) > len, fill the
+       the whole array with the boundary value, but don't overrun it.
+       * intrinsics/eoshift2.c:  Likewise.
+       * m4/eoshift1.m4:  Likewise.
+       * m4/eoshift3.m4:  Likewise.
+       * generated/eoshift1_4.c:  Regenerated.
+       * generated/eoshift1_8.c:  Regenerated.
+       * generated/eoshift3_4.c:  Regenerated.
+       * generated/eoshift3_8.c:  Regenerated.
+
 2005-07-07  Feng Wang  <fengwang@nudt.edu.cn>
 
        PR fortran/16531
index cb4dfb5547b5ae370cdc281f22d43eb15a05238c..6012c3fe902b276346582519830a6899f3ee725d 100644 (file)
@@ -158,7 +158,14 @@ eoshift1_4 (gfc_array_char *ret,
     {
       /* Do the shift for this dimension.  */
       sh = *hptr;
-      delta = (sh >= 0) ? sh: -sh;
+      if (( sh >= 0 ? sh : -sh ) > len)
+       {
+         delta = len;
+         sh = len;
+       }
+      else
+       delta = (sh >= 0) ? sh: -sh;
+
       if (sh > 0)
         {
           src = &sptr[delta * soffset];
index 379cb4a1b50acb59ed4d7a3d67b9c3c2cd77ce54..3caf66a60900d4c78c9a401b6ee25f4563828e40 100644 (file)
@@ -158,7 +158,14 @@ eoshift1_8 (gfc_array_char *ret,
     {
       /* Do the shift for this dimension.  */
       sh = *hptr;
-      delta = (sh >= 0) ? sh: -sh;
+      if (( sh >= 0 ? sh : -sh ) > len)
+       {
+         delta = len;
+         sh = len;
+       }
+      else
+       delta = (sh >= 0) ? sh: -sh;
+
       if (sh > 0)
         {
           src = &sptr[delta * soffset];
index 4ce66a3059ada10db42e3da968c04937bc9bdb46..1fe4e765c82eaac27b76ff7ff9a0c62e5d466e81 100644 (file)
@@ -167,7 +167,14 @@ eoshift3_4 (gfc_array_char *ret, gfc_array_char *array,
     {
       /* Do the shift for this dimension.  */
       sh = *hptr;
-      delta = (sh >= 0) ? sh: -sh;
+      if (( sh >= 0 ? sh : -sh ) > len)
+       {
+         delta = len;
+         sh = len;
+       }
+      else
+       delta = (sh >= 0) ? sh: -sh;
+
       if (sh > 0)
         {
           src = &sptr[delta * soffset];
index 7e9b911b1a6b8f8ebb7a152bda30fae514b4f586..69ead625577f4fb16661a6dbc1c32e4ff1f4bdbc 100644 (file)
@@ -167,7 +167,14 @@ eoshift3_8 (gfc_array_char *ret, gfc_array_char *array,
     {
       /* Do the shift for this dimension.  */
       sh = *hptr;
-      delta = (sh >= 0) ? sh: -sh;
+      if (( sh >= 0 ? sh : -sh ) > len)
+       {
+         delta = len;
+         sh = len;
+       }
+      else
+       delta = (sh >= 0) ? sh: -sh;
+
       if (sh > 0)
         {
           src = &sptr[delta * soffset];
index b1fbd1a516ade639c6646e3c6b9e912f2519e2d4..6152e9fccbd8ab2e0943ce2960ba966302412756 100644 (file)
@@ -131,10 +131,19 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * array,
   sstride0 = sstride[0];
   rptr = ret->data;
   sptr = array->data;
-  if (shift > 0)
-    len = len - shift;
+
+  if ((shift >= 0 ? shift : -shift) > len)
+    {
+      shift = len;
+      len = 0;
+    }
   else
-    len = len + shift;
+    {
+      if (shift > 0)
+       len = len - shift;
+      else
+       len = len + shift;
+    }
 
   while (rptr)
     {
index 70baf3c18d1524479e8ec405586aeb5cfc01ed84..4e2b41ba7d3fa2a9705c01781777e579b52d00e7 100644 (file)
@@ -139,16 +139,25 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array,
   bstride0 = bstride[0];
   rptr = ret->data;
   sptr = array->data;
+
+  if ((shift >= 0 ? shift : -shift ) > len)
+    {
+      shift = len;
+      len = 0;
+    }
+  else
+    {
+      if (shift > 0)
+       len = len - shift;
+      else
+       len = len + shift;
+    }
+  
   if (bound)
     bptr = bound->data;
   else
     bptr = zeros;
 
-  if (shift > 0)
-    len = len - shift;
-  else
-    len = len + shift;
-
   while (rptr)
     {
       /* Do the shift for this dimension.  */
index 906687ac7ca4d453354b01b4bc7700b887ff5a5e..a650f952a64897e8200902264705d1f8564b2b31 100644 (file)
@@ -159,7 +159,14 @@ eoshift1_`'atype_kind (gfc_array_char *ret,
     {
 `      /* Do the shift for this dimension.  */'
       sh = *hptr;
-      delta = (sh >= 0) ? sh: -sh;
+      if (( sh >= 0 ? sh : -sh ) > len)
+       {
+         delta = len;
+         sh = len;
+       }
+      else
+       delta = (sh >= 0) ? sh: -sh;
+
       if (sh > 0)
         {
           src = &sptr[delta * soffset];
index 24b21cd1531ceaf05c1f8fcd2835ffd6c65c284a..1e04113e12b39f705e25ce398320dbf0f17e3d22 100644 (file)
@@ -168,7 +168,14 @@ eoshift3_`'atype_kind (gfc_array_char *ret, gfc_array_char *array,
     {
 `      /* Do the shift for this dimension.  */'
       sh = *hptr;
-      delta = (sh >= 0) ? sh: -sh;
+      if (( sh >= 0 ? sh : -sh ) > len)
+       {
+         delta = len;
+         sh = len;
+       }
+      else
+       delta = (sh >= 0) ? sh: -sh;
+
       if (sh > 0)
         {
           src = &sptr[delta * soffset];