This is the mail archive of the gcc-bugs@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]

Re: va_arg *, and why not.


Mark Mitchell <mark@codesourcery.com> writes:

| >>>>> "Gabriel" == Gabriel Dos Reis <gdr@codesourcery.com> writes:
| 
|     Gabriel> Aha, got it.
| 
|     Gabriel> So what about changing the prototype of
|     Gabriel> report_diagnostic() to
| 
|     Gabriel>   void report_diagnostic (const char *, va_list *, const
|     Gabriel> char *, int, int)
| 
| Works for me.

So is this Ok to install?  Bootstrapping on an i686-pc-linux.

-- Gaby
CodeSourcery, LLC                             http://www.codesourcery.com

2000-07-17  Gabriel Dos Reis  <gdr@merlin.codesourcery.com>

	* diagnostic.h (report_diagnostic): Change prototype.

	* diagnostic.c (output_do_verbatim, diagnostic_for_asm,
	diagnostic_for_decl):  Change prototype.
	(error_with_decl, warning_with_decl, pedwarn_with_decl, warning,
	error, warning, error_with_file_and_line,
	warning_with_file_and_line, pedwarn_with_file_and_line, fatal):
	Adjust call to report_diagnostic, diagnostic_for_decl.
	(error_for_asm, warning_for_asm): Adjust call to diagnostic_for_asm. 
	(output_verbatim, verbatim): Adjust call to output_do_verbatim.
	
	* c-errors.c (pedwarn_c99): Adjust call to report_diagnostic. End
	varaible argument list.

Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.h,v
retrieving revision 1.7
diff -p -r1.7 diagnostic.h
*** diagnostic.h	2000/07/12 00:48:02	1.7
--- diagnostic.h	2000/07/17 06:24:18
*************** extern int diagnostic_message_length_per
*** 101,107 ****
  extern output_buffer *diagnostic_buffer;
  
  /* Prototypes */
! void report_diagnostic          PARAMS ((const char *, va_list,
                                           const char *, int, int));
  void initialize_diagnostics     PARAMS ((void));
  void reshape_diagnostic_buffer  PARAMS ((void));
--- 101,107 ----
  extern output_buffer *diagnostic_buffer;
  
  /* Prototypes */
! void report_diagnostic          PARAMS ((const char *, va_list *,
                                           const char *, int, int));
  void initialize_diagnostics     PARAMS ((void));
  void reshape_diagnostic_buffer  PARAMS ((void));
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.25
diff -p -r1.25 diagnostic.c
*** diagnostic.c	2000/07/15 16:50:31	1.25
--- diagnostic.c	2000/07/17 06:24:19
*************** Boston, MA 02111-1307, USA.  */
*** 64,70 ****
  /* Prototypes. */
  static void finish_diagnostic PARAMS ((void));
  static void output_do_verbatim PARAMS ((output_buffer *,
!                                         const char *, va_list));
  static void output_to_stream PARAMS ((output_buffer *, FILE *));
  static void output_format PARAMS ((output_buffer *));
  
--- 64,70 ----
  /* Prototypes. */
  static void finish_diagnostic PARAMS ((void));
  static void output_do_verbatim PARAMS ((output_buffer *,
!                                         const char *, va_list *));
  static void output_to_stream PARAMS ((output_buffer *, FILE *));
  static void output_format PARAMS ((output_buffer *));
  
*************** static char *context_as_prefix PARAMS ((
*** 75,82 ****
  static void output_do_printf PARAMS ((output_buffer *, const char *));
  static void format_with_decl PARAMS ((output_buffer *, tree));
  static void file_and_line_for_asm PARAMS ((rtx, const char **, int *));
! static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list, int));
! static void diagnostic_for_decl PARAMS ((tree, const char *, va_list, int));
  static void vnotice PARAMS ((FILE *, const char *, va_list));
  static void set_real_maximum_length PARAMS ((output_buffer *));
                                            
--- 75,82 ----
  static void output_do_printf PARAMS ((output_buffer *, const char *));
  static void format_with_decl PARAMS ((output_buffer *, tree));
  static void file_and_line_for_asm PARAMS ((rtx, const char **, int *));
