OSDN Git Service

Fix for PR libgcj/6081:
[pf3gnuchains/gcc-fork.git] / gcc / diagnostic.h
index 648680d..925134a 100644 (file)
@@ -1,5 +1,5 @@
 /* Various declarations for language-independent diagnostics subroutines.
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
 
 This file is part of GCC.
@@ -55,13 +55,13 @@ typedef enum
 
 /* The type of front-end specific hook that formats trees into an
    output_buffer.  A language specific printer returns a truth value if
-   everything goes well. */
+   everything goes well.  */
 typedef int (*printer_fn) PARAMS ((output_buffer *));
 
 /* This data structure encapsulates an output_buffer's state.  */
 typedef struct
 {
-  /* The prefix for each new line.   */
+  /* The prefix for each new line.  */
   const char *prefix;
 
   /* The real upper bound of number of characters per line, taking into
@@ -69,7 +69,7 @@ typedef struct
   int maximum_length;
 
   /* The ideal upper bound of number of characters per line, as suggested
-     by front-end. */  
+     by front-end.  */  
   int ideal_maximum_length;
 
   /* Indentation count.  */
@@ -130,9 +130,8 @@ struct output_buffer
   printer_fn format_decoder;
 };
 
-/* Current state of the diagnostic_context' output_buffer.  This macro
-   accepts both `diagnostic_context *' and `output_buffer *'.  */
-#define output_buffer_state(BUFFER) ((output_buffer *)BUFFER)->state
+/* Current state of an output_buffer.  */
+#define output_buffer_state(BUFFER) (BUFFER)->state
 
 /* The stream attached to the output_buffer, where the formatted
    diagnostics will ultimately go.  Works only on `output_buffer *'.  */
@@ -145,7 +144,7 @@ struct output_buffer
 /* The rest of the `variable argument list' not yet processed.
    This macro works on both `output_state *' and `output_buffer *'.  */
 #define output_buffer_format_args(BUFFER) \
-   *(((output_state *)BUFFER)->format_args)
+   *(((output_state *)(BUFFER))->format_args)
 
 /* In line-wrapping mode, whether we should start a new line.  */
 #define output_needs_newline(BUFFER) (BUFFER)->state.need_newline_p
@@ -157,6 +156,16 @@ struct output_buffer
 #define output_message_text(BUFFER) \
    ((const char *) obstack_base (&(BUFFER)->obstack))
 
+/* Client supplied function used to decode formats.  */
+#define output_format_decoder(BUFFER)     (BUFFER)->format_decoder
+
+/* Prefixing rule used in formatting a diagnostic message.  */
+#define output_prefixing_rule(BUFFER)  (BUFFER)->state.prefixing_rule
+
+/* Maximum characters per line in automatic line wrapping mode.
+   Zero means don't wrap lines.  */
+#define output_line_cutoff(BUFFER)  (BUFFER)->state.ideal_maximum_length
+
 /* This data structure bundles altogether any information relevant to
    the context of a diagnostic message.  */
 struct diagnostic_context
@@ -191,7 +200,7 @@ struct diagnostic_context
   */
   void (*begin_diagnostic) PARAMS ((output_buffer *, diagnostic_context *));
 
-  /* This function is called after the diagnostic message is printed.   */
+  /* This function is called after the diagnostic message is printed.  */
   void (*end_diagnostic) PARAMS ((output_buffer *, diagnostic_context *));
 
   /* Hook for front-end extensions.  */
@@ -221,34 +230,32 @@ struct diagnostic_context
    displayed.  */
 #define diagnostic_finalizer(DC) (DC)->end_diagnostic
 
-/* Extention hook for client.  */
+/* Extension hook for client.  */
 #define diagnostic_auxiliary_data(DC) (DC)->x_data
 
-/* Client supplied function used to decode formats.  Can operate on both
- `output_buffer *' and `diagnostic_context *'.  */
-#define diagnostic_format_decoder(DC) ((output_buffer *)(DC))->format_decoder
+/* Same as output_format_decoder.  Works on 'diagnostic_context *'.  */
+#define diagnostic_format_decoder(DC) output_format_decoder (&(DC)->buffer)
 
-/* Prefixing rule used in formatting a diagnostic message.  Accepts both
-   `output_buffer *' and `diagnostic_context *'.  */
-#define diagnostic_prefixing_rule(DC) \
-   ((output_buffer *)(DC))->state.prefixing_rule
+/* Same as output_prefixing_rule.  Works on 'diagnostic_context *'.  */
+#define diagnostic_prefixing_rule(DC) output_prefixing_rule (&(DC)->buffer)
 
 /* Maximum characters per line in automatic line wrapping mode.
-   Zero means don't wrap lines. */
-#define diagnostic_line_cutoff(DC) \
-   ((output_buffer *)(DC))->state.ideal_maximum_length
+   Zero means don't wrap lines.  */
+#define diagnostic_line_cutoff(DC) output_line_cutoff (&(DC)->buffer)
+
+/* Same as output_buffer_state, but works on 'diagnostic_context *'.  */
+#define diagnostic_state(DC)  output_buffer_state (&(DC)->buffer)
+
+#define diagnostic_buffer (&global_dc->buffer)
 
 /* This diagnostic context is used by front-ends that directly output
    diagnostic messages without going through `error', `warning',
    and similar functions.  */
 extern diagnostic_context *global_dc;
 
-/* This will be removed shortly.  */
-extern output_buffer *diagnostic_buffer;
-
 /* The total count of a KIND of diagnostics meitted so far.  */
 #define diagnostic_kind_count(DC, DK) \
-   ((output_buffer *)(DC))->state.diagnostic_count[(int) (DK)]
+   (DC)->buffer.state.diagnostic_count[(int) (DK)]
 
 /* The number of errors that have been issued so far.  Ideally, these
    would take an output_buffer as an argument.  */
@@ -310,12 +317,4 @@ extern int error_function_changed  PARAMS ((void));
 extern void record_last_error_function PARAMS ((void));
 extern void report_problematic_module  PARAMS ((output_buffer *));     
 
-/* Called by report_error_function to print out function name.
- * Default may be overridden by language front-ends.  */
-extern void (*print_error_function) PARAMS ((diagnostic_context *,
-                                             const char *));
-
-extern void default_print_error_function PARAMS ((diagnostic_context *,
-                                                  const char *));
-
 #endif /* ! GCC_DIAGNOSTIC_H */