aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-05-03 23:02:49 +0000
committerRichard Stallman <rms@gnu.org>1993-05-03 23:02:49 +0000
commitfe9ef5d7b76fd06c4b39374884e3ef39c23827fb (patch)
tree3d7860d4d1217bc2f0f9b327d482f5c20857d0e7 /gcc
parent22cc53bcef662b3f15055efae4df9ef96a956da5 (diff)
downloadgcc-fe9ef5d7b76fd06c4b39374884e3ef39c23827fb.zip
gcc-fe9ef5d7b76fd06c4b39374884e3ef39c23827fb.tar.gz
gcc-fe9ef5d7b76fd06c4b39374884e3ef39c23827fb.tar.bz2
(digest_init): Check size properly for wide-string.
From-SVN: r4309
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-typeck.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 96c59ec..9a4cdec1 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4829,9 +4829,13 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
{
register int size = TREE_INT_CST_LOW (TYPE_SIZE (type));
size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
- /* Subtract 1 because it's ok to ignore the terminating null char
+ /* Subtract 1 (or sizeof (wchar_t))
+ because it's ok to ignore the terminating null char
that is counted in the length of the constant. */
- if (size < TREE_STRING_LENGTH (string) - 1)
+ if (size < TREE_STRING_LENGTH (string)
+ - (TYPE_PRECISION (typ1) != TYPE_PRECISION (char_type_node)
+ ? TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT
+ : 1))
pedwarn_init (
"initializer-string for array of chars%s is too long",
" `%s'", ofwhat);