From: Tobias Schlüter Date: Sun, 30 May 2004 16:33:28 +0000 (+0200) Subject: re PR fortran/14067 (no warning when character data statement overflows declared... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9471628798891a7bc2cf21721764520325630c9b;p=gcc.git re PR fortran/14067 (no warning when character data statement overflows declared size) PR fortran/14067 * trans-const.c (gfc_conv_string_init): Allow variable string length lower than initialization string length. From-SVN: r82457 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fa09538d585..f942b17832e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2004-05-30 Tobias Schlueter + + PR fortran/14067 + * trans-const.c (gfc_conv_string_init): Allow variable string + length lower than initialization string length. + 2004-05-30 Paul Brook PR fortran/15620 diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c index 13f6b83c8b3..8a716de6c6c 100644 --- a/gcc/fortran/trans-const.c +++ b/gcc/fortran/trans-const.c @@ -90,7 +90,9 @@ gfc_build_string_const (int length, const char *s) } /* Return a string constant with the given length. Used for static - initializers. The constant will be padded to the full length. */ + initializers. The constant will be padded or truncated to match + length. */ + tree gfc_conv_string_init (tree length, gfc_expr * expr) { @@ -106,8 +108,8 @@ gfc_conv_string_init (tree length, gfc_expr * expr) len = TREE_INT_CST_LOW (length); slen = expr->value.character.length; - assert (len >= slen); - if (len != slen) + + if (len > slen) { s = gfc_getmem (len); memcpy (s, expr->value.character.string, slen);