diff options
author | Zack Weinberg <zack@codesourcery.com> | 2002-05-15 05:30:01 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2002-05-15 05:30:01 +0000 |
commit | a11eba953e31ffadb5bf0f943320c200577c955e (patch) | |
tree | 576aea20e1d126c2bd484da7831e462f3b570f4c /gcc/c-common.c | |
parent | 1c31ecf66502d28461ea45a8242a5c6e10beb7f2 (diff) | |
download | gcc-a11eba953e31ffadb5bf0f943320c200577c955e.zip gcc-a11eba953e31ffadb5bf0f943320c200577c955e.tar.gz gcc-a11eba953e31ffadb5bf0f943320c200577c955e.tar.bz2 |
c-parse.in (MODIFIED_WCHAR_TYPE): New macro.
* c-parse.in (MODIFIED_WCHAR_TYPE): New macro.
(c_common_nodes_and_builtins): Use it.
(builtin_define_with_value): New function.
(cb_register_builtins): Define __SIZE_TYPE__,
__PTRDIFF_TYPE__, __WCHAR_TYPE__, and __WINT_TYPE__ here,
using builtin_define_with_value. Use consistent notation when
defining __GXX_WEAK__.
(WCHAR_TYPE_SIZE): Don't redefine.
(combine_strings): Don't use WCHAR_TYPE_SIZE.
* cppdefault.h: Don't provide defaults for SIZE_TYPE,
PTRDIFF_TYPE, WCHAR_TYPE, or WINT_TYPE.
* cppinit.c (builtin_array): Remove entries for __SIZE_TYPE__ etc.
* tradcpp.c (initialize_builtins): Likewise.
* gcc.c (cpp_unique_options): Don't muck with __WCHAR_TYPE__.
* c-lex.h (builtin_define_with_value): Prototype.
* system.h: Poison NO_BUILTIN_SIZE_TYPE, NO_BUILTIN_WCHAR_TYPE,
NO_BUILTIN_PTRDIFF_TYPE, and NO_BUILTIN_WINT_TYPE.
* doc/tm.texi: Remove mention of NO_BUILTIN_SIZE_TYPE etc.
* config/avr/avr.h, config/h8300/h8300.h, config/i386/i386.h,
config/ia64/ia64.h, config/mips/dec-osf1.h, config/mips/iris6.h,
config/mips/linux.h, config/mips/mips.h, config/mips/netbsd.h,
config/mips/osfrose.h, config/mips/sni-svr4.h, config/rs6000/aix51.h,
config/s390/linux.h, config/sh/sh.h, config/sh/sh64.h,
config/sparc/linux64.h, config/sparc/netbsd-elf.h,
config/sparc/sol2-bi.h, config/sparc/sparc.h:
Do not define NO_BUILTIN_SIZE_TYPE etc. Remove all references
to __SIZE_TYPE__ etc from all spec strings. When this makes
extra specs empty, delete them.
From-SVN: r53472
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 8233187..f60a27f 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -41,9 +41,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "except.h" /* For USING_SJLJ_EXCEPTIONS. */ cpp_reader *parse_in; /* Declared in c-lex.h. */ -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE TYPE_PRECISION (wchar_type_node) - /* We let tm.h override the types used here, to handle trivial differences such as the choice of unsigned int or long unsigned int for size_t. When machines start needing nontrivial differences in the size type, @@ -58,6 +55,10 @@ cpp_reader *parse_in; /* Declared in c-lex.h. */ #define WCHAR_TYPE "int" #endif +/* WCHAR_TYPE gets overridden by -fshort-wchar. */ +#define MODIFIED_WCHAR_TYPE \ + (flag_short_wchar ? "short unsigned int" : WCHAR_TYPE) + #ifndef PTRDIFF_TYPE #define PTRDIFF_TYPE "long int" #endif @@ -802,7 +803,8 @@ combine_strings (strings) } else { - const int nzeros = (WCHAR_TYPE_SIZE / BITS_PER_UNIT) - 1; + const int nzeros = (TYPE_PRECISION (wchar_type_node) + / BITS_PER_UNIT) - 1; int j, k; if (BYTES_BIG_ENDIAN) @@ -2872,9 +2874,7 @@ c_common_nodes_and_builtins () (*targetm.init_builtins) (); /* This is special for C++ so functions can be overloaded. */ - wchar_type_node = get_identifier (flag_short_wchar - ? "short unsigned int" - : WCHAR_TYPE); + 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); if (c_language == clk_cplusplus) @@ -4321,7 +4321,7 @@ cb_register_builtins (pfile) if (c_language == clk_cplusplus) { if (SUPPORTS_ONE_ONLY) - cpp_define (pfile, "__GXX_WEAK__"); + cpp_define (pfile, "__GXX_WEAK__=1"); else cpp_define (pfile, "__GXX_WEAK__=0"); } @@ -4330,6 +4330,12 @@ cb_register_builtins (pfile) if (USING_SJLJ_EXCEPTIONS) cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__"); + /* stddef.h needs to know these. */ + builtin_define_with_value ("__SIZE_TYPE__", SIZE_TYPE); + builtin_define_with_value ("__PTRDIFF_TYPE__", PTRDIFF_TYPE); + builtin_define_with_value ("__WCHAR_TYPE__", MODIFIED_WCHAR_TYPE); + builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE); + /* A straightforward target hook doesn't work, because of problems linking that hook's body when part of non-C front ends. */ TARGET_CPU_CPP_BUILTINS (); @@ -4379,6 +4385,27 @@ builtin_define_std (macro) } } +/* Pass an object-like macro and a value to define it to. */ +void +builtin_define_with_value (macro, expansion) + const char *macro; + const char *expansion; +{ + char *buf, *q; + size_t mlen = strlen (macro); + size_t elen = strlen (expansion); + + q = buf = alloca (mlen + elen + 2); + memcpy (q, macro, mlen); + q += mlen; + *q++ = '='; + memcpy (q, expansion, elen); + q += elen; + *q = '\0'; + + cpp_define (parse_in, buf); +} + /* Front end initialization common to C, ObjC and C++. */ const char * c_common_init (filename) |