diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-27 05:51:14 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-27 05:51:14 +0000 |
commit | dc0b244fe513ad001e5671ae6254dd2493c0eed9 (patch) | |
tree | 2f52ca5c8e31847edc88df70f877c0e92544df2b /gcc/cppinit.c | |
parent | 019d8ed15563e5bff58d2bba45418b4fa347273d (diff) | |
download | ppe42-gcc-dc0b244fe513ad001e5671ae6254dd2493c0eed9.tar.gz ppe42-gcc-dc0b244fe513ad001e5671ae6254dd2493c0eed9.zip |
* c-common.c (c_common_init): Set CPP arithmetic precision.
* cppexp.c (cpp_num_part): Move typedef ...
* cpphash.h: ...here; make unsigned HOST_WIDE_INT.
* cppinit.c (cpp_create_reader): Default to host long arithmetic.
(sanity_checks): Update.
testsuite:
* gcc.dg/cpp/arith-2.c, gcc.dg/cpp/arith-3.c: New tests.
* gcc.dg/cpp/if-3.c: Remove.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53911 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r-- | gcc/cppinit.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 98782416e96..86566e5f4a2 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -496,8 +496,7 @@ cpp_create_reader (lang) /* Default CPP arithmetic to something sensible for the host for the benefit of dumb users like fix-header. */ -#define BITS_PER_HOST_WIDEST_INT (CHAR_BIT * sizeof (HOST_WIDEST_INT)) - CPP_OPTION (pfile, precision) = BITS_PER_HOST_WIDEST_INT; + CPP_OPTION (pfile, precision) = CHAR_BIT * sizeof (long); CPP_OPTION (pfile, char_precision) = CHAR_BIT; CPP_OPTION (pfile, wchar_precision) = CHAR_BIT * sizeof (int); CPP_OPTION (pfile, int_precision) = CHAR_BIT * sizeof (int); @@ -848,6 +847,7 @@ static void sanity_checks (pfile) cpp_reader *pfile; { cppchar_t test = 0; + size_t max_precision = 2 * CHAR_BIT * sizeof (cpp_num_part); /* Sanity checks for assumptions about CPP arithmetic and target type precisions made by cpplib. */ @@ -855,11 +855,11 @@ static void sanity_checks (pfile) if (test < 1) cpp_error (pfile, DL_ICE, "cppchar_t must be an unsigned type"); - if (CPP_OPTION (pfile, precision) > BITS_PER_HOST_WIDEST_INT) + if (CPP_OPTION (pfile, precision) > max_precision) cpp_error (pfile, DL_ICE, "preprocessor arithmetic has maximum precision of %lu bits; target requires %lu bits", - (unsigned long)BITS_PER_HOST_WIDEST_INT, - (unsigned long)CPP_OPTION (pfile, precision)); + (unsigned long) max_precision, + (unsigned long) CPP_OPTION (pfile, precision)); if (CPP_OPTION (pfile, precision) < CPP_OPTION (pfile, int_precision)) cpp_error (pfile, DL_ICE, @@ -876,11 +876,15 @@ static void sanity_checks (pfile) cpp_error (pfile, DL_ICE, "target int is narrower than target char"); + /* This is assumed in eval_token() and could be fixed if necessary. */ + if (sizeof (cppchar_t) > sizeof (cpp_num_part)) + cpp_error (pfile, DL_ICE, "CPP half-integer narrower than CPP character"); + if (CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T) cpp_error (pfile, DL_ICE, "CPP on this host cannot handle wide character constants over %lu bits, but the target requires %lu bits", - (unsigned long)BITS_PER_CPPCHAR_T, - (unsigned long)CPP_OPTION (pfile, wchar_precision)); + (unsigned long) BITS_PER_CPPCHAR_T, + (unsigned long) CPP_OPTION (pfile, wchar_precision)); } #else # define sanity_checks(PFILE) |