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

Diagnostic library cleanup, #1



This patch move the global variables lang_diagnostic_starter and
lang_diagnostic_finalizer in the dignostic_context structure.

Bootstrapped and tested on an i686-pc-linux.

-- Gaby

2001-06-26  Gabriel Dos Reis  <gdr@codesourcery.com>

	* diagnostic.h (struct diagnostic_context): Add new field.
	(lang_diagnostic_starter, lang_diagnostic_finalizer): Remove
	declaratons.
	(global_dc): Declare.
	* diagnostic.c (global_diagnostic_context): New variable.
	(global_output_buffer): Remove.
	(global_dc): Define.
	(lang_diagnostic_starter, lang_diagnostic_finalizer): Remove
 	definitions.
	(initialize_diagnostics): Adjust initialization.
	(set_diagnostic_context): Adjust setting.

cp/
2001-06-26  Gabriel Dos Reis  <gdr@codesourcery.com>

	* error.c (init_error): Adjust settings.

Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.59
diff -p -r1.59 diagnostic.c
*** diagnostic.c	2001/06/26 07:53:49	1.59
--- diagnostic.c	2001/06/26 13:57:50
*************** extern int warnings_are_errors;
*** 108,117 ****
  /* Front-end specific tree formatter, if non-NULL.  */
  printer_fn lang_printer = NULL;
  
! /* An output_buffer surrogate for stderr.  */
! static output_buffer global_output_buffer;
! output_buffer *diagnostic_buffer = &global_output_buffer;
  
  /* Function of last error message;
     more generally, function such that if next error message is in it
     then we don't have to mention the function name.  */
--- 108,120 ----
  /* Front-end specific tree formatter, if non-NULL.  */
  printer_fn lang_printer = NULL;
  
! /* A diagnostic_context surrogate for stderr.  */
! static diagnostic_context global_diagnostic_context;
! diagnostic_context *global_dc = &global_diagnostic_context;
  
+ /* This will be removed shortly.  */
+ output_buffer *diagnostic_buffer = &global_diagnostic_context.buffer;
+ 
  /* Function of last error message;
     more generally, function such that if next error message is in it
     then we don't have to mention the function name.  */
*************** static int last_error_tick;
*** 126,135 ****
  void (*print_error_function) PARAMS ((const char *)) =
    default_print_error_function;
  
- /* Hooks for language specific diagnostic messages pager and finalizer.  */
- diagnostic_starter_fn lang_diagnostic_starter;
- diagnostic_finalizer_fn lang_diagnostic_finalizer;
- 
  /* Maximum characters per line in automatic line wrapping mode.
     Zero means don't wrap lines. */
  
--- 129,134 ----
*************** initialize_diagnostics ()
*** 189,196 ****
    /* Proceed to actual initialization.  */
    default_initialize_buffer (diagnostic_buffer);
  
!   lang_diagnostic_starter = default_diagnostic_starter;
!   lang_diagnostic_finalizer = default_diagnostic_finalizer;
  }
  
  void
--- 188,195 ----
    /* Proceed to actual initialization.  */
    default_initialize_buffer (diagnostic_buffer);
  
!   diagnostic_starter (global_dc) = default_diagnostic_starter;
!   diagnostic_finalizer (global_dc) = default_diagnostic_finalizer;
  }
  
  void
*************** set_diagnostic_context (dc, msgid, args_
*** 1772,1779 ****
    diagnostic_file_location (dc) = file;
    diagnostic_line_location (dc) = line;
    diagnostic_is_warning (dc) = warn;
!   diagnostic_starter (dc) = lang_diagnostic_starter;
!   diagnostic_finalizer (dc) = lang_diagnostic_finalizer;
  }
  
  void
--- 1771,1778 ----
    diagnostic_file_location (dc) = file;
    diagnostic_line_location (dc) = line;
    diagnostic_is_warning (dc) = warn;
!   diagnostic_starter (dc) = diagnostic_starter (global_dc);
!   diagnostic_finalizer (dc) = diagnostic_finalizer (global_dc);
  }
  
  void
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.h,v
retrieving revision 1.28
diff -p -r1.28 diagnostic.h
*** diagnostic.h	2001/06/26 07:53:50	1.28
--- diagnostic.h	2001/06/26 13:57:50
*************** struct output_buffer
*** 132,137 ****
--- 132,142 ----
     the context of a diagnostic message.  */
  struct diagnostic_context
  {
+   /* Where most of the diagnostic formatting work is done.  In Object
+      Oriented terms, we'll say that diagnostic_context is a sub-class of
+      output_buffer.  */
+   output_buffer buffer;
+ 
    /* The diagnostic message to output.  */
    const char *message;
  
*************** struct diagnostic_context
*** 185,193 ****
  
  extern printer_fn lang_printer;
  
- extern diagnostic_starter_fn lang_diagnostic_starter;
- extern diagnostic_finalizer_fn lang_diagnostic_finalizer;
- 
  extern int diagnostic_message_length_per_line;
  
  /* This output buffer is used by front-ends that directly output
--- 190,195 ----
*************** extern int diagnostic_message_length_per
*** 196,201 ****
--- 198,204 ----
     avoided.  This global buffer will go away, once all such usage
     has been removed.  */
  extern output_buffer *diagnostic_buffer;
+ extern diagnostic_context *global_dc;
  
  #define diagnostic_kind_count(BUFFER, DK) \
     (BUFFER)->state.diagnostic_count[(int) DK]

Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/error.c,v
retrieving revision 1.154
diff -p -r1.154 error.c
*** error.c	2001/03/28 11:01:36	1.154
--- error.c	2001/06/26 13:57:57
*************** cp_printer * cp_printers[256] =
*** 191,203 ****
  void
  init_error ()
  {
-   init_output_buffer (scratch_buffer, /* prefix */NULL, /* line-width */0);
-   
    print_error_function = lang_print_error_function;
!   lang_diagnostic_starter = cp_diagnostic_starter;
!   lang_diagnostic_finalizer = cp_diagnostic_finalizer;
! 
    lang_printer = cp_tree_printer;
  }
  
  /* Dump a scope, if deemed necessary.  */
--- 191,202 ----
  void
  init_error ()
  {
    print_error_function = lang_print_error_function;
!   diagnostic_starter (global_dc) = cp_diagnostic_starter;
!   diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer;
    lang_printer = cp_tree_printer;
+   
+   init_output_buffer (scratch_buffer, /* prefix */NULL, /* line-width */0);
  }
  
  /* Dump a scope, if deemed necessary.  */


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