+2002-02-24 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * cpplex.c (cpp_interpret_charconst): Get signedness or
+ otherwise of wide character constants correct.
+ * cppexp.c (lex): Get signedness of wide charconsts correct.
+
Sun Feb 24 07:41:31 2002 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* optabs.c (widen_operand): Only call convert_modes for
{
unsigned int chars_seen;
- /* This is always a signed type. */
- op.unsignedp = 0;
+ if (token->type == CPP_CHAR)
+ op.unsignedp = 0;
+ else
+ op.unsignedp = WCHAR_UNSIGNED;
op.op = CPP_NUMBER;
op.value = cpp_interpret_charconst (pfile, token, 1, 0, &chars_seen);
return op;
unsigned int width, max_chars, c;
unsigned HOST_WIDE_INT mask;
HOST_WIDE_INT result = 0;
+ bool unsigned_p;
#ifdef MULTIBYTE_CHARS
(void) local_mbtowc (NULL, NULL, 0);
/* Width in bits. */
if (token->type == CPP_CHAR)
- width = MAX_CHAR_TYPE_SIZE;
+ {
+ width = MAX_CHAR_TYPE_SIZE;
+ unsigned_p = CPP_OPTION (pfile, signed_char) == 0;
+ }
else
- width = MAX_WCHAR_TYPE_SIZE;
+ {
+ width = MAX_WCHAR_TYPE_SIZE;
+ unsigned_p = WCHAR_UNSIGNED;
+ }
if (width < HOST_BITS_PER_WIDE_INT)
mask = ((unsigned HOST_WIDE_INT) 1 << width) - 1;
else if (chars_seen > 1 && !traditional && warn_multi)
cpp_warning (pfile, "multi-character character constant");
- /* If char type is signed, sign-extend the constant. */
- if (token->type == CPP_CHAR && chars_seen)
+ /* If relevant type is signed, sign-extend the constant. */
+ if (chars_seen)
{
unsigned int nbits = chars_seen * width;
mask = (unsigned HOST_WIDE_INT) ~0 >> (HOST_BITS_PER_WIDE_INT - nbits);
- if (CPP_OPTION (pfile, signed_char) == 0
- || ((result >> (nbits - 1)) & 1) == 0)
+ if (unsigned_p || ((result >> (nbits - 1)) & 1) == 0)
result &= mask;
else
result |= ~mask;