wchar character constant sizes
Andrew Macleod
amacleod@cygnus.com
Tue Apr 24 09:22:00 GMT 2001
While attempting to get sparc64 configured, Ive run across a slight
hiccup while compiling libstdc++. The test case reduces down to :
char m () {
char x;
x = L'.';
return x;
}
When compiled, this produces:
char m()
test.C:4: character constant too long
char m()
The problem appears to be that c-lex.c::lex_charconst isn't calculating max_chars based on
the wchar_type, but rather from the integer type as for C.
And by they way, is there a good reason that c-lex.c throws away the definition
of WCHAR_TYPE_SIZE instead of using what a port sets it as?
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE TYPE_PRECISION (wchar_type_node)
Anyway, This fixes my problem for sparc64-solaris. Bootstraps and everything on sparc and x86.
seem reasonable?
Andrew
* c-lex.c (lex_charconst): When compiling for c++, set max_chars based
on WCHAR_TYPE.
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lex.c,v
retrieving revision 1.133
diff -c -p -r1.133 c-lex.c
*** c-lex.c 2001/03/07 01:31:59 1.133
--- c-lex.c 2001/04/24 14:34:38
*************** lex_charconst (str, len, wide)
*** 1629,1635 ****
max_chars = TYPE_PRECISION (integer_type_node) / width;
if (wide)
! width = WCHAR_TYPE_SIZE;
while (str < limit)
{
--- 1629,1638 ----
max_chars = TYPE_PRECISION (integer_type_node) / width;
if (wide)
! {
! width = WCHAR_TYPE_SIZE;
! max_chars = WCHAR_BYTES;
! }
while (str < limit)
{
More information about the Gcc-patches
mailing list