This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Committed] PR fortran/77942 -- test for zero


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]