Commit c91ad699 by Gabriel Dos Reis Committed by Gabriel Dos Reis

diagnostic.c (vline_wrapper_message_with_location, [...]): Remove.

2000-07-12  Gabriel Dos Reis  <gdr@codesourcery.com>

        * diagnostic.c (vline_wrapper_message_with_location,
        v_message_with_file_and_line, v_error_with_file_and_file,
        v_error_for_asm, v_warning_for_asm, vfatal,
        v_warning_with_file_and_line, v_pedwarn_with_file_and_line,
        vsorry, verror, vwarning, vpedwarn): Remove.
        (diagnostic_for_asm): New function.
        (pedwarn, error, warning, pedwarn_with_file_and_line,
        error_with_file_and_line, warning_with_file_and_line, sorry,
        error_for_asm, warning_for_asm, fatal): Reimplement.
        (finish_diagnostic): Clear diagnostic info as well.

From-SVN: r35011
parent 530d0ba5
2000-07-12 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
* diagnostic.c (vline_wrapper_message_with_location,
v_message_with_file_and_line, v_error_with_file_and_file,
v_error_for_asm, v_warning_for_asm, vfatal,
v_warning_with_file_and_line, v_pedwarn_with_file_and_line,
vsorry, verror, vwarning, vpedwarn): Remove.
(diagnostic_for_asm): New function.
(pedwarn, error, warning, pedwarn_with_file_and_line,
error_with_file_and_line, warning_with_file_and_line, sorry,
error_for_asm, warning_for_asm, fatal): Reimplement.
(finish_diagnostic): Clear diagnostic info as well.
2000-07-13 Neil Booth <NeilB@earthling.net> 2000-07-13 Neil Booth <NeilB@earthling.net>
* c-common.h (flag_digraphs): New. * c-common.h (flag_digraphs): New.
......
...@@ -77,30 +77,13 @@ static char *context_as_prefix PARAMS ((const char *, int, int)); ...@@ -77,30 +77,13 @@ static char *context_as_prefix PARAMS ((const char *, int, int));
static void output_do_printf PARAMS ((output_buffer *, const char *)); static void output_do_printf PARAMS ((output_buffer *, const char *));
static void line_wrapper_printf PARAMS ((FILE *, const char *, ...)) static void line_wrapper_printf PARAMS ((FILE *, const char *, ...))
ATTRIBUTE_PRINTF_2; ATTRIBUTE_PRINTF_2;
static void vline_wrapper_message_with_location PARAMS ((const char *, int,
int, const char *,
va_list));
static void notice PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1; static void notice PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1;
static void v_message_with_file_and_line PARAMS ((const char *, int, int,
const char *, va_list));
static void v_message_with_decl PARAMS ((tree, int, const char *, va_list)); static void v_message_with_decl PARAMS ((tree, int, const char *, va_list));
static void file_and_line_for_asm PARAMS ((rtx, const char **, int *)); static void file_and_line_for_asm PARAMS ((rtx, const char **, int *));
static void v_error_with_file_and_line PARAMS ((const char *, int, static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list, int));
const char *, va_list));
static void v_error_with_decl PARAMS ((tree, const char *, va_list)); static void v_error_with_decl PARAMS ((tree, const char *, va_list));
static void v_error_for_asm PARAMS ((rtx, const char *, va_list));
static void vfatal PARAMS ((const char *, va_list)) ATTRIBUTE_NORETURN;
static void v_warning_with_file_and_line PARAMS ((const char *, int,
const char *, va_list));
static void v_warning_with_decl PARAMS ((tree, const char *, va_list)); static void v_warning_with_decl PARAMS ((tree, const char *, va_list));
static void v_warning_for_asm PARAMS ((rtx, const char *, va_list));
static void v_pedwarn_with_decl PARAMS ((tree, const char *, va_list)); static void v_pedwarn_with_decl PARAMS ((tree, const char *, va_list));
static void v_pedwarn_with_file_and_line PARAMS ((const char *, int,
const char *, va_list));
static void vsorry PARAMS ((const char *, va_list));
static void verror PARAMS ((const char *, va_list));
static void vwarning PARAMS ((const char *, va_list));
static void vpedwarn PARAMS ((const char *, va_list));
static void report_file_and_line PARAMS ((const char *, int, int)); static void report_file_and_line PARAMS ((const char *, int, int));
static void vnotice PARAMS ((FILE *, const char *, va_list)); static void vnotice PARAMS ((FILE *, const char *, va_list));
static void set_real_maximum_length PARAMS ((output_buffer *)); static void set_real_maximum_length PARAMS ((output_buffer *));
...@@ -834,27 +817,6 @@ line_wrapper_printf VPARAMS ((FILE *file, const char *msgid, ...)) ...@@ -834,27 +817,6 @@ line_wrapper_printf VPARAMS ((FILE *file, const char *msgid, ...))
va_end (ap); va_end (ap);
} }
static void
vline_wrapper_message_with_location (file, line, warn, msgid, ap)
const char *file;
int line;
int warn;
const char *msgid;
va_list ap;
{
output_buffer buffer;
init_output_buffer (&buffer, context_as_prefix (file, line, warn),
diagnostic_message_length_per_line);
output_buffer_ptr_to_format_args (&buffer) = &ap;
output_do_printf (&buffer, msgid);
output_to_stream (&buffer, stderr);
fputc ('\n', stderr);
output_destroy_prefix (&buffer);
}
/* Print the message MSGID in FILE. */ /* Print the message MSGID in FILE. */
static void static void
...@@ -903,21 +865,6 @@ report_file_and_line (file, line, warn) ...@@ -903,21 +865,6 @@ report_file_and_line (file, line, warn)
notice ("warning: "); notice ("warning: ");
} }
/* Print a message relevant to line LINE of file FILE. */
static void
v_message_with_file_and_line (file, line, warn, msgid, ap)
const char *file;
int line;
int warn;
const char *msgid;
va_list ap;
{
report_file_and_line (file, line, warn);
vnotice (stderr, msgid, ap);
fputc ('\n', stderr);
}
/* Print a message relevant to the given DECL. */ /* Print a message relevant to the given DECL. */
static void static void
...@@ -1040,21 +987,21 @@ file_and_line_for_asm (insn, pfile, pline) ...@@ -1040,21 +987,21 @@ file_and_line_for_asm (insn, pfile, pline)
} }
} }
/* Report an error at line LINE of file FILE. */ /* 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,
and each ASM_OPERANDS records its own source file and line. */
static void static void
v_error_with_file_and_line (file, line, msgid, ap) diagnostic_for_asm (insn, msg, args, warn)
const char *file; rtx insn;
int line; const char *msg;
const char *msgid; va_list args;
va_list ap; int warn;
{ {
count_error (0); const char *file;
report_error_function (file); int line;
if (doing_line_wrapping ())
vline_wrapper_message_with_location (file, line, 0, msgid, ap); file_and_line_for_asm (insn, &file, &line);
else report_diagnostic (msg, args, file, line, warn);
v_message_with_file_and_line (file, line, 0, msgid, ap);
} }
/* Report an error at the declaration DECL. /* Report an error at the declaration DECL.
...@@ -1072,75 +1019,6 @@ v_error_with_decl (decl, msgid, ap) ...@@ -1072,75 +1019,6 @@ v_error_with_decl (decl, msgid, ap)
v_message_with_decl (decl, 0, msgid, ap); v_message_with_decl (decl, 0, msgid, ap);
} }
/* Report an error at the line number 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. */
static void
v_error_for_asm (insn, msgid, ap)
rtx insn;
const char *msgid;
va_list ap;
{
const char *file;
int line;
count_error (0);
file_and_line_for_asm (insn, &file, &line);
report_error_function (file);
v_message_with_file_and_line (file, line, 0, msgid, ap);
}
/* Report an error at the current line number. */
static void
verror (msgid, ap)
const char *msgid;
va_list ap;
{
v_error_with_file_and_line (input_filename, lineno, msgid, ap);
}
/* Report a fatal error at the current line number. Allow a front end to
intercept the message. */
static void (*fatal_function) PARAMS ((const char *, va_list));
static void
vfatal (msgid, ap)
const char *msgid;
va_list ap;
{
if (fatal_function != 0)
(*fatal_function) (_(msgid), ap);
verror (msgid, ap);
exit (FATAL_EXIT_CODE);
}
/* Report a warning at line LINE of file FILE. */
static void
v_warning_with_file_and_line (file, line, msgid, ap)
const char *file;
int line;
const char *msgid;
va_list ap;
{
if (count_error (1))
{
report_error_function (file);
if (doing_line_wrapping ())
vline_wrapper_message_with_location (file, line, 1, msgid, ap);
else
v_message_with_file_and_line (file, line, 1, msgid, ap);
}
}
/* Report a warning at the declaration DECL. /* Report a warning at the declaration DECL.
MSGID is a format string which uses %s to substitute the declaration MSGID is a format string which uses %s to substitute the declaration
name; subsequent substitutions are a la printf. */ name; subsequent substitutions are a la printf. */
...@@ -1158,55 +1036,10 @@ v_warning_with_decl (decl, msgid, ap) ...@@ -1158,55 +1036,10 @@ v_warning_with_decl (decl, msgid, ap)
} }
} }
/* Report a warning at the line number 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. */
static void
v_warning_for_asm (insn, msgid, ap)
rtx insn;
const char *msgid;
va_list ap;
{
if (count_error (1))
{
const char *file;
int line;
file_and_line_for_asm (insn, &file, &line);
report_error_function (file);
v_message_with_file_and_line (file, line, 1, msgid, ap);
}
}
/* Report a warning at the current line number. */
static void
vwarning (msgid, ap)
const char *msgid;
va_list ap;
{
v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
}
/* These functions issue either warnings or errors depending on /* These functions issue either warnings or errors depending on
-pedantic-errors. */ -pedantic-errors. */
static void static void
vpedwarn (msgid, ap)
const char *msgid;
va_list ap;
{
if (flag_pedantic_errors)
verror (msgid, ap);
else
vwarning (msgid, ap);
}
static void
v_pedwarn_with_decl (decl, msgid, ap) v_pedwarn_with_decl (decl, msgid, ap)
tree decl; tree decl;
const char *msgid; const char *msgid;
...@@ -1228,38 +1061,6 @@ v_pedwarn_with_decl (decl, msgid, ap) ...@@ -1228,38 +1061,6 @@ v_pedwarn_with_decl (decl, msgid, ap)
} }
} }
static void
v_pedwarn_with_file_and_line (file, line, msgid, ap)
const char *file;
int line;
const char *msgid;
va_list ap;
{
if (flag_pedantic_errors)
v_error_with_file_and_line (file, line, msgid, ap);
else
v_warning_with_file_and_line (file, line, msgid, ap);
}
/* Apologize for not implementing some feature. */
static void
vsorry (msgid, ap)
const char *msgid;
va_list ap;
{
sorrycount++;
if (input_filename)
fprintf (stderr, "%s:%d: ", input_filename, lineno);
else
fprintf (stderr, "%s: ", progname);
notice ("sorry, not implemented: ");
vnotice (stderr, msgid, ap);
fputc ('\n', stderr);
}
/* Count an error or warning. Return 1 if the message should be printed. */ /* Count an error or warning. Return 1 if the message should be printed. */
...@@ -1344,7 +1145,7 @@ pedwarn VPARAMS ((const char *msgid, ...)) ...@@ -1344,7 +1145,7 @@ pedwarn VPARAMS ((const char *msgid, ...))
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
vpedwarn (msgid, ap); report_diagnostic (msgid, ap, input_filename, lineno, !flag_pedantic_errors);
va_end (ap); va_end (ap);
} }
...@@ -1389,7 +1190,7 @@ pedwarn_with_file_and_line VPARAMS ((const char *file, int line, ...@@ -1389,7 +1190,7 @@ pedwarn_with_file_and_line VPARAMS ((const char *file, int line,
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
v_pedwarn_with_file_and_line (file, line, msgid, ap); report_diagnostic (msgid, ap, file, line, !flag_pedantic_errors);
va_end (ap); va_end (ap);
} }
...@@ -1401,14 +1202,23 @@ sorry VPARAMS ((const char *msgid, ...)) ...@@ -1401,14 +1202,23 @@ sorry VPARAMS ((const char *msgid, ...))
const char *msgid; const char *msgid;
#endif #endif
va_list ap; va_list ap;
output_state os;
os = diagnostic_buffer->state;
VA_START (ap, msgid); VA_START (ap, msgid);
#ifndef ANSI_PROTOTYPES #ifndef ANSI_PROTOTYPES
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
++sorrycount;
vsorry (msgid, ap); output_set_prefix
(diagnostic_buffer, context_as_prefix (input_filename, lineno, 0));
output_printf (diagnostic_buffer, "sorry, not implemented: ");
output_buffer_ptr_to_format_args (diagnostic_buffer) = &ap;
output_buffer_text_cursor (diagnostic_buffer) = msgid;
output_format (diagnostic_buffer);
finish_diagnostic ();
diagnostic_buffer->state = os;
va_end (ap); va_end (ap);
} }
...@@ -1551,7 +1361,7 @@ error_with_file_and_line VPARAMS ((const char *file, int line, ...@@ -1551,7 +1361,7 @@ error_with_file_and_line VPARAMS ((const char *file, int line,
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
v_error_with_file_and_line (file, line, msgid, ap); report_diagnostic (msgid, ap, file, line, /* warn = */ 0);
va_end (ap); va_end (ap);
} }
...@@ -1591,7 +1401,7 @@ error_for_asm VPARAMS ((rtx insn, const char *msgid, ...)) ...@@ -1591,7 +1401,7 @@ error_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
v_error_for_asm (insn, msgid, ap); diagnostic_for_asm (insn, msgid, ap, /* warn = */ 0);
va_end (ap); va_end (ap);
} }
...@@ -1609,12 +1419,14 @@ error VPARAMS ((const char *msgid, ...)) ...@@ -1609,12 +1419,14 @@ error VPARAMS ((const char *msgid, ...))
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
verror (msgid, ap); report_diagnostic (msgid, ap, input_filename, lineno, /* warn = */ 0);
va_end (ap); va_end (ap);
} }
/* Set the function to call when a fatal error occurs. */ /* Set the function to call when a fatal error occurs. */
static void (*fatal_function) PARAMS ((const char *, va_list));
void void
set_fatal_function (f) set_fatal_function (f)
void (*f) PARAMS ((const char *, va_list)); void (*f) PARAMS ((const char *, va_list));
...@@ -1622,6 +1434,8 @@ set_fatal_function (f) ...@@ -1622,6 +1434,8 @@ set_fatal_function (f)
fatal_function = f; fatal_function = f;
} }
/* Report a fatal error at the current line number. Allow a front end to
intercept the message. */
void void
fatal VPARAMS ((const char *msgid, ...)) fatal VPARAMS ((const char *msgid, ...))
{ {
...@@ -1629,15 +1443,21 @@ fatal VPARAMS ((const char *msgid, ...)) ...@@ -1629,15 +1443,21 @@ fatal VPARAMS ((const char *msgid, ...))
const char *msgid; const char *msgid;
#endif #endif
va_list ap; va_list ap;
va_list args_for_fatal_msg;
VA_START (ap, msgid); VA_START (ap, msgid);
#ifndef ANSI_PROTOTYPES #ifndef ANSI_PROTOTYPES
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
va_copy (args_for_fatal_msg, ap);
vfatal (msgid, ap); if (fatal_function != NULL)
(*fatal_function) (_(msgid), args_for_fatal_msg);
va_end (args_for_fatal_msg);
report_diagnostic (msgid, ap, input_filename, lineno, 0);
va_end (ap); va_end (ap);
exit (FATAL_EXIT_CODE);
} }
void void
...@@ -1686,7 +1506,7 @@ warning_with_file_and_line VPARAMS ((const char *file, int line, ...@@ -1686,7 +1506,7 @@ warning_with_file_and_line VPARAMS ((const char *file, int line,
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
v_warning_with_file_and_line (file, line, msgid, ap); report_diagnostic (msgid, ap, file, line, /* warn = */ 1);
va_end (ap); va_end (ap);
} }
...@@ -1726,7 +1546,7 @@ warning_for_asm VPARAMS ((rtx insn, const char *msgid, ...)) ...@@ -1726,7 +1546,7 @@ warning_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
v_warning_for_asm (insn, msgid, ap); diagnostic_for_asm (insn, msgid, ap, /* warn = */ 1);
va_end (ap); va_end (ap);
} }
...@@ -1744,7 +1564,7 @@ warning VPARAMS ((const char *msgid, ...)) ...@@ -1744,7 +1564,7 @@ warning VPARAMS ((const char *msgid, ...))
msgid = va_arg (ap, const char *); msgid = va_arg (ap, const char *);
#endif #endif
vwarning (msgid, ap); report_diagnostic (msgid, ap, input_filename, lineno, /* warn = */ 1);
va_end (ap); va_end (ap);
} }
...@@ -1753,6 +1573,7 @@ static void ...@@ -1753,6 +1573,7 @@ static void
finish_diagnostic () finish_diagnostic ()
{ {
output_to_stream (diagnostic_buffer, stderr); output_to_stream (diagnostic_buffer, stderr);
clear_diagnostic_info (diagnostic_buffer);
fputc ('\n', stderr); fputc ('\n', stderr);
fflush (stderr); fflush (stderr);
} }
...@@ -1765,8 +1586,9 @@ output_do_verbatim (buffer, msg, args) ...@@ -1765,8 +1586,9 @@ output_do_verbatim (buffer, msg, args)
const char *msg; const char *msg;
va_list args; va_list args;
{ {
output_state os = buffer->state; output_state os;
os = buffer->state;
output_prefix (buffer) = NULL; output_prefix (buffer) = NULL;
prefixing_policy (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER; prefixing_policy (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
output_buffer_text_cursor (buffer) = msg; output_buffer_text_cursor (buffer) = msg;
...@@ -1827,8 +1649,9 @@ report_diagnostic (msg, args, file, line, warn) ...@@ -1827,8 +1649,9 @@ report_diagnostic (msg, args, file, line, warn)
int line; int line;
int warn; int warn;
{ {
output_state os = diagnostic_buffer->state; output_state os;
os = diagnostic_buffer->state;
diagnostic_msg = msg; diagnostic_msg = msg;
diagnostic_args = &args; diagnostic_args = &args;
if (count_error (warn)) if (count_error (warn))
......
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