aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/cppinit.c58
-rw-r--r--gcc/cpplex.c14
-rw-r--r--gcc/cpplib.h21
4 files changed, 68 insertions, 35 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e84fe90..e91a779 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2002-05-04 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * 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.
+
2002-05-04 Bernd Schmidt <bernds@redhat.com>
* config/i386/i386.c (bdesc_2arg): Add a couple of missing SSE2
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index cb5b263..594fa7e 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
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 0a26049..51c82b2 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -80,7 +80,7 @@ static void save_comment PARAMS ((cpp_reader *, cpp_token *, const uchar *,
cppchar_t));
static int name_p PARAMS ((cpp_reader *, const cpp_string *));
static int maybe_read_ucs PARAMS ((cpp_reader *, const unsigned char **,
- const unsigned char *, unsigned int *));
+ const unsigned char *, cppchar_t *));
static tokenrun *next_tokenrun PARAMS ((tokenrun *));
static unsigned int hex_digit_value PARAMS ((unsigned int));
@@ -695,7 +695,7 @@ parse_string (pfile, token, terminator)
unterminated:
if (CPP_OPTION (pfile, lang) != CLK_ASM || terminator == '>')
cpp_error (pfile, DL_ERROR, "missing terminating %c character",
- terminator);
+ (int) terminator);
buffer->cur--;
break;
}
@@ -1648,7 +1648,7 @@ maybe_read_ucs (pfile, pstr, limit, pc)
cpp_reader *pfile;
const unsigned char **pstr;
const unsigned char *limit;
- unsigned int *pc;
+ cppchar_t *pc;
{
const unsigned char *p = *pstr;
unsigned int code = 0;
@@ -1763,7 +1763,7 @@ cpp_parse_escape (pfile, pstr, limit, wide)
case 'e': case 'E':
if (CPP_PEDANTIC (pfile))
cpp_error (pfile, DL_PEDWARN,
- "non-ISO-standard escape sequence, '\\%c'", c);
+ "non-ISO-standard escape sequence, '\\%c'", (int) c);
c = TARGET_ESC;
break;
@@ -1838,9 +1838,11 @@ cpp_parse_escape (pfile, pstr, limit, wide)
if (unknown)
{
if (ISGRAPH (c))
- cpp_error (pfile, DL_PEDWARN, "unknown escape sequence '\\%c'", c);
+ cpp_error (pfile, DL_PEDWARN,
+ "unknown escape sequence '\\%c'", (int) c);
else
- cpp_error (pfile, DL_PEDWARN, "unknown escape sequence: '\\%03o'", c);
+ cpp_error (pfile, DL_PEDWARN,
+ "unknown escape sequence: '\\%03o'", (int) c);
}
if (c > mask)
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 520f2a2..9063647 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -191,11 +191,22 @@ struct cpp_token
};
/* A type wide enough to hold any multibyte source character.
- cpplib's character constant interpreter uses shifts, and so
- requires an unsigned type. */
-typedef unsigned int cppchar_t;
-/* Its signed equivalent. */
-typedef int cppchar_signed_t;
+ cpplib's character constant interpreter requires an unsigned type.
+ Also, a typedef for the signed equivalent. */
+#ifndef MAX_WCHAR_TYPE_SIZE
+# define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
+#endif
+#if SIZEOF_INT >= MAX_WCHAR_TYPE_SIZE
+# define CPPCHAR_SIGNED_T int
+#else
+# if SIZEOF_LONG >= MAX_WCHAR_TYPE_SIZE || !HAVE_LONG_LONG
+# define CPPCHAR_SIGNED_T long
+# else
+# define CPPCHAR_SIGNED_T long long
+# endif
+#endif
+typedef unsigned CPPCHAR_SIGNED_T cppchar_t;
+typedef CPPCHAR_SIGNED_T cppchar_signed_t;
/* Values for opts.dump_macros.
dump_only means inhibit output of the preprocessed text