This is the mail archive of the gcc-regression@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC build failed for mips-elf with your patch on 2002-05-04T08:57:11Z.


Neil Booth wrote:-

> Is this patch OK?  I find it hard to believe that WCHAR_SIZE is ever
> 64 (the iris5.h used to have 64, but a while ago David Billinghurst
> fixed that and made it 32).  If it is, then currently we can't support
> cross-compilers properly, and maybe I should downgrade this error to
> a warning?

Forget it; it appears that Irix can have 64-bit wchar_t.  What a space
eater.

cpplib needs to be able to upgrade its cppchar_t to unsigned long or
even, in this case, unsigned long long.  This patch does that.  I've
checked that mips-elf doesn't fail because of the size of wchar_t
any more.  This also exposed that we needed some casts where we don't
currently have any.

Once an x86 bootstrap has passed, I'll apply this.

Neil.

	* cppinit.c (MAX_WCHAR_TYPE_SIZE): Move to cpplib.h
	(cpp_post_options): Improve sanity check diagnostics.
	* 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.

============================================================
Index: gcc/cppinit.c
--- gcc/cppinit.c	4 May 2002 07:26:42 -0000	1.216
+++ gcc/cppinit.c	4 May 2002 17:17:26 -0000
@@ -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
@@ -1809,23 +1806,27 @@ cpp_post_options (pfile)
     }
 
 #if ENABLE_CHECKING
+ {
+   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));
 
-  if (CPP_OPTION (pfile, char_precision) > BITS_PER_CPPCHAR_T
-      || CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T)
+  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 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");
+	       "CPP on this host cannot handle (wide) character constants over %u bits, but the target requires %u bits",
+	       BITS_PER_CPPCHAR_T, max_prec);
   }
 #endif
 
============================================================
Index: gcc/cpplex.c
--- gcc/cpplex.c	4 May 2002 07:26:42 -0000	1.199
+++ gcc/cpplex.c	4 May 2002 17:17:35 -0000
@@ -80,7 +80,7 @@ static void save_comment PARAMS ((cpp_re
 				  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, wi
     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, wi
   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: gcc/cpplib.h
--- gcc/cpplib.h	4 May 2002 07:26:45 -0000	1.211
+++ gcc/cpplib.h	4 May 2002 17:17:37 -0000
@@ -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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]