From 58929d71e1e3db9ffa2ac900e87c7905d5f4c4ff Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 4 Jan 2018 20:16:23 +0000 Subject: [PATCH] re PR fortran/83679 (r256113 causes regression on pr77942.f90) 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. From-SVN: r256263 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/simplify.c | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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);