#include "toplev.h"
#include "intl.h"
#include "diagnostic.h"
+#include "langhooks.h"
+#include "langhooks-def.h"
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
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. */
/* Used to detect when input_file_stack has changed since last described. */
static int last_error_tick;
-/* Called by report_error_function to print out function name.
- Default may be overridden by language front-ends. */
-
-void (*print_error_function) PARAMS ((diagnostic_context *, const char *))
- = default_print_error_function;
-
/* Prevent recursion into the error handler. */
static int diagnostic_lock;
output_is_line_wrapping (buffer)
output_buffer *buffer;
{
- return diagnostic_line_cutoff (buffer) > 0;
+ return output_line_cutoff (buffer) > 0;
}
/* Return BUFFER's prefix. */
we'll emit prefix only once per diagnostic message, it is appropriate
not to increase unnecessarily the line-length cut-off. */
if (! output_is_line_wrapping (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);
+ || output_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE
+ || output_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
+ line_wrap_cutoff (buffer) = output_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 (diagnostic_line_cutoff (buffer) - prefix_length < 32)
- line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer) + 32;
+ if (output_line_cutoff (buffer) - prefix_length < 32)
+ line_wrap_cutoff (buffer) = output_line_cutoff (buffer) + 32;
else
- line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer);
+ line_wrap_cutoff (buffer) = output_line_cutoff (buffer);
}
}
output_buffer *buffer;
int length;
{
- diagnostic_line_cutoff (buffer) = length;
+ output_line_cutoff (buffer) = length;
set_real_maximum_length (buffer);
}
memset (buffer, 0, sizeof (output_buffer));
obstack_init (&buffer->obstack);
output_buffer_attached_stream (buffer) = stderr;
- diagnostic_line_cutoff (buffer) = maximum_length;
- diagnostic_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc);
+ output_line_cutoff (buffer) = maximum_length;
+ output_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc);
output_set_prefix (buffer, prefix);
output_text_length (buffer) = 0;
clear_diagnostic_info (buffer);
{
if (output_prefix (buffer) != NULL)
{
- switch (diagnostic_prefixing_rule (buffer))
+ switch (output_prefixing_rule (buffer))
{
default:
case DIAGNOSTICS_SHOW_PREFIX_NEVER:
if (*p == '%') /* Print the name. */
{
const char *const n = (DECL_NAME (decl)
- ? (*decl_printable_name) (decl, 2)
+ ? (*lang_hooks.decl_printable_name) (decl, 2)
: _("((anonymous))"));
output_add_string (buffer, n);
while (*p)
if (rtl_dump_and_exit)
verbatim ("%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
else
- verbatim (" %s", (*decl_printable_name) (decl, 2));
+ verbatim (" %s", (*lang_hooks.decl_printable_name) (decl, 2));
fflush (stderr);
output_needs_newline (diagnostic_buffer) = 1;
record_last_error_function ();
an error. */
void
-default_print_error_function (context, file)
+lhd_print_error_function (context, file)
diagnostic_context *context;
const char *file;
{
char *prefix = file ? build_message_string ("%s: ", file) : NULL;
output_state os;
- os = output_buffer_state (context);
+ os = diagnostic_state (context);
output_set_prefix ((output_buffer *) context, prefix);
if (current_function_decl == NULL)
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
output_printf
((output_buffer *) context, "In member function `%s':",
- (*decl_printable_name) (current_function_decl, 2));
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2));
else
output_printf
((output_buffer *) context, "In function `%s':",
- (*decl_printable_name) (current_function_decl, 2));
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2));
}
output_add_newline ((output_buffer *) context);
record_last_error_function ();
output_buffer_to_stream ((output_buffer *) context);
- output_buffer_state (context) = os;
+ diagnostic_state (context) = os;
free ((char*) prefix);
}
}
const char *file ATTRIBUTE_UNUSED;
{
report_problematic_module ((output_buffer *) global_dc);
- (*print_error_function) (global_dc, input_filename);
+ (*lang_hooks.print_error_function) (global_dc, input_filename);
}
void
os = output_buffer_state (buffer);
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_ptr_to_format_args (buffer) = args_ptr;
output_set_maximum_length (buffer, 0);