This allows to use predefined_ctype() on wchar_t. Note: currently __WCHAR_TYPE__ is defined to 'int' but this is incorrect on: i386, m68k, ppc32, ... Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- char.c | 4 ++-- lib.c | 4 +--- target.c | 3 +-- target.h | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/char.c b/char.c index c52521bc8..f26b2a806 100644 --- a/char.c +++ b/char.c @@ -84,7 +84,7 @@ void get_char_constant(struct token *token, unsigned long long *val) end = p + type - TOKEN_WIDE_CHAR; } p = parse_escape(p, &v, end, - type < TOKEN_WIDE_CHAR ? bits_in_char : bits_in_wchar, token->pos); + type < TOKEN_WIDE_CHAR ? bits_in_char : wchar_ctype->bit_size, token->pos); if (p != end) warning(token->pos, "multi-character character constant"); @@ -113,7 +113,7 @@ struct token *get_string_constant(struct token *token, struct expression *expr) done = next; } } - bits = is_wide ? bits_in_wchar : bits_in_char; + bits = is_wide ? wchar_ctype->bit_size: bits_in_char; while (token != done) { unsigned v; const char *p = token->string->data; diff --git a/lib.c b/lib.c index 89126fb57..0abefa083 100644 --- a/lib.c +++ b/lib.c @@ -1244,14 +1244,12 @@ static void predefined_macros(void) break; } - predefined_sizeof("WCHAR", "_T", bits_in_wchar); - predefined_max("WCHAR", "", bits_in_wchar); - predefined_width("WCHAR", bits_in_wchar); predefine("__CHAR_BIT__", 1, "%d", bits_in_char); predefined_ctype("SHORT", &short_ctype, PTYPE_SIZEOF); predefined_ctype("SHRT", &short_ctype, PTYPE_MAX|PTYPE_WIDTH); predefined_ctype("SCHAR", &char_ctype, PTYPE_MAX|PTYPE_WIDTH); + predefined_ctype("WCHAR", wchar_ctype, PTYPE_ALL_T|PTYPE_TYPE); predefined_ctype("INT", &int_ctype, PTYPE_ALL); predefined_ctype("LONG", &long_ctype, PTYPE_ALL); diff --git a/target.c b/target.c index 86a9e2e63..e09eff865 100644 --- a/target.c +++ b/target.c @@ -5,6 +5,7 @@ struct symbol *size_t_ctype = &uint_ctype; struct symbol *ssize_t_ctype = &int_ctype; +struct symbol *wchar_ctype = &int_ctype; /* * For "__attribute__((aligned))" @@ -22,8 +23,6 @@ int bits_in_long = 32; int bits_in_longlong = 64; int bits_in_longlonglong = 128; -int bits_in_wchar = 32; - int max_int_alignment = 4; /* diff --git a/target.h b/target.h index 8326fa21a..74f51ffeb 100644 --- a/target.h +++ b/target.h @@ -3,6 +3,7 @@ extern struct symbol *size_t_ctype; extern struct symbol *ssize_t_ctype; +extern struct symbol *wchar_ctype; /* * For "__attribute__((aligned))" @@ -20,8 +21,6 @@ extern int bits_in_long; extern int bits_in_longlong; extern int bits_in_longlonglong; -extern int bits_in_wchar; - extern int max_int_alignment; /* -- 2.19.0