diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-04 19:42:01 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-04 19:42:01 +0000 |
commit | 40855b3039fe63b317142ae2cdb591b4fef02d95 (patch) | |
tree | 93fad2ddad4007e009671f2fd3bcb16a3937b345 /gcc/cppinit.c | |
parent | d3ceaee1b851570b269f8533b5690726512c1dfc (diff) | |
download | gcc-40855b3039fe63b317142ae2cdb591b4fef02d95.tar.gz |
* cppinit.c (MAX_WCHAR_TYPE_SIZE): Move to cpplib.h
(cpp_post_options): Move sanity checks to...
(sanity_checks): New.
* cpplex.c (maybe_read_ucs): Fix prototype.
(parse_string, cpp_parse_escape): Cast for %c format specifier.
* cpplib.h (cppchar_t): Use unsigned long or unsigned long long
if necessary.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53163 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r-- | gcc/cppinit.c | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c index cb5b263151b..594fa7ed739 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -509,9 +509,6 @@ cpp_create_reader (lang) #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE #endif CPP_OPTION (pfile, char_precision) = MAX_CHAR_TYPE_SIZE; -#ifndef MAX_WCHAR_TYPE_SIZE -#define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE -#endif CPP_OPTION (pfile, wchar_precision) = MAX_WCHAR_TYPE_SIZE; /* It's simplest to just create this struct whether or not it will @@ -1793,12 +1790,46 @@ cpp_handle_options (pfile, argc, argv) return i; } +/* Sanity-checks are dependent on command-line options, so it is + called as a subroutine of cpp_post_options (). */ +#if ENABLE_CHECKING +static void sanity_checks PARAMS ((cpp_reader *)); +static void sanity_checks (pfile) + cpp_reader *pfile; +{ + cppchar_t test = 0; + size_t max_prec; + + /* Sanity checks for CPP arithmetic. */ + test--; + if (test < 1) + cpp_error (pfile, DL_FATAL, "cppchar_t must be an unsigned type"); + + if (CPP_OPTION (pfile, precision) > BITS_PER_HOST_WIDEST_INT) + cpp_error (pfile, DL_FATAL, + "preprocessor arithmetic has maximum precision of %u bits; target requires %u bits", + BITS_PER_HOST_WIDEST_INT, CPP_OPTION (pfile, precision)); + + max_prec = CPP_OPTION (pfile, char_precision); + if (max_prec < CPP_OPTION (pfile, wchar_precision)) + max_prec = CPP_OPTION (pfile, wchar_precision); + if (max_prec > BITS_PER_CPPCHAR_T) + cpp_error (pfile, DL_FATAL, + "CPP on this host cannot handle (wide) character constants over %u bits, but the target requires %u bits", + BITS_PER_CPPCHAR_T, max_prec); +} +#else +# define sanity_checks(PFILE) +#endif + /* Extra processing when all options are parsed, after all calls to cpp_handle_option[s]. Consistency checks etc. */ void cpp_post_options (pfile) cpp_reader *pfile; { + sanity_checks (pfile); + if (pfile->print_version) { fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string); @@ -1808,27 +1839,6 @@ cpp_post_options (pfile) fputc ('\n', stderr); } -#if ENABLE_CHECKING - /* Sanity checks for CPP arithmetic. */ - if (CPP_OPTION (pfile, precision) > BITS_PER_HOST_WIDEST_INT) - cpp_error (pfile, DL_FATAL, - "preprocessor arithmetic has maximum precision of %u bits; target requires %u bits", - BITS_PER_HOST_WIDEST_INT, CPP_OPTION (pfile, precision)); - - if (CPP_OPTION (pfile, char_precision) > BITS_PER_CPPCHAR_T - || CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T) - cpp_error (pfile, DL_FATAL, - "CPP cannot handle (wide) character constants over %u bits", - BITS_PER_CPPCHAR_T); - - { - cppchar_t test = 0; - test--; - if (test < 1) - cpp_error (pfile, DL_FATAL, "cppchar_t must be an unsigned type"); - } -#endif - /* Canonicalize in_fname and out_fname. We guarantee they are not NULL, and that the empty string represents stdin / stdout. */ if (CPP_OPTION (pfile, in_fname) == NULL |