This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Compiler aborts if ^M is encountered
- To: gcc-patches at gcc dot gnu dot org
- Subject: Compiler aborts if ^M is encountered
- From: Bernd Schmidt <bernds at redhat dot co dot uk>
- Date: Fri, 15 Sep 2000 19:59:42 +0100 (BST)
This problem is due to the error reporting functions in diagnostic.c being
incapable of dealing with the format strings used in c-lex.c:
c-lex.c: error ("stray '\\%#o' in program", tok->val.aux);
We can't deal with the "#" flag. This leads to errors of the form
g_misc.i:7: stray '\
Internal compiler error: Error reporting routines re-entered.
The patch below corrects it, but I'm not entirely sure why we're rolling
our own functions for all this rather than relying on something standard
like sprintf.
Bernd
* diagnostic.c (output_octal, output_long_octal): New arg LEADING_ZERO.
If set, use different format string.
(output_format): Parse '#' modifier for octal.
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.35
diff -u -p -r1.35 diagnostic.c
--- diagnostic.c 2000/09/06 18:43:35 1.35
+++ diagnostic.c 2000/09/15 17:54:30
@@ -84,8 +84,9 @@ static void output_unsigned_decimal PARA
static void output_long_decimal PARAMS ((output_buffer *, long int));
static void output_long_unsigned_decimal PARAMS ((output_buffer *,
long unsigned int));
-static void output_octal PARAMS ((output_buffer *, unsigned int));
-static void output_long_octal PARAMS ((output_buffer *, unsigned long int));
+static void output_octal PARAMS ((output_buffer *, unsigned int, int));
+static void output_long_octal PARAMS ((output_buffer *, unsigned long int,
+ int));
static void output_hexadecimal PARAMS ((output_buffer *, unsigned int));
static void output_long_hexadecimal PARAMS ((output_buffer *,
unsigned long int));
@@ -490,19 +491,27 @@ output_long_unsigned_decimal (buffer, i)
}
static void
-output_octal (buffer, i)
+output_octal (buffer, i, leading_zero)
output_buffer *buffer;
unsigned int i;
+ int leading_zero;
{
- output_formatted_integer (buffer, "%o", i);
+ if (leading_zero)
+ output_formatted_integer (buffer, "%#o", i);
+ else
+ output_formatted_integer (buffer, "%o", i);
}
static void
-output_long_octal (buffer, i)
+output_long_octal (buffer, i, leading_zero)
output_buffer *buffer;
unsigned long int i;
+ int leading_zero;
{
- output_formatted_integer (buffer, "%lo", i);
+ if (leading_zero)
+ output_formatted_integer (buffer, "%#lo", i);
+ else
+ output_formatted_integer (buffer, "%lo", i);
}
static void
@@ -661,6 +670,7 @@ output_format (buffer)
++output_buffer_text_cursor (buffer))
{
int long_integer = 0;
+ int leading_zero = 0;
/* Ignore text. */
{
@@ -673,10 +683,18 @@ output_format (buffer)
if (!*output_buffer_text_cursor (buffer))
break;
+
+ ++output_buffer_text_cursor (buffer);
+
+ /* We got a '%'. Let's see what happens. Record if there are any flags
+ which we understand. */
+ if (*output_buffer_text_cursor (buffer) == '#')
+ {
+ leading_zero = 1;
+ ++output_buffer_text_cursor (buffer);
+ }
- /* We got a '%'. Let's see what happens. Record whether we're
- parsing a long integer format specifier. */
- if (*++output_buffer_text_cursor (buffer) == 'l')
+ if (*output_buffer_text_cursor (buffer) == 'l')
{
long_integer = 1;
++output_buffer_text_cursor (buffer);
@@ -706,11 +724,11 @@ output_format (buffer)
if (long_integer)
output_long_octal (buffer,
va_arg (output_buffer_format_args (buffer),
- unsigned long int));
+ unsigned long int), leading_zero);
else
output_octal (buffer,
va_arg (output_buffer_format_args (buffer),
- unsigned int));
+ unsigned int), leading_zero);
break;
case 's':