summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/cpplex.c
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2002-05-09 20:02:13 +0000
committerobrien <obrien@FreeBSD.org>2002-05-09 20:02:13 +0000
commitc8f5fc7032940ad6633f932ac40cade82ec4d0cc (patch)
tree29a0f0a6c79a69ecc64f612947a0fe5904311713 /contrib/gcc/cpplex.c
parentc9ab9ae440a8066b2c2b85b157b1fdadcf09916a (diff)
downloadFreeBSD-src-c8f5fc7032940ad6633f932ac40cade82ec4d0cc.zip
FreeBSD-src-c8f5fc7032940ad6633f932ac40cade82ec4d0cc.tar.gz
Gcc 3.1.0 pre-release from the FSF anoncvs repo on 9-May-2002 15:57:15 EDT.
Diffstat (limited to 'contrib/gcc/cpplex.c')
-rw-r--r--contrib/gcc/cpplex.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/contrib/gcc/cpplex.c b/contrib/gcc/cpplex.c
index 8465350..eea6a9e 100644
--- a/contrib/gcc/cpplex.c
+++ b/contrib/gcc/cpplex.c
@@ -1837,6 +1837,7 @@ cpp_interpret_charconst (pfile, token, warn_multi, traditional, pchars_seen)
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);
@@ -1844,9 +1845,15 @@ cpp_interpret_charconst (pfile, token, warn_multi, traditional, pchars_seen)
/* 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;
@@ -1903,15 +1910,13 @@ cpp_interpret_charconst (pfile, token, warn_multi, traditional, pchars_seen)
else if (chars_seen > 1 && !traditional && warn_multi)
cpp_warning (pfile, "multi-character character constant");
- /* If char type is signed, sign-extend the constant. The
- __CHAR_UNSIGNED__ macro is set by the driver if appropriate. */
- 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 (pfile->spec_nodes.n__CHAR_UNSIGNED__->type == NT_MACRO
- || ((result >> (nbits - 1)) & 1) == 0)
+ if (unsigned_p || ((result >> (nbits - 1)) & 1) == 0)
result &= mask;
else
result |= ~mask;
OpenPOWER on IntegriCloud