This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[patch, fortran] PR34559 - ICE on REPEAT with empty string literals


gcc/fortran:
2007-12-22  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/34559
	* simplify.c (gfc_simplify_repeat): Added safeguard for empty string
	literals.

gcc/testsuite:
2007-12-22  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/34559
	* gfortran.dg/repeat_6.f90: New test.


Regression tested on i686-pc-linux-gnu. 
Will commit as obvious after 24 hours if no one objects.

Regards
	Daniel
Index: simplify.c
===================================================================
--- simplify.c	(revision 131122)
+++ simplify.c	(working copy)
@@ -3128,7 +3128,9 @@ gfc_simplify_repeat (gfc_expr *e, gfc_ex
   if (e->expr_type != EXPR_CONSTANT)
     return NULL;
 
-  if (len || mpz_sgn (e->ts.cl->length->value.integer) != 0)
+  if (len || 
+      (e->ts.cl->length && 
+       mpz_sgn (e->ts.cl->length->value.integer)) != 0)
     {
       const char *res = gfc_extract_int (n, &ncop);
       gcc_assert (res == NULL);
Index: ../testsuite/gfortran.dg/repeat_6.f90
===================================================================
--- ../testsuite/gfortran.dg/repeat_6.f90	(revision 0)
+++ ../testsuite/gfortran.dg/repeat_6.f90	(revision 0)
@@ -0,0 +1,13 @@
+! { dg-do run }
+!
+! PR34559 -- ICE on empty string literals
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+!
+
+  character(len=200) :: string = "a" // repeat ("", 3)       &
+                                     // repeat ("xxx", 0)    &
+                                     // repeat ("string", 2)
+
+  if (string /= "astringstring") CALL abort()
+end

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