diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2005-02-20 17:01:32 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2005-02-20 17:01:32 +0000 |
commit | c5ff069dc46eb81aa4c0732ea5e6f76a535474b2 (patch) | |
tree | 60cdafb935d90504cac1d3437ff96f90d70b9c09 /gcc/c-common.c | |
parent | 5920b5d2e8ead646a8cbb66847a4586b4db16ad6 (diff) | |
download | gcc-c5ff069dc46eb81aa4c0732ea5e6f76a535474b2.zip gcc-c5ff069dc46eb81aa4c0732ea5e6f76a535474b2.tar.gz gcc-c5ff069dc46eb81aa4c0732ea5e6f76a535474b2.tar.bz2 |
re PR middle-end/18785 (isdigit builtin function fails with EBCDIC character sets)
PR 18785
libcpp:
* charset.c (LAST_POSSIBLY_BASIC_SOURCE_CHAR): New helper macro.
(cpp_host_to_exec_charset): New function.
* include/cpplib.h: Declare cpp_host_to_exec_charset.
gcc:
* langhooks.h (struct lang_hooks): Add to_target_charset.
* langhooks.c (lhd_to_target_charset): New function.
* langhooks-def.h: Declare lhd_to_target_charset.
(LANG_HOOKS_TO_TARGET_CHARSET): New macro.
(LANG_HOOKS_INITIALIZER): Update.
* c-common.c (c_common_to_target_charset): New function.
* c-common.h: Declare it.
* c-objc-common.h (LANG_HOOKS_TO_TARGET_CHARSET): Set to
c_common_to_target_charset.
* defaults.c (TARGET_BELL, TARGET_BS, TARGET_CR, TARGET_DIGIT0)
(TARGET_ESC, TARGET_FF, TARGET_NEWLINE, TARGET_TAB, TARGET_VT):
Delete definitions.
* system.h: Poison them.
* doc/tm.texi: Don't discuss them.
* builtins.c (fold_builtin_isdigit): Use lang_hooks.to_target_charset.
* c-pretty-print.c (pp_c_integer_constant): Don't use pp_c_char.
(pp_c_char): Do not attempt to generate letter escapes for
newline, tab, etc.
* config/arm/arm.c (output_ascii_pseudo_op): Likewise.
* config/mips/mips.c (mips_output_ascii): Likewise.
gcc/cp:
* cp-objcp-common.h (LANG_HOOKS_TO_TARGET_CHARSET): Set to
c_common_to_target_charset. Delete bogus comment.
gcc/testsuite:
* gcc.dg/charset/builtin1.c: New test.
From-SVN: r95304
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index b414915..a4dfdd8 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5620,6 +5620,27 @@ c_warn_unused_result (tree *top_p) } } +/* Convert a character from the host to the target execution character + set. cpplib handles this, mostly. */ + +HOST_WIDE_INT +c_common_to_target_charset (HOST_WIDE_INT c) +{ + /* Character constants in GCC proper are sign-extended under -fsigned-char, + zero-extended under -fno-signed-char. cpplib insists that characters + and character constants are always unsigned. Hence we must convert + back and forth. */ + cppchar_t uc = ((cppchar_t)c) & ((((cppchar_t)1) << CHAR_BIT)-1); + + uc = cpp_host_to_exec_charset (parse_in, uc); + + if (flag_signed_char) + return ((HOST_WIDE_INT)uc) << (HOST_BITS_PER_WIDE_INT - CHAR_TYPE_SIZE) + >> (HOST_BITS_PER_WIDE_INT - CHAR_TYPE_SIZE); + else + return uc; +} + /* Build the result of __builtin_offsetof. EXPR is a nested sequence of component references, with an INDIRECT_REF at the bottom; much like the traditional rendering of offsetof as a macro. Returns the folded |