This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Committed] PR fortran/77942 -- test for zero
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 11 Oct 2016 14:47:43 -0700
- Subject: [Committed] PR fortran/77942 -- test for zero
- Authentication-results: sourceware.org; auth=none
- Reply-to: kargl at uw dot edu
Committed to 6-branch and trunk.
2016-10-11 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77942
* simplify.c (gfc_simplify_cshift): Check for zero.
2016-10-11 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77942
* gfortran.dg/pr77942.f90
Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c (revision 241006)
+++ gcc/fortran/simplify.c (working copy)
@@ -1989,7 +1989,7 @@ gfc_simplify_cshift (gfc_expr *array, gf
shft = shft < 0 ? 1 - shft : shft;
/* Special case: Shift to the original order! */
- if (shft % sz == 0)
+ if (sz == 0 || shft % sz == 0)
return a;
result = gfc_copy_expr (a);
Index: gcc/testsuite/gfortran.dg/pr77942.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr77942.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr77942.f90 (working copy)
@@ -0,0 +1,5 @@
+! { dg-do compile }
+program p
+ character, parameter :: c(2) = 'a'
+ print *, cshift(c(2:1), 1)
+end
--
Steve