re PR fortran/34559 (ICE using REPEAT on 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.

From-SVN: r131139
This commit is contained in:
Daniel Franke 2007-12-22 17:18:28 -05:00
parent 62ee27a469
commit 111716e0e1
4 changed files with 28 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2007-12-22 Daniel Franke <franke.daniel@gmail.com>
PR fortran/34559
* simplify.c (gfc_simplify_repeat): Added safeguard for empty
string literals.
2007-12-22 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/34549
@ -26,6 +32,7 @@
* module.c (read_module): Check sym->module is there before
using it in a string comparison.
>>>>>>> .r131138
2007-12-20 Tobias Burnus <burnus@net-b.de>
PR fortran/34482

View File

@ -3128,7 +3128,9 @@ gfc_simplify_repeat (gfc_expr *e, gfc_expr *n)
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);

View File

@ -1,3 +1,8 @@
2007-12-22 Daniel Franke <franke.daniel@gmail.com>
PR fortran/34559
* gfortran.dg/repeat_6.f90: New test.
2007-12-22 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/34549

View File

@ -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