From 47b3a403a5b5424d15829d47abd4cb1a8a87e93e Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Thu, 7 Jul 2005 22:01:41 +0000 Subject: re PR fortran/21594 ([4.0 only] FAIL: gfortran.dg/eoshift.f90 -O0 execution test) 2005-07-07 Thomas Koenig 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 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 --- libgfortran/intrinsics/eoshift0.c | 15 ++++++++++++--- libgfortran/intrinsics/eoshift2.c | 19 ++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'libgfortran/intrinsics') diff --git a/libgfortran/intrinsics/eoshift0.c b/libgfortran/intrinsics/eoshift0.c index b1fbd1a..6152e9f 100644 --- a/libgfortran/intrinsics/eoshift0.c +++ b/libgfortran/intrinsics/eoshift0.c @@ -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) { diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c index 70baf3c..4e2b41b 100644 --- a/libgfortran/intrinsics/eoshift2.c +++ b/libgfortran/intrinsics/eoshift2.c @@ -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. */ -- cgit v1.1