! static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *, int));
! static void diagnostic_for_decl PARAMS ((tree, const char *, va_list *, int));
  static void vnotice PARAMS ((FILE *, const char *, va_list));
  static void set_real_maximum_length PARAMS ((output_buffer *));
                                            
*************** file_and_line_for_asm (insn, pfile, plin
*** 875,901 ****
     of the insn INSN.  This is used only when INSN is an `asm' with operands,
     and each ASM_OPERANDS records its own source file and line.  */
  static void
! diagnostic_for_asm (insn, msg, args, warn)
       rtx insn;
       const char *msg;
!      va_list args;
       int warn;
  {
    const char *file;
    int line;
  
    file_and_line_for_asm (insn, &file, &line);
!   report_diagnostic (msg, args, file, line, warn);
  }
  
  /* Report a diagnostic MESSAGE at the declaration DECL.
     MSG is a format string which uses %s to substitute the declaration
     name; subsequent substitutions are a la output_format.  */
  static void
! diagnostic_for_decl (decl, msg, args, warn)
       tree decl;
       const char *msg;
!      va_list args;
       int warn;
  {
    output_state os;
--- 875,901 ----
     of the insn INSN.  This is used only when INSN is an `asm' with operands,
     and each ASM_OPERANDS records its own source file and line.  */
  static void
! diagnostic_for_asm (insn, msg, args_ptr, warn)
       rtx insn;
       const char *msg;
!      va_list *args_ptr;
       int warn;
  {
    const char *file;
    int line;
  
    file_and_line_for_asm (insn, &file, &line);
!   report_diagnostic (msg, args_ptr, file, line, warn);
  }
  
  /* Report a diagnostic MESSAGE at the declaration DECL.
     MSG is a format string which uses %s to substitute the declaration
     name; subsequent substitutions are a la output_format.  */
  static void
! diagnostic_for_decl (decl, msg, args_ptr, warn)
       tree decl;
       const char *msg;
!      va_list *args_ptr;
       int warn;
  {
    output_state os;
*************** diagnostic_for_decl (decl, msg, args, wa
*** 907,913 ****
    output_set_prefix
      (diagnostic_buffer, context_as_prefix
       (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), warn));
!   output_buffer_ptr_to_format_args (diagnostic_buffer) = &args;
    output_buffer_text_cursor (diagnostic_buffer) = msg;
    format_with_decl (diagnostic_buffer, decl);
    finish_diagnostic ();
--- 907,913 ----
    output_set_prefix
      (diagnostic_buffer, context_as_prefix
       (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), warn));
!   output_buffer_ptr_to_format_args (diagnostic_buffer) = args_ptr;
    output_buffer_text_cursor (diagnostic_buffer) = msg;
    format_with_decl (diagnostic_buffer, decl);
    finish_diagnostic ();
*************** pedwarn VPARAMS ((const char *msgid, ...
*** 1000,1006 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, ap, input_filename, lineno, !flag_pedantic_errors);
    va_end (ap);
  }
  
--- 1000,1007 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, &ap, input_filename, lineno,
!                      !flag_pedantic_errors);
    va_end (ap);
  }
  
*************** pedwarn_with_decl VPARAMS ((tree decl, c
*** 1027,1033 ****
       or kernel uses the original layout).  There's no point in issuing a
       warning either, it's just unnecessary noise.  */
    if (!DECL_IN_SYSTEM_HEADER (decl))
!     diagnostic_for_decl (decl, msgid, ap, !flag_pedantic_errors);
    va_end (ap);
  }
  
--- 1028,1034 ----
       or kernel uses the original layout).  There's no point in issuing a
       warning either, it's just unnecessary noise.  */
    if (!DECL_IN_SYSTEM_HEADER (decl))
!     diagnostic_for_decl (decl, msgid, &ap, !flag_pedantic_errors);
    va_end (ap);
  }
  
