Commit bd6bec6b by Gabriel Dos Reis Committed by Gabriel Dos Reis

diagnostic.h (output_buffer_state): Redefine.

	* diagnostic.h (output_buffer_state): Redefine.
	(output_format_decoder): New macro.
	(output_prefixing_rule): Likewise.
	(output_line_cutoff): Likewise.
	(diagnostic_format_decoder): Adjust.
	(diagnostic_prefixing_rule): Likewise.
	(diagnostic_line_cutoff): Likewise.
	(diagnostic_state): Likewise.
	(diagnostic_kind_count): Likewise.
	(diagnostic_buffer): Now a macro.

	* diagnostic.c (diagnostic_buffer): Remove definition.
	(output_is_line_wrapping): Adjust.
	(set_real_maximum_length): Likewise.
	(output_set_maximum_length): Likewise.
	(init_output_buffer): Likewise.
	(lhd_print_error_function): Likewise.
	(output_do_verbatim): Likewise.

cp/
	* error.c (cxx_print_error_function): Adjust call to macros.

From-SVN: r52307
parent f20c0d98
2002-04-15 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
* diagnostic.h (output_buffer_state): Redefine.
(output_format_decoder): New macro.
(output_prefixing_rule): Likewise.
(output_line_cutoff): Likewise.
(diagnostic_format_decoder): Adjust.
(diagnostic_prefixing_rule): Likewise.
(diagnostic_line_cutoff): Likewise.
(diagnostic_state): Likewise.
(diagnostic_kind_count): Likewise.
(diagnostic_buffer): Now a macro.
* diagnostic.c (diagnostic_buffer): Remove definition.
(output_is_line_wrapping): Adjust.
(set_real_maximum_length): Likewise.
(output_set_maximum_length): Likewise.
(init_output_buffer): Likewise.
(lhd_print_error_function): Likewise.
(output_do_verbatim): Likewise.
2002-04-14 Neil Booth <neil@daikokuya.demon.co.uk> 2002-04-14 Neil Booth <neil@daikokuya.demon.co.uk>
* cpperror.c (print_location): Don't print include chain * cpperror.c (print_location): Don't print include chain
......
2002-04-15 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
* error.c (cxx_print_error_function): Adjust call to macros.
2002-04-14 Jakub Jelinek <jakub@redhat.com> 2002-04-14 Jakub Jelinek <jakub@redhat.com>
* class.c (layout_virtual_bases): Do all dsize computation on trees. * class.c (layout_virtual_bases): Do all dsize computation on trees.
......
...@@ -2382,10 +2382,10 @@ cxx_print_error_function (context, file) ...@@ -2382,10 +2382,10 @@ cxx_print_error_function (context, file)
output_state os; output_state os;
lhd_print_error_function (context, file); lhd_print_error_function (context, file);
os = output_buffer_state (context); os = diagnostic_state (context);
output_set_prefix ((output_buffer *)context, file); output_set_prefix ((output_buffer *)context, file);
maybe_print_instantiation_context ((output_buffer *)context); maybe_print_instantiation_context ((output_buffer *)context);
output_buffer_state (context) = os; diagnostic_state (context) = os;
} }
static void static void
......
...@@ -103,9 +103,6 @@ extern int warnings_are_errors; ...@@ -103,9 +103,6 @@ extern int warnings_are_errors;
static diagnostic_context global_diagnostic_context; static diagnostic_context global_diagnostic_context;
diagnostic_context *global_dc = &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; /* Function of last error message;
more generally, function such that if next error message is in it more generally, function such that if next error message is in it
then we don't have to mention the function name. */ then we don't have to mention the function name. */
...@@ -177,7 +174,7 @@ int ...@@ -177,7 +174,7 @@ int
output_is_line_wrapping (buffer) output_is_line_wrapping (buffer)
output_buffer *buffer; output_buffer *buffer;
{ {
return diagnostic_line_cutoff (buffer) > 0; return output_line_cutoff (buffer) > 0;
} }
/* Return BUFFER's prefix. */ /* Return BUFFER's prefix. */
...@@ -200,19 +197,19 @@ set_real_maximum_length (buffer) ...@@ -200,19 +197,19 @@ set_real_maximum_length (buffer)
we'll emit prefix only once per diagnostic message, it is appropriate we'll emit prefix only once per diagnostic message, it is appropriate
not to increase unnecessarily the line-length cut-off. */ not to increase unnecessarily the line-length cut-off. */
if (! output_is_line_wrapping (buffer) if (! output_is_line_wrapping (buffer)
|| diagnostic_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE || output_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE
|| diagnostic_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER) || output_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer); line_wrap_cutoff (buffer) = output_line_cutoff (buffer);
else else
{ {
int prefix_length = int prefix_length =
output_prefix (buffer) ? strlen (output_prefix (buffer)) : 0; output_prefix (buffer) ? strlen (output_prefix (buffer)) : 0;
/* If the prefix is ridiculously too long, output at least /* If the prefix is ridiculously too long, output at least
32 characters. */ 32 characters. */
if (diagnostic_line_cutoff (buffer) - prefix_length < 32) if (output_line_cutoff (buffer) - prefix_length < 32)
line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer) + 32; line_wrap_cutoff (buffer) = output_line_cutoff (buffer) + 32;
else else
line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer); line_wrap_cutoff (buffer) = output_line_cutoff (buffer);
} }
} }
...@@ -224,7 +221,7 @@ output_set_maximum_length (buffer, length) ...@@ -224,7 +221,7 @@ output_set_maximum_length (buffer, length)
output_buffer *buffer; output_buffer *buffer;
int length; int length;
{ {
diagnostic_line_cutoff (buffer) = length; output_line_cutoff (buffer) = length;
set_real_maximum_length (buffer); set_real_maximum_length (buffer);
} }
...@@ -301,8 +298,8 @@ init_output_buffer (buffer, prefix, maximum_length) ...@@ -301,8 +298,8 @@ init_output_buffer (buffer, prefix, maximum_length)
memset (buffer, 0, sizeof (output_buffer)); memset (buffer, 0, sizeof (output_buffer));
obstack_init (&buffer->obstack); obstack_init (&buffer->obstack);
output_buffer_attached_stream (buffer) = stderr; output_buffer_attached_stream (buffer) = stderr;
diagnostic_line_cutoff (buffer) = maximum_length; output_line_cutoff (buffer) = maximum_length;
diagnostic_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc); output_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc);
output_set_prefix (buffer, prefix); output_set_prefix (buffer, prefix);
output_text_length (buffer) = 0; output_text_length (buffer) = 0;
clear_diagnostic_info (buffer); clear_diagnostic_info (buffer);
...@@ -354,7 +351,7 @@ output_emit_prefix (buffer) ...@@ -354,7 +351,7 @@ output_emit_prefix (buffer)
{ {
if (output_prefix (buffer) != NULL) if (output_prefix (buffer) != NULL)
{ {
switch (diagnostic_prefixing_rule (buffer)) switch (output_prefixing_rule (buffer))
{ {
default: default:
case DIAGNOSTICS_SHOW_PREFIX_NEVER: case DIAGNOSTICS_SHOW_PREFIX_NEVER:
...@@ -1091,7 +1088,7 @@ lhd_print_error_function (context, file) ...@@ -1091,7 +1088,7 @@ lhd_print_error_function (context, file)
char *prefix = file ? build_message_string ("%s: ", file) : NULL; char *prefix = file ? build_message_string ("%s: ", file) : NULL;
output_state os; output_state os;
os = output_buffer_state (context); os = diagnostic_state (context);
output_set_prefix ((output_buffer *) context, prefix); output_set_prefix ((output_buffer *) context, prefix);
if (current_function_decl == NULL) if (current_function_decl == NULL)
...@@ -1111,7 +1108,7 @@ lhd_print_error_function (context, file) ...@@ -1111,7 +1108,7 @@ lhd_print_error_function (context, file)
record_last_error_function (); record_last_error_function ();
output_buffer_to_stream ((output_buffer *) context); output_buffer_to_stream ((output_buffer *) context);
output_buffer_state (context) = os; diagnostic_state (context) = os;
free ((char*) prefix); free ((char*) prefix);
} }
} }
...@@ -1307,7 +1304,7 @@ output_do_verbatim (buffer, msgid, args_ptr) ...@@ -1307,7 +1304,7 @@ output_do_verbatim (buffer, msgid, args_ptr)
os = output_buffer_state (buffer); os = output_buffer_state (buffer);
output_prefix (buffer) = NULL; output_prefix (buffer) = NULL;
diagnostic_prefixing_rule (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER; output_prefixing_rule (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
output_buffer_text_cursor (buffer) = _(msgid); output_buffer_text_cursor (buffer) = _(msgid);
output_buffer_ptr_to_format_args (buffer) = args_ptr; output_buffer_ptr_to_format_args (buffer) = args_ptr;
output_set_maximum_length (buffer, 0); output_set_maximum_length (buffer, 0);
......
...@@ -130,9 +130,8 @@ struct output_buffer ...@@ -130,9 +130,8 @@ struct output_buffer
printer_fn format_decoder; printer_fn format_decoder;
}; };
/* Current state of the diagnostic_context' output_buffer. This macro /* Current state of an output_buffer. */
accepts both `diagnostic_context *' and `output_buffer *'. */ #define output_buffer_state(BUFFER) (BUFFER)->state
#define output_buffer_state(BUFFER) ((output_buffer *)(BUFFER))->state
/* The stream attached to the output_buffer, where the formatted /* The stream attached to the output_buffer, where the formatted
diagnostics will ultimately go. Works only on `output_buffer *'. */ diagnostics will ultimately go. Works only on `output_buffer *'. */
...@@ -157,6 +156,16 @@ struct output_buffer ...@@ -157,6 +156,16 @@ struct output_buffer
#define output_message_text(BUFFER) \ #define output_message_text(BUFFER) \
((const char *) obstack_base (&(BUFFER)->obstack)) ((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 /* This data structure bundles altogether any information relevant to
the context of a diagnostic message. */ the context of a diagnostic message. */
struct diagnostic_context struct diagnostic_context
...@@ -224,31 +233,29 @@ struct diagnostic_context ...@@ -224,31 +233,29 @@ struct diagnostic_context
/* Extension hook for client. */ /* Extension hook for client. */
#define diagnostic_auxiliary_data(DC) (DC)->x_data #define diagnostic_auxiliary_data(DC) (DC)->x_data
/* Client supplied function used to decode formats. Can operate on both /* Same as output_format_decoder. Works on 'diagnostic_context *'. */
`output_buffer *' and `diagnostic_context *'. */ #define diagnostic_format_decoder(DC) output_format_decoder (&(DC)->buffer)
#define diagnostic_format_decoder(DC) ((output_buffer *)(DC))->format_decoder
/* Prefixing rule used in formatting a diagnostic message. Accepts both /* Same as output_prefixing_rule. Works on 'diagnostic_context *'. */
`output_buffer *' and `diagnostic_context *'. */ #define diagnostic_prefixing_rule(DC) output_prefixing_rule (&(DC)->buffer)
#define diagnostic_prefixing_rule(DC) \
((output_buffer *)(DC))->state.prefixing_rule
/* Maximum characters per line in automatic line wrapping mode. /* Maximum characters per line in automatic line wrapping mode.
Zero means don't wrap lines. */ Zero means don't wrap lines. */
#define diagnostic_line_cutoff(DC) \ #define diagnostic_line_cutoff(DC) output_line_cutoff (&(DC)->buffer)
((output_buffer *)(DC))->state.ideal_maximum_length
/* 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 /* This diagnostic context is used by front-ends that directly output
diagnostic messages without going through `error', `warning', diagnostic messages without going through `error', `warning',
and similar functions. */ and similar functions. */
extern diagnostic_context *global_dc; 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. */ /* The total count of a KIND of diagnostics meitted so far. */
#define diagnostic_kind_count(DC, DK) \ #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 /* The number of errors that have been issued so far. Ideally, these
would take an output_buffer as an argument. */ would take an output_buffer as an argument. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment