From 4eef4aad9a4e3edbe01a61f69887a0c9692c95ab Mon Sep 17 00:00:00 2001 From: tkoenig Date: Thu, 7 Jul 2005 22:01:41 +0000 Subject: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101738 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/ChangeLog | 13 +++++++++++++ libgfortran/generated/eoshift1_4.c | 9 ++++++++- libgfortran/generated/eoshift1_8.c | 9 ++++++++- libgfortran/generated/eoshift3_4.c | 9 ++++++++- libgfortran/generated/eoshift3_8.c | 9 ++++++++- libgfortran/intrinsics/eoshift0.c | 15 ++++++++++++--- libgfortran/intrinsics/eoshift2.c | 19 ++++++++++++++----- libgfortran/m4/eoshift1.m4 | 9 ++++++++- libgfortran/m4/eoshift3.m4 | 9 ++++++++- 9 files changed, 87 insertions(+), 14 deletions(-) (limited to 'libgfortran') diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 242bd3c8910..b1256797e62 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,16 @@ +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 Feng Wang PR fortran/16531 diff --git a/libgfortran/generated/eoshift1_4.c b/libgfortran/generated/eoshift1_4.c index cb4dfb5547b..6012c3fe902 100644 --- a/libgfortran/generated/eoshift1_4.c +++ b/libgfortran/generated/eoshift1_4.c @@ -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]; diff --git a/libgfortran/generated/eoshift1_8.c b/libgfortran/generated/eoshift1_8.c index 379cb4a1b50..3caf66a6090 100644 --- a/libgfortran/generated/eoshift1_8.c +++ b/libgfortran/generated/eoshift1_8.c @@ -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]; diff --git a/libgfortran/generated/eoshift3_4.c b/libgfortran/generated/eoshift3_4.c index 4ce66a3059a..1fe4e765c82 100644 --- a/libgfortran/generated/eoshift3_4.c +++ b/libgfortran/generated/eoshift3_4.c @@ -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]; diff --git a/libgfortran/generated/eoshift3_8.c b/libgfortran/generated/eoshift3_8.c index 7e9b911b1a6..69ead625577 100644 --- a/libgfortran/generated/eoshift3_8.c +++ b/libgfortran/generated/eoshift3_8.c @@ -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]; diff --git a/libgfortran/intrinsics/eoshift0.c b/libgfortran/intrinsics/eoshift0.c index b1fbd1a516a..6152e9fccbd 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 70baf3c18d1..4e2b41ba7d3 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. */ diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4 index 906687ac7ca..a650f952a64 100644 --- a/libgfortran/m4/eoshift1.m4 +++ b/libgfortran/m4/eoshift1.m4 @@ -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]; diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4 index 24b21cd1531..1e04113e12b 100644 --- a/libgfortran/m4/eoshift3.m4 +++ b/libgfortran/m4/eoshift3.m4 @@ -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]; -- cgit v1.2.1