aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@integrable-solutions.net>2002-08-28 21:41:55 +0000
committerGabriel Dos Reis <gdr@gcc.gnu.org>2002-08-28 21:41:55 +0000
commit585e661a790755c89b9c8563a4bdac785dd89ef3 (patch)
tree2b17511bd36a86a0261dcb0450d11f2c2c443f3a /gcc
parent07ec1151808767a9b8c4bd3dcff336dd68bad454 (diff)
downloadgcc-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')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/c-common.c32
-rw-r--r--gcc/doc/cpp.texi20
3 files changed, 56 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 17b0ffe..223d00d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+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__.
+
2002-08-28 Sylvain Pion <pion@cs.nyu.edu>
* doc/invoke.texi (-Wreorder): Remove remaining pieces from the generic
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. */
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index bb0c39c..0770e41 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -1972,6 +1972,10 @@ unsigned on the target machine. It exists to cause the standard header
file @file{limits.h} to work correctly. You should not use this macro
yourself; instead, refer to the standard macros defined in @file{limits.h}.
+@item __WCHAR_UNSIGNED__
+Like @code{__CHAR_UNSIGNED__}, this macro is defined if and only if the
+data type @code{wchar_t} is unsigned and the front-end is in C++ mode.
+
@item __REGISTER_PREFIX__
This macro expands to a single token (not a string constant) which is
the prefix applied to CPU register names in assembly language for this
@@ -2002,6 +2006,22 @@ typedefs, respectively. They exist to make the standard header files
these macros directly; instead, include the appropriate headers and use
the typedefs.
+@item __CHAR_BIT__
+@itemx __WCHAR_BIT__
+@itemx __SHRT_BIT__
+@itemx __INT_BIT__
+@itemx __LONG_BIT__
+@itemx __LONG_LONG_BIT__
+@itemx __FLOAT_BIT__
+@itemx __DOUBLE_BIT__
+@itemx __LONG_DOUBLE_BIT__
+These macros are defined to the number of bits used in the
+representation of the data types @code{char}, @code{wchar_t},
+@code{short}, @code{int}, @code{long}, @code{long long}, @code{float},
+@code{double} and @code{long double}. They exist to make the standard
+header given numerical limits work correctly. You should not use
+these macros directly; instead, include the appropriate headers.
+
@item __USING_SJLJ_EXCEPTIONS__
This macro is defined, with value 1, if the compiler uses the old
mechanism based on @code{setjmp} and @code{longjmp} for exception