diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-31 20:30:31 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-31 20:30:31 +0000 |
commit | f3449a3cc72080f8ec407c38393448ca1dd1f6aa (patch) | |
tree | 95ebe0a942d710ca9a7eb0e922e458a37ecf6a02 /gcc/c-common.c | |
parent | 95002c27bc835dcf9ff48b026b0f0113bf6b92fe (diff) | |
download | gcc-f3449a3cc72080f8ec407c38393448ca1dd1f6aa.tar.gz |
PR c/448
fixincludes:
* inclhack.def (newlib_stdint_1, newlib_stdint_2): New fixes.
* fixincl.x: Regenerate.
* tests/base/stdint.h: Update.
gcc:
* Makefile.in (USE_GCC_STDINT): Define.
(stmp-int-hdrs): Install stdint.h if applicable.
* c-common.c (CHAR16_TYPE): Define in terms of UINT_LEAST16_TYPE
if known.
(CHAR32_TYPE): Define in terms of UINT_LEAST32_TYPE if known.
(SIG_ATOMIC_TYPE, INT8_TYPE, INT16_TYPE, INT32_TYPE, INT64_TYPE,
UINT8_TYPE, UINT16_TYPE, UINT32_TYPE, UINT64_TYPE,
INT_LEAST8_TYPE, INT_LEAST16_TYPE, INT_LEAST32_TYPE,
INT_LEAST64_TYPE, UINT_LEAST8_TYPE, UINT_LEAST16_TYPE,
UINT_LEAST32_TYPE, UINT_LEAST64_TYPE, INT_FAST8_TYPE,
INT_FAST16_TYPE, INT_FAST32_TYPE, INT_FAST64_TYPE,
UINT_FAST8_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE,
UINT_FAST64_TYPE, INTPTR_TYPE, UINTPTR_TYPE): Define.
(c_common_nodes_and_builtins): Initialize
underlying_wchar_type_node. Do not initialize
signed_wchar_type_node or unsigned_wchar_type_node. Initialize
nodes for new types.
(c_stddef_cpp_builtins): Define macros for new types.
* c-common.h (CTI_SIGNED_WCHAR_TYPE, CTI_UNSIGNED_WCHAR_TYPE):
Remove.
(CTI_UNDERLYING_WCHAR_TYPE, CTI_SIG_ATOMIC_TYPE, CTI_INT8_TYPE,
CTI_INT16_TYPE, CTI_INT32_TYPE, CTI_INT64_TYPE, CTI_UINT8_TYPE,
CTI_UINT16_TYPE, CTI_UINT32_TYPE, CTI_UINT64_TYPE,
CTI_INT_LEAST8_TYPE, CTI_INT_LEAST16_TYPE, CTI_INT_LEAST32_TYPE,
CTI_INT_LEAST64_TYPE, CTI_UINT_LEAST8_TYPE, CTI_UINT_LEAST16_TYPE,
CTI_UINT_LEAST32_TYPE, CTI_UINT_LEAST64_TYPE, CTI_INT_FAST8_TYPE,
CTI_INT_FAST16_TYPE, CTI_INT_FAST32_TYPE, CTI_INT_FAST64_TYPE,
CTI_UINT_FAST8_TYPE, CTI_UINT_FAST16_TYPE, CTI_UINT_FAST32_TYPE,
CTI_UINT_FAST64_TYPE, CTI_INTPTR_TYPE, CTI_UINTPTR_TYPE): Define.
(signed_wchar_type_node, unsigned_wchar_type_node): Remove.
(underlying_wchar_type_node, sig_atomic_type_node, int8_type_node,
int16_type_node, int32_type_node, int64_type_node,
uint8_type_node, uint16_type_node, c_uint32_type_node,
c_uint64_type_node, int_least8_type_node, int_least16_type_node,
int_least32_type_node, int_least64_type_node,
uint_least8_type_node, uint_least16_type_node,
uint_least32_type_node, uint_least64_type_node,
int_fast8_type_node, int_fast16_type_node, int_fast32_type_node,
int_fast64_type_node, uint_fast8_type_node, uint_fast16_type_node,
uint_fast32_type_node, uint_fast64_type_node, intptr_type_node,
uintptr_type_node): Define.
* c-cppbuiltin.c (builtin_define_constants,
builtin_define_type_minmax): New.
(builtin_define_stdint_macros): Define more macros.
(c_cpp_builtins): Define more limit macros.
(type_suffix): New.
(builtin_define_type_max): Define in terms of
builtin_define_type_minmax. Remove is_long parameter. All
callers changed.
* config.gcc (use_gcc_stdint): Define.
(tm_file): Add glibc-stdint.h for targets using glibc or uClibc.
Add newlib-stdint.h for generic targets.
* config/glibc-stdint.h, config/newlib-stdint.h,
ginclude/stdint-gcc.h, ginclude/stdint-wrap.h: New.
* config/m32c/m32c.h (UINTPTR_TYPE): Define.
* config/score/score.h (UINTPTR_TYPE): Define.
* config/sol2.h (SIG_ATOMIC_TYPE, INT8_TYPE, INT16_TYPE,
INT32_TYPE, INT64_TYPE, UINT8_TYPE, UINT16_TYPE, UINT32_TYPE,
UINT64_TYPE, INT_LEAST8_TYPE, INT_LEAST16_TYPE, INT_LEAST32_TYPE,
INT_LEAST64_TYPE, UINT_LEAST8_TYPE, UINT_LEAST16_TYPE,
UINT_LEAST32_TYPE, UINT_LEAST64_TYPE, INT_FAST8_TYPE,
INT_FAST16_TYPE, INT_FAST32_TYPE, INT_FAST64_TYPE,
UINT_FAST8_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE,
UINT_FAST64_TYPE, INTPTR_TYPE, UINTPTR_TYPE): Define.
* config/spu/spu.h (STDINT_LONG32): Define.
* configure.ac (use_gcc_stdint): Substitute.
* configure: Regenerate.
* doc/cpp.texi (__SIG_ATOMIC_TYPE__, __INT8_TYPE__,
__INT16_TYPE__, __INT32_TYPE__, __INT64_TYPE__, __UINT8_TYPE__,
__UINT16_TYPE__, __UINT32_TYPE__, __UINT64_TYPE__,
__INT_LEAST8_TYPE__, __INT_LEAST16_TYPE__, __INT_LEAST32_TYPE__,
__INT_LEAST64_TYPE__, __UINT_LEAST8_TYPE__, __UINT_LEAST16_TYPE__,
__UINT_LEAST32_TYPE_, __UINT_LEAST64_TYPE__, __INT_FAST8_TYPE__,
__INT_FAST16_TYPE__, __INT_FAST32_TYPE__, __INT_FAST64_TYPE__,
__UINT_FAST8_TYPE__, __UINT_FAST16_TYPE__, __UINT_FAST32_TYPE__,
__UINT_FAST64_TYPE__, __INTPTR_TYPE__, __UINTPTR_TYPE__,
__WINT_MAX__, __SIZE_MAX__, __PTRDIFF_MAX__, __UINTMAX_MAX__,
__SIG_ATOMIC_MAX__, __INT8_MAX__, __INT16_MAX__, __INT32_MAX__,
__INT64_MAX__, __UINT8_MAX__, __UINT16_MAX__, __UINT32_MAX__,
__UINT64_MAX__, __INT_LEAST8_MAX__, __INT_LEAST16_MAX__,
__INT_LEAST32_MAX__, __INT_LEAST64_MAX__, __UINT_LEAST8_MAX__,
__UINT_LEAST16_MAX__, __UINT_LEAST32_MAX__, __UINT_LEAST64_MAX__,
__INT_FAST8_MAX__, __INT_FAST16_MAX__, __INT_FAST32_MAX__,
__INT_FAST64_MAX__, __UINT_FAST8_MAX__, __UINT_FAST16_MAX__,
__UINT_FAST32_MAX__, __UINT_FAST64_MAX__, __INTPTR_MAX__,
__UINTPTR_MAX__, __WCHAR_MIN__, __WINT_MIN__, __SIG_ATOMIC_MIN__,
__INT8_C, __INT16_C, __INT32_C, __INT64_C, __UINT8_C, __UINT16_C,
__UINT32_C, __UINT64_C, __INTMAX_C, __UINTMAX_C): Document.
* doc/tm.texi (SIG_ATOMIC_TYPE, INT8_TYPE, INT16_TYPE, INT32_TYPE,
INT64_TYPE, UINT8_TYPE, UINT16_TYPE, UINT32_TYPE, UINT64_TYPE,
INT_LEAST8_TYPE, INT_LEAST16_TYPE, INT_LEAST32_TYPE,
INT_LEAST64_TYPE, UINT_LEAST8_TYPE, UINT_LEAST16_TYPE,
UINT_LEAST32_TYPE, UINT_LEAST64_TYPE, INT_FAST8_TYPE,
INT_FAST16_TYPE, INT_FAST32_TYPE, INT_FAST64_TYPE,
UINT_FAST8_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE,
UINT_FAST64_TYPE, INTPTR_TYPE, UINTPTR_TYPE): Document.
gcc/testsuite:
* lib/target-supports.exp (check_effective_target_stdint_types):
Update comment.
(check_effective_target_inttypes_types): New.
* gcc.dg/c99-stdint-1.c, gcc.dg/c99-stdint-2.c,
gcc.dg/c99-stdint-3.c, gcc.dg/c99-stdint-4.c,
gcc.dg/c99-stdint-5.c, gcc.dg/c99-stdint-6.c: New tests.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145372 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 272 |
1 files changed, 261 insertions, 11 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index f0c312244b2..8b05a40ef72 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -69,11 +69,21 @@ cpp_reader *parse_in; /* Declared in c-pragma.h. */ #define PID_TYPE "int" #endif -#ifndef CHAR16_TYPE +/* If GCC knows the exact uint_least16_t and uint_least32_t types from + <stdint.h>, use them for char16_t and char32_t. Otherwise, use + these guesses; getting the wrong type of a given width will not + affect C++ name mangling because in C++ these are distinct types + not typedefs. */ + +#ifdef UINT_LEAST16_TYPE +#define CHAR16_TYPE UINT_LEAST16_TYPE +#else #define CHAR16_TYPE "short unsigned int" #endif -#ifndef CHAR32_TYPE +#ifdef UINT_LEAST32_TYPE +#define CHAR32_TYPE UINT_LEAST32_TYPE +#else #define CHAR32_TYPE "unsigned int" #endif @@ -109,6 +119,116 @@ cpp_reader *parse_in; /* Declared in c-pragma.h. */ : "long long unsigned int")) #endif +/* There are no default definitions of these <stdint.h> types. */ + +#ifndef SIG_ATOMIC_TYPE +#define SIG_ATOMIC_TYPE ((const char *) NULL) +#endif + +#ifndef INT8_TYPE +#define INT8_TYPE ((const char *) NULL) +#endif + +#ifndef INT16_TYPE +#define INT16_TYPE ((const char *) NULL) +#endif + +#ifndef INT32_TYPE +#define INT32_TYPE ((const char *) NULL) +#endif + +#ifndef INT64_TYPE +#define INT64_TYPE ((const char *) NULL) +#endif + +#ifndef UINT8_TYPE +#define UINT8_TYPE ((const char *) NULL) +#endif + +#ifndef UINT16_TYPE +#define UINT16_TYPE ((const char *) NULL) +#endif + +#ifndef UINT32_TYPE +#define UINT32_TYPE ((const char *) NULL) +#endif + +#ifndef UINT64_TYPE +#define UINT64_TYPE ((const char *) NULL) +#endif + +#ifndef INT_LEAST8_TYPE +#define INT_LEAST8_TYPE ((const char *) NULL) +#endif + +#ifndef INT_LEAST16_TYPE +#define INT_LEAST16_TYPE ((const char *) NULL) +#endif + +#ifndef INT_LEAST32_TYPE +#define INT_LEAST32_TYPE ((const char *) NULL) +#endif + +#ifndef INT_LEAST64_TYPE +#define INT_LEAST64_TYPE ((const char *) NULL) +#endif + +#ifndef UINT_LEAST8_TYPE +#define UINT_LEAST8_TYPE ((const char *) NULL) +#endif + +#ifndef UINT_LEAST16_TYPE +#define UINT_LEAST16_TYPE ((const char *) NULL) +#endif + +#ifndef UINT_LEAST32_TYPE +#define UINT_LEAST32_TYPE ((const char *) NULL) +#endif + +#ifndef UINT_LEAST64_TYPE +#define UINT_LEAST64_TYPE ((const char *) NULL) +#endif + +#ifndef INT_FAST8_TYPE +#define INT_FAST8_TYPE ((const char *) NULL) +#endif + +#ifndef INT_FAST16_TYPE +#define INT_FAST16_TYPE ((const char *) NULL) +#endif + +#ifndef INT_FAST32_TYPE +#define INT_FAST32_TYPE ((const char *) NULL) +#endif + +#ifndef INT_FAST64_TYPE +#define INT_FAST64_TYPE ((const char *) NULL) +#endif + +#ifndef UINT_FAST8_TYPE +#define UINT_FAST8_TYPE ((const char *) NULL) +#endif + +#ifndef UINT_FAST16_TYPE +#define UINT_FAST16_TYPE ((const char *) NULL) +#endif + +#ifndef UINT_FAST32_TYPE +#define UINT_FAST32_TYPE ((const char *) NULL) +#endif + +#ifndef UINT_FAST64_TYPE +#define UINT_FAST64_TYPE ((const char *) NULL) +#endif + +#ifndef INTPTR_TYPE +#define INTPTR_TYPE ((const char *) NULL) +#endif + +#ifndef UINTPTR_TYPE +#define UINTPTR_TYPE ((const char *) NULL) +#endif + /* The following symbols are subsumed in the c_global_trees array, and listed here individually for documentation purposes. @@ -131,8 +251,6 @@ cpp_reader *parse_in; /* Declared in c-pragma.h. */ tree unsigned_char_type_node; tree signed_char_type_node; tree wchar_type_node; - tree signed_wchar_type_node; - tree unsigned_wchar_type_node; tree char16_type_node; tree char32_type_node; @@ -4762,6 +4880,7 @@ c_common_nodes_and_builtins (void) wchar_type_node = get_identifier (MODIFIED_WCHAR_TYPE); wchar_type_node = TREE_TYPE (identifier_global_value (wchar_type_node)); wchar_type_size = TYPE_PRECISION (wchar_type_node); + underlying_wchar_type_node = wchar_type_node; if (c_dialect_cxx ()) { if (TYPE_UNSIGNED (wchar_type_node)) @@ -4770,11 +4889,6 @@ c_common_nodes_and_builtins (void) wchar_type_node = make_signed_type (wchar_type_size); record_builtin_type (RID_WCHAR, "wchar_t", wchar_type_node); } - else - { - signed_wchar_type_node = c_common_signed_type (wchar_type_node); - unsigned_wchar_type_node = c_common_unsigned_type (wchar_type_node); - } /* This is for wide string constants. */ wchar_array_type_node @@ -4820,6 +4934,88 @@ c_common_nodes_and_builtins (void) uintmax_type_node = TREE_TYPE (identifier_global_value (get_identifier (UINTMAX_TYPE))); + if (SIG_ATOMIC_TYPE) + sig_atomic_type_node = + TREE_TYPE (identifier_global_value (get_identifier (SIG_ATOMIC_TYPE))); + if (INT8_TYPE) + int8_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT8_TYPE))); + if (INT16_TYPE) + int16_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT16_TYPE))); + if (INT32_TYPE) + int32_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT32_TYPE))); + if (INT64_TYPE) + int64_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT64_TYPE))); + if (UINT8_TYPE) + uint8_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT8_TYPE))); + if (UINT16_TYPE) + uint16_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT16_TYPE))); + if (UINT32_TYPE) + c_uint32_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT32_TYPE))); + if (UINT64_TYPE) + c_uint64_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT64_TYPE))); + if (INT_LEAST8_TYPE) + int_least8_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT_LEAST8_TYPE))); + if (INT_LEAST16_TYPE) + int_least16_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT_LEAST16_TYPE))); + if (INT_LEAST32_TYPE) + int_least32_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT_LEAST32_TYPE))); + if (INT_LEAST64_TYPE) + int_least64_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT_LEAST64_TYPE))); + if (UINT_LEAST8_TYPE) + uint_least8_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT_LEAST8_TYPE))); + if (UINT_LEAST16_TYPE) + uint_least16_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT_LEAST16_TYPE))); + if (UINT_LEAST32_TYPE) + uint_least32_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT_LEAST32_TYPE))); + if (UINT_LEAST64_TYPE) + uint_least64_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT_LEAST64_TYPE))); + if (INT_FAST8_TYPE) + int_fast8_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT_FAST8_TYPE))); + if (INT_FAST16_TYPE) + int_fast16_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT_FAST16_TYPE))); + if (INT_FAST32_TYPE) + int_fast32_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT_FAST32_TYPE))); + if (INT_FAST64_TYPE) + int_fast64_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INT_FAST64_TYPE))); + if (UINT_FAST8_TYPE) + uint_fast8_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT_FAST8_TYPE))); + if (UINT_FAST16_TYPE) + uint_fast16_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT_FAST16_TYPE))); + if (UINT_FAST32_TYPE) + uint_fast32_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT_FAST32_TYPE))); + if (UINT_FAST64_TYPE) + uint_fast64_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINT_FAST64_TYPE))); + if (INTPTR_TYPE) + intptr_type_node = + TREE_TYPE (identifier_global_value (get_identifier (INTPTR_TYPE))); + if (UINTPTR_TYPE) + uintptr_type_node = + TREE_TYPE (identifier_global_value (get_identifier (UINTPTR_TYPE))); + default_function_type = build_function_type (integer_type_node, NULL_TREE); ptrdiff_type_node = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE))); @@ -5522,8 +5718,8 @@ boolean_increment (enum tree_code code, tree arg) return val; } -/* Built-in macros for stddef.h, that require macros defined in this - file. */ +/* Built-in macros for stddef.h and stdint.h, that require macros + defined in this file. */ void c_stddef_cpp_builtins(void) { @@ -5535,6 +5731,60 @@ c_stddef_cpp_builtins(void) builtin_define_with_value ("__UINTMAX_TYPE__", UINTMAX_TYPE, 0); builtin_define_with_value ("__CHAR16_TYPE__", CHAR16_TYPE, 0); builtin_define_with_value ("__CHAR32_TYPE__", CHAR32_TYPE, 0); + if (SIG_ATOMIC_TYPE) + builtin_define_with_value ("__SIG_ATOMIC_TYPE__", SIG_ATOMIC_TYPE, 0); + if (INT8_TYPE) + builtin_define_with_value ("__INT8_TYPE__", INT8_TYPE, 0); + if (INT16_TYPE) + builtin_define_with_value ("__INT16_TYPE__", INT16_TYPE, 0); + if (INT32_TYPE) + builtin_define_with_value ("__INT32_TYPE__", INT32_TYPE, 0); + if (INT64_TYPE) + builtin_define_with_value ("__INT64_TYPE__", INT64_TYPE, 0); + if (UINT8_TYPE) + builtin_define_with_value ("__UINT8_TYPE__", UINT8_TYPE, 0); + if (UINT16_TYPE) + builtin_define_with_value ("__UINT16_TYPE__", UINT16_TYPE, 0); + if (UINT32_TYPE) + builtin_define_with_value ("__UINT32_TYPE__", UINT32_TYPE, 0); + if (UINT64_TYPE) + builtin_define_with_value ("__UINT64_TYPE__", UINT64_TYPE, 0); + if (INT_LEAST8_TYPE) + builtin_define_with_value ("__INT_LEAST8_TYPE__", INT_LEAST8_TYPE, 0); + if (INT_LEAST16_TYPE) + builtin_define_with_value ("__INT_LEAST16_TYPE__", INT_LEAST16_TYPE, 0); + if (INT_LEAST32_TYPE) + builtin_define_with_value ("__INT_LEAST32_TYPE__", INT_LEAST32_TYPE, 0); + if (INT_LEAST64_TYPE) + builtin_define_with_value ("__INT_LEAST64_TYPE__", INT_LEAST64_TYPE, 0); + if (UINT_LEAST8_TYPE) + builtin_define_with_value ("__UINT_LEAST8_TYPE__", UINT_LEAST8_TYPE, 0); + if (UINT_LEAST16_TYPE) + builtin_define_with_value ("__UINT_LEAST16_TYPE__", UINT_LEAST16_TYPE, 0); + if (UINT_LEAST32_TYPE) + builtin_define_with_value ("__UINT_LEAST32_TYPE__", UINT_LEAST32_TYPE, 0); + if (UINT_LEAST64_TYPE) + builtin_define_with_value ("__UINT_LEAST64_TYPE__", UINT_LEAST64_TYPE, 0); + if (INT_FAST8_TYPE) + builtin_define_with_value ("__INT_FAST8_TYPE__", INT_FAST8_TYPE, 0); + if (INT_FAST16_TYPE) + builtin_define_with_value ("__INT_FAST16_TYPE__", INT_FAST16_TYPE, 0); + if (INT_FAST32_TYPE) + builtin_define_with_value ("__INT_FAST32_TYPE__", INT_FAST32_TYPE, 0); + if (INT_FAST64_TYPE) + builtin_define_with_value ("__INT_FAST64_TYPE__", INT_FAST64_TYPE, 0); + if (UINT_FAST8_TYPE) + builtin_define_with_value ("__UINT_FAST8_TYPE__", UINT_FAST8_TYPE, 0); + if (UINT_FAST16_TYPE) + builtin_define_with_value ("__UINT_FAST16_TYPE__", UINT_FAST16_TYPE, 0); + if (UINT_FAST32_TYPE) + builtin_define_with_value ("__UINT_FAST32_TYPE__", UINT_FAST32_TYPE, 0); + if (UINT_FAST64_TYPE) + builtin_define_with_value ("__UINT_FAST64_TYPE__", UINT_FAST64_TYPE, 0); + if (INTPTR_TYPE) + builtin_define_with_value ("__INTPTR_TYPE__", INTPTR_TYPE, 0); + if (UINTPTR_TYPE) + builtin_define_with_value ("__UINTPTR_TYPE__", UINTPTR_TYPE, 0); } static void |