re PR fortran/83650 (Wrong simplification in cshift with negative shifts)

2018-01-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/83650
	* simplify.c (gfc_simplify_cshift): Correct contition for
	negative shifts.

2018-01-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/83650
	* gfortran.dg/simplify_cshift_1.f90: Correct condition.

From-SVN: r256085
This commit is contained in:
Thomas Koenig 2018-01-02 18:01:31 +00:00
parent 22be5165e0
commit 52535f91db
4 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2018-01-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/83650
* simplify.c (gfc_simplify_cshift): Correct contition for
negative shifts.
2017-12-28 Steven G. Kargl <kargl@gcc.gnu.org>
PR Fortran/83548

View File

@ -1991,7 +1991,9 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim)
mpz_clear (size);
/* Adjust shft to deal with right or left shifts. */
shft = shft < 0 ? 1 - shft : shft;
shft = shft % sz;
if (shft < 0)
shft += sz;
/* Special case: Shift to the original order! */
if (sz == 0 || shft % sz == 0)

View File

@ -1,3 +1,8 @@
2018-01-02 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/83650
* gfortran.dg/simplify_cshift_1.f90: Correct condition.
2018-01-01 Jakub Jelinek <jakub@redhat.com>
PR middle-end/83608

View File

@ -23,12 +23,12 @@ program foo
v = cshift(c, 2)
if (any(b /= v)) call abort
! Special cases shift = 0, size(a), 1-size(a)
! Special cases shift = 0, size(a), size(a)
b = cshift([1, 2, 3, 4, 5], 0)
if (any(b /= a)) call abort
b = cshift([1, 2, 3, 4, 5], size(a))
if (any(b /= a)) call abort
b = cshift([1, 2, 3, 4, 5], 1-size(a))
b = cshift([1, 2, 3, 4, 5], -size(a))
if (any(b /= a)) call abort
! simplification of array arg.