]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/83679 (r256113 causes regression on pr77942.f90)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 4 Jan 2018 20:18:58 +0000 (20:18 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 4 Jan 2018 20:18:58 +0000 (20:18 +0000)
2018-01-04  Steven G. Kargl  <kargl@gcc.gnu.org>

PR Fortran/83679
* simplify.c (gfc_simplify_cshift): Restore early return for zero-sized
array.  Update Copyright year while here.

From-SVN: r256264

gcc/fortran/ChangeLog
gcc/fortran/simplify.c

index 18d014e02937c88805017993d95370809f1db6c3..11095e9f17d2950b68e972e88de5db4a52e3101e 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-04  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR Fortran/83679
+       * simplify.c (gfc_simplify_cshift): Restore early return for zero-sized
+       array.  Update Copyright year while here.
+
 2018-01-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from 7-branch
index ea7a7464421387201d60bd4869f36aa053eac5c1..c9a6dd55b463054ac2559e7ee5b6ecf14fa95514 100644 (file)
@@ -1,5 +1,5 @@
 /* Simplify intrinsic functions at compile-time.
-   Copyright (C) 2000-2016 Free Software Foundation, Inc.
+   Copyright (C) 2000-2016, 2018 Free Software Foundation, Inc.
    Contributed by Andy Vaught & Katherine Holcomb
 
 This file is part of GCC.
@@ -1838,13 +1838,17 @@ gfc_simplify_cshift (gfc_expr *array, gfc_expr *shift, gfc_expr *dim)
       sz = mpz_get_si (size);
       mpz_clear (size);
 
+      /* Special case: Zero-sized array.  */
+      if (sz == 0)
+       return a;
+
       /* Adjust shft to deal with right or left shifts. */
       shft = shft % sz;
       if (shft < 0)
-       shft += sz;
+       shft += sz;
 
       /* Special case: Shift to the original order!  */
-      if (sz == 0 || shft % sz == 0)
+      if (shft % sz == 0)
        return a;
 
       result = gfc_copy_expr (a);