aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppexp.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2002-05-06 22:53:10 +0000
committerNeil Booth <neil@gcc.gnu.org>2002-05-06 22:53:10 +0000
commita5a49440f74e957e418360804bf270a8ebc9ad8e (patch)
tree3f56b583072218fe62c5e65ab9af8fa0eb09165a /gcc/cppexp.c
parentd7ee9f9fa759ab04e844982d8818001f6ba7d4cd (diff)
downloadgcc-a5a49440f74e957e418360804bf270a8ebc9ad8e.zip
gcc-a5a49440f74e957e418360804bf270a8ebc9ad8e.tar.gz
gcc-a5a49440f74e957e418360804bf270a8ebc9ad8e.tar.bz2
c-common.c (warn_multichar): New.
* c-common.c (warn_multichar): New. (c_common_init): Set CPP's warn_multichar. * c-common.h (warn_multichar): New. * c-decl.c (warn_multichar): Remove. * c-lex.c (lex_charconst): Update. * c-tree.h (warn_multichar): Remove. * cppexp.c (eval_token): Sign-extend charconst value. * cppinit.c (cpp_create_reader): Set warn_multichar. * cpplex.c (cpp_interpret_charconst): Don't sign-extend each character. Update prototype. Sign-extend the result. * cpplib.h: Fix conditions. (struct cpp_options): Add new warning flag. (cpp_interpret_charconst): Update prototype. cp: * Make-lang.in (decl2.o): Update. * cp-tree.h (warn_multichar): Remove. * decl2.c: Include c-common.h. (warn_multichar): Remove. doc: * cpp.texi: Update documentation. testsuite: * gcc.dg/cpp/charconst-3.c: Correct tests accordingly. From-SVN: r53240
Diffstat (limited to 'gcc/cppexp.c')
-rw-r--r--gcc/cppexp.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/cppexp.c b/gcc/cppexp.c
index b71b02a..288cdd4 100644
--- a/gcc/cppexp.c
+++ b/gcc/cppexp.c
@@ -295,7 +295,16 @@ eval_token (pfile, token)
case CPP_WCHAR:
case CPP_CHAR:
- op.value = cpp_interpret_charconst (pfile, token, 1, &temp, &unsignedp);
+ {
+ cppchar_t result = cpp_interpret_charconst (pfile, token,
+ &temp, &unsignedp);
+ op.value = result;
+ /* Sign-extend the result if necessary. */
+ if (!unsignedp && (cppchar_signed_t) result < 0
+ && sizeof (HOST_WIDEST_INT) > sizeof (cppchar_t))
+ op.value |= ~(((unsigned HOST_WIDEST_INT) 1 << BITS_PER_CPPCHAR_T)
+ - 1);
+ }
break;
case CPP_NAME: