From 6b67c26e611e8546402d9b963398fad166439822 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Wed, 27 Jun 2001 18:03:03 +0000 Subject: [PATCH] diagnostic.h: Add documentation. 2001-06-27 Gabriel Dos Reis * diagnostic.h: Add documentation. Make macros polymorphic. * diagnostic.c (ideal_line_wrap_cutoff): Remove definition. Replace with diagnostic_line_cutoff. (prefixing_policy): Remove. Replace with diagnostic_prefixing_rule. From-SVN: r43616 --- gcc/ChangeLog | 7 +++++ gcc/diagnostic.c | 26 ++++++++-------- gcc/diagnostic.h | 79 +++++++++++++++++++++++++++++++++++++----------- 3 files changed, 80 insertions(+), 32 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b73e252c345..5a89256f13e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2001-06-27 Gabriel Dos Reis + + * diagnostic.h: Add documentation. Make macros polymorphic. + * diagnostic.c (ideal_line_wrap_cutoff): Remove + definition. Replace with diagnostic_line_cutoff. + (prefixing_policy): Remove. Replace with diagnostic_prefixing_rule. + 2001-06-27 Joseph S. Myers * doc/c-tree.texi, doc/contrib.texi, doc/cpp.texi, diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index c3ab80c0f49..c306355ff25 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -52,9 +52,7 @@ Boston, MA 02111-1307, USA. */ #define is_starting_newline(BUFFER) (output_text_length (BUFFER) == 0) #define output_prefix(BUFFER) (BUFFER)->state.prefix #define line_wrap_cutoff(BUFFER) (BUFFER)->state.maximum_length -#define ideal_line_wrap_cutoff(BUFFER) (BUFFER)->state.ideal_maximum_length #define prefix_was_emitted_for(BUFFER) (BUFFER)->state.emitted_prefix_p -#define prefixing_policy(BUFFER) (BUFFER)->state.prefixing_rule #define output_buffer_ptr_to_format_args(BUFFER) (BUFFER)->state.format_args #define diagnostic_args output_buffer_ptr_to_format_args (diagnostic_buffer) @@ -189,7 +187,7 @@ int output_is_line_wrapping (buffer) output_buffer *buffer; { - return ideal_line_wrap_cutoff (buffer) > 0; + return diagnostic_line_cutoff (buffer) > 0; } /* Return BUFFER's prefix. */ @@ -212,19 +210,19 @@ set_real_maximum_length (buffer) we'll emit prefix only once per diagnostic message, it is appropriate not to increase unncessarily the line-length cut-off. */ if (! output_is_line_wrapping (buffer) - || prefixing_policy (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE - || prefixing_policy (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER) - line_wrap_cutoff (buffer) = ideal_line_wrap_cutoff (buffer); + || diagnostic_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE + || diagnostic_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER) + line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer); else { int prefix_length = output_prefix (buffer) ? strlen (output_prefix (buffer)) : 0; /* If the prefix is ridiculously too long, output at least 32 characters. */ - if (ideal_line_wrap_cutoff (buffer) - prefix_length < 32) - line_wrap_cutoff (buffer) = ideal_line_wrap_cutoff (buffer) + 32; + if (diagnostic_line_cutoff (buffer) - prefix_length < 32) + line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer) + 32; else - line_wrap_cutoff (buffer) = ideal_line_wrap_cutoff (buffer); + line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer); } } @@ -236,7 +234,7 @@ output_set_maximum_length (buffer, length) output_buffer *buffer; int length; { - ideal_line_wrap_cutoff (buffer) = length; + diagnostic_line_cutoff (buffer) = length; set_real_maximum_length (buffer); } @@ -313,8 +311,8 @@ init_output_buffer (buffer, prefix, maximum_length) memset (buffer, 0, sizeof (output_buffer)); obstack_init (&buffer->obstack); output_buffer_attached_stream (buffer) = stderr; - ideal_line_wrap_cutoff (buffer) = maximum_length; - prefixing_policy (buffer) = diagnostic_prefixing_rule (global_dc); + diagnostic_line_cutoff (buffer) = maximum_length; + diagnostic_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc); output_set_prefix (buffer, prefix); output_text_length (buffer) = 0; clear_diagnostic_info (buffer); @@ -366,7 +364,7 @@ output_emit_prefix (buffer) { if (output_prefix (buffer) != NULL) { - switch (prefixing_policy (buffer)) + switch (diagnostic_prefixing_rule (buffer)) { default: case DIAGNOSTICS_SHOW_PREFIX_NEVER: @@ -1559,7 +1557,7 @@ output_do_verbatim (buffer, msgid, args_ptr) os = output_buffer_state (buffer); output_prefix (buffer) = NULL; - prefixing_policy (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER; + diagnostic_prefixing_rule (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER; output_buffer_text_cursor (buffer) = _(msgid); output_buffer_ptr_to_format_args (buffer) = args_ptr; output_set_maximum_length (buffer, 0); diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 72aa297f6d3..0e229bb9523 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -76,10 +76,10 @@ typedef struct int indent_skip; /* Nonzero if current PREFIX was emitted at least once. */ - int emitted_prefix_p; + bool emitted_prefix_p; /* Nonzero means one should emit a newline before outputing anything. */ - int need_newline_p; + bool need_newline_p; /* Current prefixing rule. */ diagnostic_prefixing_rule_t prefixing_rule; @@ -130,13 +130,30 @@ struct output_buffer printer_fn format_decoder; }; -#define output_buffer_state(BUFFER) (BUFFER)->state +/* 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 + +/* The stream attached to the output_buffer, where the formatted + diagnostics will ultimately go. Works only on `output_buffer *'. */ #define output_buffer_attached_stream(BUFFER) (BUFFER)->stream + +/* This points to the beginning of the rest of the diagnostic message + to be formatted. Accepts only `output_buffer *'s. */ #define output_buffer_text_cursor(BUFFER) (BUFFER)->state.cursor -#define output_buffer_format_args(BUFFER) *((BUFFER)->state.format_args) + +/* 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) + +/* In line-wrapping mode, whether we should start a new line. */ #define output_needs_newline(BUFFER) (BUFFER)->state.need_newline_p -#define output_buffer_state(BUFFER) (BUFFER)->state + +/* The amount of whitespace to be emitted when starting a new line. */ #define output_indentation(BUFFER) (BUFFER)->state.indent_skip + +/* A pointer to the formatted diagonstic message. */ #define output_message_text(BUFFER) \ ((const char *) obstack_base (&(BUFFER)->obstack)) @@ -181,39 +198,65 @@ struct diagnostic_context void *x_data; }; +/* The diagnostic message being formatted. */ #define diagnostic_message(DC) (DC)->message + +/* A pointer to the variable argument list used in a call + to a diagonstic routine. */ #define diagnostic_argument_list(DC) (DC)->args_ptr + +/* The program file to which the diagnostic is referring to. */ #define diagnostic_file_location(DC) (DC)->file + +/* The program source line referred to in the diagnostic message. */ #define diagnostic_line_location(DC) (DC)->line + +/* Tell whether the diagnostic message is to be treated as a warning. */ #define diagnostic_is_warning(DC) (DC)->warn + +/* Client supplied function to announce a diagnostic. */ #define diagnostic_starter(DC) (DC)->begin_diagnostic + +/* Client supplied function called after a diagnostic message is + displayed. */ #define diagnostic_finalizer(DC) (DC)->end_diagnostic + +/* Extention hook for client. */ #define diagnostic_auxiliary_data(DC) (DC)->x_data -#define diagnostic_format_decoder(DC) (DC)->buffer.format_decoder -#define diagnostic_prefixing_rule(DC) (DC)->buffer.state.prefixing_rule + +/* 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 + +/* 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 /* Maximum characters per line in automatic line wrapping mode. Zero means don't wrap lines. */ -#define diagnostic_line_cutoff(DC) (DC)->buffer.state.ideal_maximum_length +#define diagnostic_line_cutoff(DC) \ + ((output_buffer *)DC)->state.ideal_maximum_length -/* This output buffer is used by front-ends that directly output +/* This diagnostic context is used by front-ends that directly output diagnostic messages without going through `error', `warning', - and similar functions. In general, such usage should be - avoided. This global buffer will go away, once all such usage - has been removed. */ -extern output_buffer *diagnostic_buffer; + and similar functions. */ extern diagnostic_context *global_dc; -#define diagnostic_kind_count(BUFFER, DK) \ - (BUFFER)->state.diagnostic_count[(int) DK] +/* 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] /* The number of errors that have been issued so far. Ideally, these would take an output_buffer as an argument. */ -#define errorcount diagnostic_kind_count (diagnostic_buffer, DK_ERROR) +#define errorcount diagnostic_kind_count (global_dc, DK_ERROR) /* Similarly, but for warnings. */ -#define warningcount diagnostic_kind_count (diagnostic_buffer, DK_WARNING) +#define warningcount diagnostic_kind_count (global_dc, DK_WARNING) /* Similarly, but for sorrys. */ -#define sorrycount diagnostic_kind_count (diagnostic_buffer, DK_SORRY) +#define sorrycount diagnostic_kind_count (global_dc, DK_SORRY) /* Returns non-zero if warnings should be emitted. */ #define diagnostic_report_warnings_p() \ -- 2.30.2