]> gcc.gnu.org Git - gcc.git/commitdiff
cppinit.c (MAX_WCHAR_TYPE_SIZE): Move to cpplib.h
authorNeil Booth <neil@daikokuya.demon.co.uk>
Sat, 4 May 2002 19:42:01 +0000 (19:42 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sat, 4 May 2002 19:42:01 +0000 (19:42 +0000)
* 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.

From-SVN: r53163

gcc/ChangeLog
gcc/cppinit.c
gcc/cpplex.c
gcc/cpplib.h

index e84fe90d86bd048b814eb5520e746a74051770ff..e91a7793321a279eb7350d4c47a2b6ce9fd1df8c 100644 (file)
@@ -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
index cb5b263151b875c60cb6efc516d65197ecf3cd93..594fa7ed7398b46b7555095380111aa80bb946ad 100644 (file)
@@ -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
index 0a260490af7e590ecc46e9d0228779efd64724f4..51c82b206081fccef0eda57892e06783563cc125 100644 (file)
@@ -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)
index 520f2a2eac9bc2bf8163db6a95b9e919ac8e19e9..9063647f6db76a6a65655681f7303bbaad3a92ec 100644 (file)
@@ -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
This page took 0.075505 seconds and 5 git commands to generate.