diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2002-05-27 05:51:14 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2002-05-27 05:51:14 +0000 |
commit | c9220e3a83aecc4d5fa5ecfad4d203f086e0c061 (patch) | |
tree | 2f52ca5c8e31847edc88df70f877c0e92544df2b /gcc/cppinit.c | |
parent | 1457a0b52ae505202bd1f341e74e039e0f4a4602 (diff) | |
download | gcc-c9220e3a83aecc4d5fa5ecfad4d203f086e0c061.zip gcc-c9220e3a83aecc4d5fa5ecfad4d203f086e0c061.tar.gz gcc-c9220e3a83aecc4d5fa5ecfad4d203f086e0c061.tar.bz2 |
c-common.c (c_common_init): Set CPP arithmetic precision.
* 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.
From-SVN: r53911
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 9878241..86566e5 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) |