diagnostic va_list bugs
Richard Henderson
rth@cygnus.com
Sat Apr 22 11:44:00 GMT 2000
You're assuming va_list is a pointer type.
Hopefully this fixes that. It's enough to get gcc to build
on Alpha again; whether it's correct for powerpc-elf I don't
know yet.
r~
* diagnostic.c (init_output_buffer): Don't initialize format_args.
(output_clear): Likewise.
(output_printf): Use va_copy.
(vline_wrapper_message_with_location): Likewise.
(v_message_with_decl): Likewise.
(line_wrapper_printf): VA_START infor buffer.format_args directly.
* system.h (va_copy): Provide default implementation.
Index: gcc/diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.11
diff -c -p -d -r1.11 diagnostic.c
*** diagnostic.c 2000/04/22 11:49:16 1.11
--- diagnostic.c 2000/04/22 18:30:01
*************** init_output_buffer (buffer, prefix, maxi
*** 198,204 ****
output_set_prefix (buffer, prefix);
buffer->cursor = NULL;
- buffer->format_args = NULL;
}
/* Reinitialize BUFFER. */
--- 198,203 ----
*************** output_clear (buffer)
*** 209,215 ****
obstack_free (&buffer->obstack, obstack_base (&buffer->obstack));
buffer->line_length = 0;
buffer->cursor = NULL;
- buffer->format_args = NULL;
}
/* Finishes to construct a NULL-terminated character string representing
--- 208,213 ----
*************** output_printf VPARAMS ((struct output_bu
*** 493,499 ****
msgid = va_arg (ap, const char *);
#endif
! buffer->format_args = ap;
output_notice (buffer, msgid);
va_end (buffer->format_args);
}
--- 491,497 ----
msgid = va_arg (ap, const char *);
#endif
! va_copy (buffer->format_args, ap);
output_notice (buffer, msgid);
va_end (buffer->format_args);
}
*************** line_wrapper_printf VPARAMS ((FILE *file
*** 510,526 ****
const char *msgid;
#endif
output_buffer buffer;
- va_list ap;
! VA_START (ap, msgid);
#ifndef ANSI_PROTOTYPES
! file = va_arg (ap, FILE *);
! msgid = va_arg (ap, const char *);
#endif
- init_output_buffer (&buffer, NULL, output_maximum_width);
- buffer.format_args = ap;
output_notice (&buffer, msgid);
output_flush_on (&buffer, file);
--- 508,522 ----
const char *msgid;
#endif
output_buffer buffer;
! init_output_buffer (&buffer, NULL, output_maximum_width);
! VA_START (buffer.format_args, msgid);
#ifndef ANSI_PROTOTYPES
! file = va_arg (buffer.format_args, FILE *);
! msgid = va_arg (buffer.format_args, const char *);
#endif
output_notice (&buffer, msgid);
output_flush_on (&buffer, file);
*************** vline_wrapper_message_with_location (fil
*** 538,546 ****
{
output_buffer buffer;
! init_output_buffer
! (&buffer, build_location_prefix (file, line, warn), output_maximum_width);
! buffer.format_args = ap;
output_notice (&buffer, msgid);
output_flush_on (&buffer, stderr);
--- 534,542 ----
{
output_buffer buffer;
! init_output_buffer (&buffer, build_location_prefix (file, line, warn),
! output_maximum_width);
! va_copy (buffer.format_args, ap);
output_notice (&buffer, msgid);
output_flush_on (&buffer, stderr);
*************** v_message_with_decl (decl, warn, msgid,
*** 681,689 ****
{
if (doing_line_wrapping ())
{
! buffer.format_args = ap;
output_notice (&buffer, p);
! ap = buffer.format_args;
}
else
vfprintf (stderr, p, ap);
--- 677,685 ----
{
if (doing_line_wrapping ())
{
! va_copy (buffer.format_args, ap);
output_notice (&buffer, p);
! va_copy (ap, buffer.format_args);
}
else
vfprintf (stderr, p, ap);
Index: gcc/system.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/system.h,v
retrieving revision 1.63
diff -c -p -d -r1.63 system.h
*** system.h 2000/04/19 16:43:44 1.63
--- system.h 2000/04/22 18:30:01
*************** Boston, MA 02111-1307, USA. */
*** 35,40 ****
--- 35,48 ----
#include <varargs.h>
#endif
+ #ifndef va_copy
+ # ifdef __va_copy
+ # define va_copy(d,s) __va_copy((d),(s))
+ # else
+ # define va_copy(d,s) ((d) = (s))
+ # endif
+ #endif
+
#include <stdio.h>
/* Define a generic NULL if one hasn't already been defined. */
More information about the Gcc-patches
mailing list