*************** pedwarn_with_file_and_line VPARAMS ((con
*** 1051,1057 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, ap, file, line, !flag_pedantic_errors);
    va_end (ap);
  }
  
--- 1052,1058 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, &ap, file, line, !flag_pedantic_errors);
    va_end (ap);
  }
  
*************** error_with_file_and_line VPARAMS ((const
*** 1191,1197 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, ap, file, line, /* warn = */ 0);
    va_end (ap);
  }
  
--- 1192,1198 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, &ap, file, line, /* warn = */ 0);
    va_end (ap);
  }
  
*************** error_with_decl VPARAMS ((tree decl, con
*** 1211,1217 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   diagnostic_for_decl (decl, msgid, ap, /* warn = */ 0);
    va_end (ap);
  }
  
--- 1212,1218 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   diagnostic_for_decl (decl, msgid, &ap, /* warn = */ 0);
    va_end (ap);
  }
  
*************** error_for_asm VPARAMS ((rtx insn, const 
*** 1231,1237 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   diagnostic_for_asm (insn, msgid, ap, /* warn = */ 0);
    va_end (ap);
  }
  
--- 1232,1238 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   diagnostic_for_asm (insn, msgid, &ap, /* warn = */ 0);
    va_end (ap);
  }
  
*************** error VPARAMS ((const char *msgid, ...))
*** 1249,1255 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, ap, input_filename, lineno, /* warn = */ 0);
    va_end (ap);
  }
  
--- 1250,1256 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, &ap, input_filename, lineno, /* warn = */ 0);
    va_end (ap);
  }
  
*************** fatal VPARAMS ((const char *msgid, ...))
*** 1285,1291 ****
    if (fatal_function != NULL)
      (*fatal_function) (_(msgid), args_for_fatal_msg);
    va_end (args_for_fatal_msg);
!   report_diagnostic (msgid, ap, input_filename, lineno, 0);
    va_end (ap);
    exit (FATAL_EXIT_CODE);
  }
--- 1286,1292 ----
    if (fatal_function != NULL)
      (*fatal_function) (_(msgid), args_for_fatal_msg);
    va_end (args_for_fatal_msg);
!   report_diagnostic (msgid, &ap, input_filename, lineno, 0);
    va_end (ap);
    exit (FATAL_EXIT_CODE);
  }
*************** warning_with_file_and_line VPARAMS ((con
*** 1336,1342 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, ap, file, line, /* warn = */ 1);
    va_end (ap);
  }
  
--- 1337,1343 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, &ap, file, line, /* warn = */ 1);
    va_end (ap);
  }
  
*************** warning_with_decl VPARAMS ((tree decl, c
*** 1356,1362 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   diagnostic_for_decl (decl, msgid, ap, /* warn = */ 1);
    va_end (ap);
  }
  
--- 1357,1363 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   diagnostic_for_decl (decl, msgid, &ap, /* warn = */ 1);
    va_end (ap);
  }
  
*************** warning_for_asm VPARAMS ((rtx insn, cons
*** 1376,1382 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   diagnostic_for_asm (insn, msgid, ap, /* warn = */ 1);
    va_end (ap);
  }
  
--- 1377,1383 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   diagnostic_for_asm (insn, msgid, &ap, /* warn = */ 1);
    va_end (ap);
  }
  
*************** warning VPARAMS ((const char *msgid, ...
*** 1394,1400 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, ap, input_filename, lineno, /* warn = */ 1);
    va_end (ap);
  }
  
--- 1395,1401 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, &ap, input_filename, lineno, /* warn = */ 1);
    va_end (ap);
  }
  
*************** finish_diagnostic ()
*** 1411,1420 ****
  /* Helper subroutine of output_verbatim and verbatim. Do the approriate
     settings needed by BUFFER for a verbatim formatting.  */
  static void
! output_do_verbatim (buffer, msg, args)
       output_buffer *buffer;
       const char *msg;
