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
This commit is contained in:
Tobias Schlüter 2004-05-30 18:33:28 +02:00 committed by Tobias Schlüter
parent d22b7e1406
commit 9471628798
2 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2004-05-30 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/14067
* trans-const.c (gfc_conv_string_init): Allow variable string
length lower than initialization string length.
2004-05-30 Paul Brook <paul@codesourcery.com>
PR fortran/15620

View File

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