diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 46c3207df41..fc48b8b70d7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-01-04 Steven G. Kargl + + 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 PR fortran/83650 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 0078dd9950b..5a6ef8fb029 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -1,5 +1,5 @@ /* Simplify intrinsic functions at compile-time. - Copyright (C) 2000-2017 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. Contributed by Andy Vaught & Katherine Holcomb This file is part of GCC. @@ -1990,13 +1990,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; /* Special case: Shift to the original order! */ - if (sz == 0 || shft % sz == 0) + if (shft % sz == 0) return a; result = gfc_copy_expr (a);