!      va_list args;
  {
    output_state os;
  
--- 1412,1421 ----
  /* Helper subroutine of output_verbatim and verbatim. Do the approriate
     settings needed by BUFFER for a verbatim formatting.  */
  static void
! output_do_verbatim (buffer, msg, args_ptr)
       output_buffer *buffer;
       const char *msg;
!      va_list *args_ptr;
  {
    output_state os;
  
*************** output_do_verbatim (buffer, msg, args)
*** 1422,1428 ****
    output_prefix (buffer) = NULL;
    prefixing_policy (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
    output_buffer_text_cursor (buffer) = msg;
!   output_buffer_ptr_to_format_args (buffer) = &args;
    output_set_maximum_length (buffer, 0);
    output_format (buffer);
    buffer->state = os;
--- 1423,1429 ----
    output_prefix (buffer) = NULL;
    prefixing_policy (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
    output_buffer_text_cursor (buffer) = msg;
!   output_buffer_ptr_to_format_args (buffer) = args_ptr;
    output_set_maximum_length (buffer, 0);
    output_format (buffer);
    buffer->state = os;
*************** output_verbatim VPARAMS ((output_buffer 
*** 1443,1449 ****
    buffer = va_arg (ap, output_buffer *);
    msg = va_arg (ap, const char *);
  #endif
!   output_do_verbatim (buffer, msg, ap);
    va_end (ap);
  }
  
--- 1444,1450 ----
    buffer = va_arg (ap, output_buffer *);
    msg = va_arg (ap, const char *);
  #endif
!   output_do_verbatim (buffer, msg, &ap);
    va_end (ap);
  }
  
*************** verbatim VPARAMS ((const char *msg, ...)
*** 1460,1466 ****
  #ifndef ANSI_PROTOTYPES
    msg = va_arg (ap, const char *);
  #endif
!   output_do_verbatim (diagnostic_buffer, msg, ap);
    output_to_stream (diagnostic_buffer, stderr);
    va_end (ap);
  }
--- 1461,1467 ----
  #ifndef ANSI_PROTOTYPES
    msg = va_arg (ap, const char *);
  #endif
!   output_do_verbatim (diagnostic_buffer, msg, &ap);
    output_to_stream (diagnostic_buffer, stderr);
    va_end (ap);
  }
*************** verbatim VPARAMS ((const char *msg, ...)
*** 1472,1480 ****
     The front-end independent format specifiers are exactly those described
     in the documentation of output_format.  */
  void
! report_diagnostic (msg, args, file, line, warn)
       const char *msg;
!      va_list args;
       const char *file;
       int line;
       int warn;
--- 1473,1481 ----
     The front-end independent format specifiers are exactly those described
     in the documentation of output_format.  */
  void
! report_diagnostic (msg, args_ptr, file, line, warn)
       const char *msg;
!      va_list *args_ptr;
       const char *file;
       int line;
       int warn;
*************** report_diagnostic (msg, args, file, line
*** 1485,1491 ****
      return;
    os = diagnostic_buffer->state;
    diagnostic_msg = msg;
!   diagnostic_args = &args;
    report_error_function (file);
    output_set_prefix
      (diagnostic_buffer, context_as_prefix (file, line, warn));
--- 1486,1492 ----
      return;
    os = diagnostic_buffer->state;
    diagnostic_msg = msg;
!   diagnostic_args = args_ptr;
    report_error_function (file);
    output_set_prefix
      (diagnostic_buffer, context_as_prefix (file, line, warn));
Index: c-errors.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-errors.c,v
retrieving revision 1.1
diff -p -r1.1 c-errors.c
*** c-errors.c	2000/07/12 14:12:51	1.1
--- c-errors.c	2000/07/17 06:24:19
*************** pedwarn_c99 VPARAMS ((const char *msgid,
*** 43,48 ****
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, ap, input_filename, lineno,
                       !flag_isoc99 || !flag_pedantic_errors);
  }
--- 43,49 ----
    msgid = va_arg (ap, const char *);
  #endif
  
!   report_diagnostic (msgid, &ap, input_filename, lineno,
                       !flag_isoc99 || !flag_pedantic_errors);
+   va_end (ap);
  }

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