diff mbox series

[fortran,committed] Fix PR 83650 on gcc-7

Message ID 94b8f651-3187-dccf-3beb-9e7a5342809e@netcologne.de
State New
Headers show
Series [fortran,committed] Fix PR 83650 on gcc-7 | expand

Commit Message

Thomas Koenig Jan. 2, 2018, 6 p.m. UTC
Hello world,

I have committed the patch below as obvious to fix the
same bug on gcc-7 that my recent patch fixed on trunk.


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.

Regards

	Thomas

Comments

Thomas Koenig Jan. 2, 2018, 10:56 p.m. UTC | #1
Am 02.01.2018 um 19:00 schrieb Thomas Koenig:
> Hello world,
> 
> I have committed the patch below as obvious to fix the
> same bug on gcc-7 that my recent patch fixed on trunk.

... of course, better with a patch which includes
the changes instead of the ChangeLog entries:

Index: fortran/simplify.c
===================================================================
--- fortran/simplify.c  (Revision 256009)
+++ fortran/simplify.c  (Arbeitskopie)
@@ -1991,7 +1991,9 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *sh
        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)
Index: testsuite/gfortran.dg/simplify_cshift_1.f90
===================================================================
--- testsuite/gfortran.dg/simplify_cshift_1.f90 (Revision 256009)
+++ testsuite/gfortran.dg/simplify_cshift_1.f90 (Arbeitskopie)
@@ -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.
diff mbox series

Patch

Index: fortran/ChangeLog
===================================================================
--- fortran/ChangeLog	(Revision 256084)
+++ fortran/ChangeLog	(Arbeitskopie)
@@ -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
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(Revision 256084)
+++ testsuite/ChangeLog	(Arbeitskopie)
@@ -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