Commit 43b45e94 by Richard Kenner

diagnostic.c (fatal_function): New variable.

	* diagnostic.c (fatal_function): New variable.
	(set_fatal_function): New function.
	(fatal): Call it.
	* diagnostic.h (set_fatal_function): New declaration.

From-SVN: r35731
parent 56847207
...@@ -127,7 +127,7 @@ static tree last_error_function = NULL; ...@@ -127,7 +127,7 @@ static tree last_error_function = NULL;
static int last_error_tick; static int last_error_tick;
/* Called by report_error_function to print out function name. /* Called by report_error_function to print out function name.
* Default may be overridden by language front-ends. */ Default may be overridden by language front-ends. */
void (*print_error_function) PARAMS ((const char *)) = void (*print_error_function) PARAMS ((const char *)) =
default_print_error_function; default_print_error_function;
...@@ -153,6 +153,7 @@ initialize_diagnostics () ...@@ -153,6 +153,7 @@ initialize_diagnostics ()
/* By default, we don't line-wrap messages. */ /* By default, we don't line-wrap messages. */
diagnostic_message_length_per_line = 0; diagnostic_message_length_per_line = 0;
set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE); set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
/* Proceed to actual initialization. */ /* Proceed to actual initialization. */
default_initialize_buffer (diagnostic_buffer); default_initialize_buffer (diagnostic_buffer);
} }
...@@ -165,6 +166,7 @@ set_message_prefixing_rule (rule) ...@@ -165,6 +166,7 @@ set_message_prefixing_rule (rule)
} }
/* Returns true if BUFFER is in line-wrappind mode. */ /* Returns true if BUFFER is in line-wrappind mode. */
int int
output_is_line_wrapping (buffer) output_is_line_wrapping (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -173,6 +175,7 @@ output_is_line_wrapping (buffer) ...@@ -173,6 +175,7 @@ output_is_line_wrapping (buffer)
} }
/* Return BUFFER's prefix. */ /* Return BUFFER's prefix. */
const char * const char *
output_get_prefix (buffer) output_get_prefix (buffer)
const output_buffer *buffer; const output_buffer *buffer;
...@@ -182,6 +185,7 @@ output_get_prefix (buffer) ...@@ -182,6 +185,7 @@ output_get_prefix (buffer)
/* Subroutine of output_set_maximum_length. Set up BUFFER's /* Subroutine of output_set_maximum_length. Set up BUFFER's
internal maximum characters per line. */ internal maximum characters per line. */
static void static void
set_real_maximum_length (buffer) set_real_maximum_length (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -204,6 +208,7 @@ set_real_maximum_length (buffer) ...@@ -204,6 +208,7 @@ set_real_maximum_length (buffer)
/* Sets the number of maximum characters per line BUFFER can output /* Sets the number of maximum characters per line BUFFER can output
in line-wrapping mode. A LENGTH value 0 suppresses line-wrapping. */ in line-wrapping mode. A LENGTH value 0 suppresses line-wrapping. */
void void
output_set_maximum_length (buffer, length) output_set_maximum_length (buffer, length)
output_buffer *buffer; output_buffer *buffer;
...@@ -214,6 +219,7 @@ output_set_maximum_length (buffer, length) ...@@ -214,6 +219,7 @@ output_set_maximum_length (buffer, length)
} }
/* Sets BUFFER's PREFIX. */ /* Sets BUFFER's PREFIX. */
void void
output_set_prefix (buffer, prefix) output_set_prefix (buffer, prefix)
output_buffer *buffer; output_buffer *buffer;
...@@ -224,7 +230,7 @@ output_set_prefix (buffer, prefix) ...@@ -224,7 +230,7 @@ output_set_prefix (buffer, prefix)
prefix_was_emitted_for (buffer) = 0; prefix_was_emitted_for (buffer) = 0;
} }
/* Free BUFFER's prefix, a previously malloc()'d string. */ /* Free BUFFER's prefix, a previously malloc'd string. */
void void
output_destroy_prefix (buffer) output_destroy_prefix (buffer)
...@@ -238,6 +244,7 @@ output_destroy_prefix (buffer) ...@@ -238,6 +244,7 @@ output_destroy_prefix (buffer)
} }
/* Zero out any text output so far in BUFFER. */ /* Zero out any text output so far in BUFFER. */
static void static void
clear_text_info (buffer) clear_text_info (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -247,6 +254,7 @@ clear_text_info (buffer) ...@@ -247,6 +254,7 @@ clear_text_info (buffer)
} }
/* Zero out any diagnostic data used so far by BUFFER. */ /* Zero out any diagnostic data used so far by BUFFER. */
static void static void
clear_diagnostic_info (buffer) clear_diagnostic_info (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -258,6 +266,7 @@ clear_diagnostic_info (buffer) ...@@ -258,6 +266,7 @@ clear_diagnostic_info (buffer)
/* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH /* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
characters per line. */ characters per line. */
void void
init_output_buffer (buffer, prefix, maximum_length) init_output_buffer (buffer, prefix, maximum_length)
output_buffer *buffer; output_buffer *buffer;
...@@ -283,6 +292,7 @@ default_initialize_buffer (buffer) ...@@ -283,6 +292,7 @@ default_initialize_buffer (buffer)
/* Recompute diagnostic_buffer's attributes to reflect any change /* Recompute diagnostic_buffer's attributes to reflect any change
in diagnostic formatting global options. */ in diagnostic formatting global options. */
void void
reshape_diagnostic_buffer () reshape_diagnostic_buffer ()
{ {
...@@ -303,6 +313,7 @@ output_clear (buffer) ...@@ -303,6 +313,7 @@ output_clear (buffer)
/* Finishes to construct a NULL-terminated character string representing /* Finishes to construct a NULL-terminated character string representing
the BUFFERed message. */ the BUFFERed message. */
const char * const char *
output_finish (buffer) output_finish (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -313,6 +324,7 @@ output_finish (buffer) ...@@ -313,6 +324,7 @@ output_finish (buffer)
/* Return the amount of characters BUFFER can accept to /* Return the amount of characters BUFFER can accept to
make a full line. */ make a full line. */
int int
output_space_left (buffer) output_space_left (buffer)
const output_buffer *buffer; const output_buffer *buffer;
...@@ -321,6 +333,7 @@ output_space_left (buffer) ...@@ -321,6 +333,7 @@ output_space_left (buffer)
} }
/* Write out BUFFER's prefix. */ /* Write out BUFFER's prefix. */
void void
output_emit_prefix (buffer) output_emit_prefix (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -350,6 +363,7 @@ output_emit_prefix (buffer) ...@@ -350,6 +363,7 @@ output_emit_prefix (buffer)
} }
/* Have BUFFER start a new line. */ /* Have BUFFER start a new line. */
void void
output_add_newline (buffer) output_add_newline (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -359,6 +373,7 @@ output_add_newline (buffer) ...@@ -359,6 +373,7 @@ output_add_newline (buffer)
} }
/* Appends a character to BUFFER. */ /* Appends a character to BUFFER. */
void void
output_add_character (buffer, c) output_add_character (buffer, c)
output_buffer *buffer; output_buffer *buffer;
...@@ -371,6 +386,7 @@ output_add_character (buffer, c) ...@@ -371,6 +386,7 @@ output_add_character (buffer, c)
} }
/* Adds a space to BUFFER. */ /* Adds a space to BUFFER. */
void void
output_add_space (buffer) output_add_space (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -386,6 +402,7 @@ output_add_space (buffer) ...@@ -386,6 +402,7 @@ output_add_space (buffer)
/* These functions format an INTEGER into BUFFER as suggested by their /* These functions format an INTEGER into BUFFER as suggested by their
names. */ names. */
void void
output_decimal (buffer, i) output_decimal (buffer, i)
output_buffer *buffer; output_buffer *buffer;
...@@ -452,6 +469,7 @@ output_long_hexadecimal (buffer, i) ...@@ -452,6 +469,7 @@ output_long_hexadecimal (buffer, i)
/* Append to BUFFER a string specified by its STARTING character /* Append to BUFFER a string specified by its STARTING character
and LENGTH. */ and LENGTH. */
static void static void
output_append_r (buffer, start, length) output_append_r (buffer, start, length)
output_buffer *buffer; output_buffer *buffer;
...@@ -466,6 +484,7 @@ output_append_r (buffer, start, length) ...@@ -466,6 +484,7 @@ output_append_r (buffer, start, length)
done. However, if beginning a new line then emit output_prefix (BUFFER) done. However, if beginning a new line then emit output_prefix (BUFFER)
and skip any leading whitespace if appropriate. The caller must ensure and skip any leading whitespace if appropriate. The caller must ensure
that it is safe to do so. */ that it is safe to do so. */
void void
output_append (buffer, start, end) output_append (buffer, start, end)
output_buffer *buffer; output_buffer *buffer;
...@@ -484,6 +503,7 @@ output_append (buffer, start, end) ...@@ -484,6 +503,7 @@ output_append (buffer, start, end)
} }
/* Wrap a text delimited by START and END into BUFFER. */ /* Wrap a text delimited by START and END into BUFFER. */
static void static void
wrap_text (buffer, start, end) wrap_text (buffer, start, end)
output_buffer *buffer; output_buffer *buffer;
...@@ -565,6 +585,7 @@ output_to_stream (buffer, file) ...@@ -565,6 +585,7 @@ output_to_stream (buffer, file)
%s: string. %s: string.
%%: `%'. %%: `%'.
%*.s: a substring the length of which is specified by an integer. */ %*.s: a substring the length of which is specified by an integer. */
static void static void
output_format (buffer) output_format (buffer)
output_buffer *buffer; output_buffer *buffer;
...@@ -573,6 +594,7 @@ output_format (buffer) ...@@ -573,6 +594,7 @@ output_format (buffer)
++output_buffer_text_cursor (buffer)) ++output_buffer_text_cursor (buffer))
{ {
int long_integer = 0; int long_integer = 0;
/* Ignore text. */ /* Ignore text. */
{ {
const char *p = output_buffer_text_cursor (buffer); const char *p = output_buffer_text_cursor (buffer);
...@@ -581,6 +603,7 @@ output_format (buffer) ...@@ -581,6 +603,7 @@ output_format (buffer)
maybe_wrap_text (buffer, output_buffer_text_cursor (buffer), p); maybe_wrap_text (buffer, output_buffer_text_cursor (buffer), p);
output_buffer_text_cursor (buffer) = p; output_buffer_text_cursor (buffer) = p;
} }
if (!*output_buffer_text_cursor (buffer)) if (!*output_buffer_text_cursor (buffer))
break; break;
...@@ -670,11 +693,11 @@ output_format (buffer) ...@@ -670,11 +693,11 @@ output_format (buffer)
break; break;
default: default:
if (!lang_printer || !(*lang_printer) (buffer)) if (! lang_printer || !(*lang_printer) (buffer))
{ {
/* Hmmm. The front-end failed to install a format translator /* Hmmm. The front-end failed to install a format translator
but called us with an unrecognized format. Sorry. */ but called us with an unrecognized format. Sorry. */
abort(); abort ();
} }
} }
} }
...@@ -881,6 +904,7 @@ file_and_line_for_asm (insn, pfile, pline) ...@@ -881,6 +904,7 @@ file_and_line_for_asm (insn, pfile, pline)
/* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number /* Report a diagnostic MESSAGE (an errror or a WARNING) at the line number
of the insn INSN. This is used only when INSN is an `asm' with operands, of the insn INSN. This is used only when INSN is an `asm' with operands,
and each ASM_OPERANDS records its own source file and line. */ and each ASM_OPERANDS records its own source file and line. */
static void static void
diagnostic_for_asm (insn, msg, args_ptr, warn) diagnostic_for_asm (insn, msg, args_ptr, warn)
rtx insn; rtx insn;
...@@ -898,6 +922,7 @@ diagnostic_for_asm (insn, msg, args_ptr, warn) ...@@ -898,6 +922,7 @@ diagnostic_for_asm (insn, msg, args_ptr, warn)
/* Report a diagnostic MESSAGE at the declaration DECL. /* Report a diagnostic MESSAGE at the declaration DECL.
MSG is a format string which uses %s to substitute the declaration MSG is a format string which uses %s to substitute the declaration
name; subsequent substitutions are a la output_format. */ name; subsequent substitutions are a la output_format. */
static void static void
diagnostic_for_decl (decl, msg, args_ptr, warn) diagnostic_for_decl (decl, msg, args_ptr, warn)
tree decl; tree decl;
...@@ -956,6 +981,7 @@ count_error (warningp) ...@@ -956,6 +981,7 @@ count_error (warningp)
} }
/* Print a diagnistic MSGID on FILE. */ /* Print a diagnistic MSGID on FILE. */
void void
fnotice VPARAMS ((FILE *file, const char *msgid, ...)) fnotice VPARAMS ((FILE *file, const char *msgid, ...))
{ {
...@@ -998,6 +1024,7 @@ fatal_io_error (name) ...@@ -998,6 +1024,7 @@ fatal_io_error (name)
} }
/* Issue a pedantic warning MSGID. */ /* Issue a pedantic warning MSGID. */
void void
pedwarn VPARAMS ((const char *msgid, ...)) pedwarn VPARAMS ((const char *msgid, ...))
{ {
...@@ -1018,6 +1045,7 @@ pedwarn VPARAMS ((const char *msgid, ...)) ...@@ -1018,6 +1045,7 @@ pedwarn VPARAMS ((const char *msgid, ...))
} }
/* Issue a pedantic waring about DECL. */ /* Issue a pedantic waring about DECL. */
void void
pedwarn_with_decl VPARAMS ((tree decl, const char *msgid, ...)) pedwarn_with_decl VPARAMS ((tree decl, const char *msgid, ...))
{ {
...@@ -1045,6 +1073,7 @@ pedwarn_with_decl VPARAMS ((tree decl, const char *msgid, ...)) ...@@ -1045,6 +1073,7 @@ pedwarn_with_decl VPARAMS ((tree decl, const char *msgid, ...))
} }
/* Same as above but within the context FILE and LINE. */ /* Same as above but within the context FILE and LINE. */
void void
pedwarn_with_file_and_line VPARAMS ((const char *file, int line, pedwarn_with_file_and_line VPARAMS ((const char *file, int line,
const char *msgid, ...)) const char *msgid, ...))
...@@ -1069,6 +1098,7 @@ pedwarn_with_file_and_line VPARAMS ((const char *file, int line, ...@@ -1069,6 +1098,7 @@ pedwarn_with_file_and_line VPARAMS ((const char *file, int line,
} }
/* Just apologize with MSGID. */ /* Just apologize with MSGID. */
void void
sorry VPARAMS ((const char *msgid, ...)) sorry VPARAMS ((const char *msgid, ...))
{ {
...@@ -1268,6 +1298,18 @@ error VPARAMS ((const char *msgid, ...)) ...@@ -1268,6 +1298,18 @@ error VPARAMS ((const char *msgid, ...))
/* Report a fatal error at the current line number. Allow a front end to /* Report a fatal error at the current line number. Allow a front end to
intercept the message. */ intercept the message. */
static void (*fatal_function) PARAMS((const char *, va_list *));
/* Set the function to call when a fatal error occurs. */
void
set_fatal_function (f)
void (*f) PARAMS ((const char *, va_list *));
{
fatal_function = f;
}
void void
fatal VPARAMS ((const char *msgid, ...)) fatal VPARAMS ((const char *msgid, ...))
{ {
...@@ -1282,6 +1324,9 @@ fatal VPARAMS ((const char *msgid, ...)) ...@@ -1282,6 +1324,9 @@ fatal VPARAMS ((const char *msgid, ...))
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
if (fatal_function != 0)
(*fatal_function) (_(msgid), &ap);
report_diagnostic (msgid, &ap, input_filename, lineno, 0); report_diagnostic (msgid, &ap, input_filename, lineno, 0);
va_end (ap); va_end (ap);
exit (FATAL_EXIT_CODE); exit (FATAL_EXIT_CODE);
......
...@@ -101,6 +101,8 @@ extern int diagnostic_message_length_per_line; ...@@ -101,6 +101,8 @@ extern int diagnostic_message_length_per_line;
extern output_buffer *diagnostic_buffer; extern output_buffer *diagnostic_buffer;
/* Prototypes */ /* Prototypes */
void set_fatal_function PARAMS ((void (*) PARAMS ((const char *,
va_list *))));
void report_diagnostic PARAMS ((const char *, va_list *, void report_diagnostic PARAMS ((const char *, va_list *,
const char *, int, int)); const char *, int, int));
void initialize_diagnostics PARAMS ((void)); void initialize_diagnostics PARAMS ((void));
......
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