diff options
author | Gabriel Dos Reis <gdr@integrable-solutions.net> | 2002-08-28 21:41:55 +0000 |
---|---|---|
committer | Gabriel Dos Reis <gdr@gcc.gnu.org> | 2002-08-28 21:41:55 +0000 |
commit | 585e661a790755c89b9c8563a4bdac785dd89ef3 (patch) | |
tree | 2b17511bd36a86a0261dcb0450d11f2c2c443f3a /gcc/c-common.c | |
parent | 07ec1151808767a9b8c4bd3dcff336dd68bad454 (diff) | |
download | gcc-585e661a790755c89b9c8563a4bdac785dd89ef3.zip gcc-585e661a790755c89b9c8563a4bdac785dd89ef3.tar.gz gcc-585e661a790755c89b9c8563a4bdac785dd89ef3.tar.bz2 |
c-common.c (builtin_define_type_precision): New function.
gcc/
2002-08-28 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-common.c (builtin_define_type_precision): New function.
(cb_register_builtins): Use it. Define __WCHAR_UNSIGNED__ is
wchar_t is unsigned in C++.
* doc/cpp.texi (Common Predefined Macros): Document
__WCHAR_UNSIGNED__, __CHAR_BIT__, __WCHAR_BIT__, __SHRT_BIT__,
__INT_BIT__, __LONG_BIT__, __LONG_LONG_BIT__, __FLOAT_BIT__,
__DOUBLE_BIT__, __LONG_DOUBLE_BIT__.
libstdc++-v3/
2002-08-28 Gabriel Dos Reis <gdr@integrable-solutions.net>
* include/std/std_limits.h (__glibcpp_char_bits,
__glibcpp_short_bits, __glibcpp_int_bits,
__glibcpp_long_bits,
__glibcpp_long_long_bits, __glibcpp_float_bits,
__glibcpp_double_bits, __glibcpp_long_double_bits):
Remove. Use
compiler predifined macros.
(__glibcpp_wchar_t_is_signed): Define based on compiler
predefined
__WCHAR_UNSIGNED__.
From-SVN: r56646
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 913aec1..4587991 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -760,9 +760,10 @@ static bool get_nonnull_operand PARAMS ((tree, unsigned HOST_WIDE_INT *)); void builtin_define_std PARAMS ((const char *)); static void builtin_define_with_value PARAMS ((const char *, const char *, - int)); + int)); static void builtin_define_type_max PARAMS ((const char *, tree, int)); static void cpp_define_data_format PARAMS ((cpp_reader *)); +static void builtin_define_type_precision PARAMS ((const char *, tree)); /* Table of machine-independent attributes common to all C-like languages. */ const struct attribute_spec c_common_attribute_table[] = @@ -4765,6 +4766,17 @@ cpp_define_data_format (pfile) builtin_define_with_value ("__GCC_FLOAT_FORMAT__", format, 0); } +/* Define NAME with value TYPE precision. */ +static void +builtin_define_type_precision (name, type) + const char *name; + tree type; +{ + char buf[8]; + sprintf (buf, "%d", (int) TYPE_PRECISION (type)); + builtin_define_with_value (name, buf, 0); +} + /* Hook that registers front end and target-specific built-ins. */ void cb_register_builtins (pfile) @@ -4807,11 +4819,16 @@ cb_register_builtins (pfile) builtin_define_type_max ("__LONG_MAX__", long_integer_type_node, 1); builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node, 2); - { - char buf[8]; - sprintf (buf, "%d", (int) TYPE_PRECISION (signed_char_type_node)); - builtin_define_with_value ("__CHAR_BIT__", buf, 0); - } + builtin_define_type_precision ("__CHAR_BIT__", char_type_node); + builtin_define_type_precision ("__WCHAR_BIT__", wchar_type_node); + builtin_define_type_precision ("__SHRT_BIT__", short_integer_type_node); + builtin_define_type_precision ("__INT_BIT__", integer_type_node); + builtin_define_type_precision ("__LONG_BIT__", long_integer_type_node); + builtin_define_type_precision ("__LONG_LONG_BIT__", + long_long_integer_type_node); + builtin_define_type_precision ("__FLOAT_BIT__", float_type_node); + builtin_define_type_precision ("__DOUBLE_BIT__", double_type_node); + builtin_define_type_precision ("__LONG_DOUBLE_BIT__", long_double_type_node); /* For use in assembly language. */ builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); @@ -4849,6 +4866,9 @@ cb_register_builtins (pfile) if (!flag_signed_char) cpp_define (pfile, "__CHAR_UNSIGNED__"); + if (c_language == clk_cplusplus && TREE_UNSIGNED (wchar_type_node)) + cpp_define (pfile, "__WCHAR_UNSIGNED__"); + cpp_define_data_format (pfile); /* Make the choice of ObjC runtime visible to source code. */ |