toplev.h (report_error_function): Remove.
* toplev.h (report_error_function): Remove. * diagnostic.h (location_t): New datatype. (text_info): Likewise. (diagnostic_info): Likewise. (output_prefix): New macro. (diagnostic_last_function_changed): Likewise. (diagnostic_set_last_function): Likewise. (diagnostic_last_module_changed): Likewise. (diagnostic_set_last_module): Likewise. (report_diagnostic): Now macro. (diagnostic_set_info): Declare. * diagnostic.c (report_problematic_module): Rename to diagnostic_repor_current_module. (set_diagnostic_context): Remove. (count_error): Rename to diagnostic_error_count. (error_function_changed): Remove. (record_last_error_function): Likewise. (error_module_changed): Likewise. (record_last_error_module): Likewise. (context_as_prefix): Rename to diagnostic_build_prefix. (flush_diagnostic_buffer): Rename to diagnostic_flush_buffer. (diagnostic_set_info): New function. * objc/objc-act.c: #include diagnostic.h (error_with_ivar): Adjust call to count_error. (warn_with_method): Likewise. * objc/Make-lang.in (objc-act.o): Depend on diagnostic.h cp/ 2002-06-04 Gabriel Dos Reis <gdr@codesourcery.com> * error.c (cp_diagnostic_starter): Adjust call. (maybe_print_instantiation_context): Change prototype to take a 'diagnostic_info *'. (print_instantiation_full_context): Likewise. (print_instantiation_partial_context): Likewise. (cp_diagnostic_starter): Likewise. (cp_diagnostic_finalizer): Likewise. (cp_print_error_function): Likewise. (cp_printer): Take a secondary parameter as a 'text_info *'. Remove output_state savings. Adjust calls. f/ 2002-06-04 Gabriel Dos Reis <gdr@codesourcery.com> * bad.c (ffebad_start_): Adjust call to count_error. * Make-lang.in (f/bad.o): Depend on diagnostic.h * bad.c: #include diagnostic.h From-SVN: r54291
This commit is contained in:
parent
304a3a85de
commit
47b69537e4
|
@ -1,3 +1,35 @@
|
|||
2002-06-05 Gabriel Dos Reis <gdr@codesourcery.com>
|
||||
|
||||
* toplev.h (report_error_function): Remove.
|
||||
|
||||
* diagnostic.h (location_t): New datatype.
|
||||
(text_info): Likewise.
|
||||
(diagnostic_info): Likewise.
|
||||
(output_prefix): New macro.
|
||||
(diagnostic_last_function_changed): Likewise.
|
||||
(diagnostic_set_last_function): Likewise.
|
||||
(diagnostic_last_module_changed): Likewise.
|
||||
(diagnostic_set_last_module): Likewise.
|
||||
(report_diagnostic): Now macro.
|
||||
(diagnostic_set_info): Declare.
|
||||
|
||||
* diagnostic.c (report_problematic_module): Rename to
|
||||
diagnostic_repor_current_module.
|
||||
(set_diagnostic_context): Remove.
|
||||
(count_error): Rename to diagnostic_error_count.
|
||||
(error_function_changed): Remove.
|
||||
(record_last_error_function): Likewise.
|
||||
(error_module_changed): Likewise.
|
||||
(record_last_error_module): Likewise.
|
||||
(context_as_prefix): Rename to diagnostic_build_prefix.
|
||||
(flush_diagnostic_buffer): Rename to diagnostic_flush_buffer.
|
||||
(diagnostic_set_info): New function.
|
||||
|
||||
* objc/objc-act.c: #include diagnostic.h
|
||||
(error_with_ivar): Adjust call to count_error.
|
||||
(warn_with_method): Likewise.
|
||||
* objc/Make-lang.in (objc-act.o): Depend on diagnostic.h
|
||||
|
||||
2002-06-05 Bob Wilson <bob.wilson@acm.org>
|
||||
|
||||
* config/xtensa/xtensa.c (xtensa_build_va_list): Use
|
||||
|
|
|
@ -32,13 +32,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
void
|
||||
pedwarn_c99 VPARAMS ((const char *msgid, ...))
|
||||
{
|
||||
diagnostic_context dc;
|
||||
|
||||
diagnostic_info diagnostic;
|
||||
VA_OPEN (ap, msgid);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
||||
set_diagnostic_context (&dc, msgid, &ap, input_filename, lineno,
|
||||
!flag_isoc99 || !flag_pedantic_errors);
|
||||
report_diagnostic (&dc);
|
||||
diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, lineno,
|
||||
flag_isoc99 ? pedantic_error_kind () : DK_WARNING);
|
||||
report_diagnostic (&diagnostic);
|
||||
VA_CLOSE (ap);
|
||||
}
|
||||
|
|
|
@ -1025,7 +1025,7 @@ check_function_format (status, attrs, params)
|
|||
static void
|
||||
status_warning VPARAMS ((int *status, const char *msgid, ...))
|
||||
{
|
||||
diagnostic_context dc;
|
||||
diagnostic_info diagnostic ;
|
||||
|
||||
VA_OPEN (ap, msgid);
|
||||
VA_FIXEDARG (ap, int *, status);
|
||||
|
@ -1036,9 +1036,9 @@ status_warning VPARAMS ((int *status, const char *msgid, ...))
|
|||
else
|
||||
{
|
||||
/* This duplicates the warning function behavior. */
|
||||
set_diagnostic_context
|
||||
(&dc, msgid, &ap, input_filename, lineno, /* warn = */ 1);
|
||||
report_diagnostic (&dc);
|
||||
diagnostic_set_info (&diagnostic, _(msgid), &ap, input_filename, lineno,
|
||||
DK_WARNING);
|
||||
report_diagnostic (&diagnostic);
|
||||
}
|
||||
|
||||
VA_CLOSE (ap);
|
||||
|
|
|
@ -35,7 +35,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
#include "ggc.h"
|
||||
#include "langhooks.h"
|
||||
|
||||
static int c_tree_printer PARAMS ((output_buffer *));
|
||||
static bool c_tree_printer PARAMS ((output_buffer *, text_info *));
|
||||
static tree inline_forbidden_p PARAMS ((tree *, int *, void *));
|
||||
static void expand_deferred_fns PARAMS ((void));
|
||||
static tree start_cdtor PARAMS ((int));
|
||||
|
@ -389,13 +389,14 @@ c_objc_common_finish_file ()
|
|||
by the C++ front-end.
|
||||
Please notice when called, the `%' part was already skipped by the
|
||||
diagnostic machinery. */
|
||||
static int
|
||||
c_tree_printer (buffer)
|
||||
static bool
|
||||
c_tree_printer (buffer, text)
|
||||
output_buffer *buffer;
|
||||
text_info *text;
|
||||
{
|
||||
tree t = va_arg (output_buffer_format_args (buffer), tree);
|
||||
tree t = va_arg (*text->args_ptr, tree);
|
||||
|
||||
switch (*output_buffer_text_cursor (buffer))
|
||||
switch (*text->format_spec)
|
||||
{
|
||||
case 'D':
|
||||
case 'F':
|
||||
|
@ -406,10 +407,10 @@ c_tree_printer (buffer)
|
|||
: "({anonymous})";
|
||||
output_add_string (buffer, n);
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
2002-06-04 Gabriel Dos Reis <gdr@codesourcery.com>
|
||||
|
||||
* error.c (cp_diagnostic_starter): Adjust call.
|
||||
(maybe_print_instantiation_context): Change prototype to take a
|
||||
'diagnostic_info *'.
|
||||
(print_instantiation_full_context): Likewise.
|
||||
(print_instantiation_partial_context): Likewise.
|
||||
(cp_diagnostic_starter): Likewise.
|
||||
(cp_diagnostic_finalizer): Likewise.
|
||||
(cp_print_error_function): Likewise.
|
||||
(cp_printer): Take a secondary parameter as a 'text_info *'.
|
||||
Remove output_state savings. Adjust calls.
|
||||
|
||||
2002-06-03 Geoffrey Keating <geoffk@redhat.com>
|
||||
|
||||
* pt.c (inline_parm_levels): Mark for GC.
|
||||
|
|
170
gcc/cp/error.c
170
gcc/cp/error.c
|
@ -105,18 +105,19 @@ static void dump_scope PARAMS ((tree, int));
|
|||
static void dump_template_parms PARAMS ((tree, int, int));
|
||||
|
||||
static const char *function_category PARAMS ((tree));
|
||||
static void maybe_print_instantiation_context PARAMS ((output_buffer *));
|
||||
static void print_instantiation_full_context PARAMS ((output_buffer *));
|
||||
static void print_instantiation_partial_context PARAMS ((output_buffer *, tree,
|
||||
static void maybe_print_instantiation_context PARAMS ((diagnostic_context *));
|
||||
static void print_instantiation_full_context PARAMS ((diagnostic_context *));
|
||||
static void print_instantiation_partial_context PARAMS ((diagnostic_context *,
|
||||
tree,
|
||||
const char *, int));
|
||||
static void cp_diagnostic_starter PARAMS ((output_buffer *,
|
||||
diagnostic_context *));
|
||||
static void cp_diagnostic_finalizer PARAMS ((output_buffer *,
|
||||
diagnostic_context *));
|
||||
static void cp_print_error_function PARAMS ((output_buffer *,
|
||||
diagnostic_context *));
|
||||
static void cp_diagnostic_starter PARAMS ((diagnostic_context *,
|
||||
diagnostic_info *));
|
||||
static void cp_diagnostic_finalizer PARAMS ((diagnostic_context *,
|
||||
diagnostic_info *));
|
||||
static void cp_print_error_function PARAMS ((diagnostic_context *,
|
||||
diagnostic_info *));
|
||||
|
||||
static int cp_printer PARAMS ((output_buffer *));
|
||||
static bool cp_printer PARAMS ((output_buffer *, text_info *));
|
||||
static void print_non_consecutive_character PARAMS ((output_buffer *, int));
|
||||
static void print_integer PARAMS ((output_buffer *, HOST_WIDE_INT));
|
||||
static tree locate_error PARAMS ((const char *, va_list));
|
||||
|
@ -2379,65 +2380,57 @@ cxx_print_error_function (context, file)
|
|||
diagnostic_context *context;
|
||||
const char *file;
|
||||
{
|
||||
output_state os;
|
||||
|
||||
lhd_print_error_function (context, file);
|
||||
os = diagnostic_state (context);
|
||||
output_set_prefix ((output_buffer *)context, file);
|
||||
maybe_print_instantiation_context ((output_buffer *)context);
|
||||
diagnostic_state (context) = os;
|
||||
output_set_prefix (&context->buffer, file);
|
||||
maybe_print_instantiation_context (context);
|
||||
}
|
||||
|
||||
static void
|
||||
cp_diagnostic_starter (buffer, dc)
|
||||
output_buffer *buffer;
|
||||
diagnostic_context *dc;
|
||||
cp_diagnostic_starter (context, diagnostic)
|
||||
diagnostic_context *context;
|
||||
diagnostic_info *diagnostic;
|
||||
{
|
||||
report_problematic_module (buffer);
|
||||
cp_print_error_function (buffer, dc);
|
||||
maybe_print_instantiation_context (buffer);
|
||||
output_set_prefix (buffer,
|
||||
context_as_prefix (diagnostic_file_location (dc),
|
||||
diagnostic_line_location (dc),
|
||||
diagnostic_is_warning (dc)));
|
||||
diagnostic_report_current_module (context);
|
||||
cp_print_error_function (context, diagnostic);
|
||||
maybe_print_instantiation_context (context);
|
||||
output_set_prefix (&context->buffer, diagnostic_build_prefix (diagnostic));
|
||||
}
|
||||
|
||||
static void
|
||||
cp_diagnostic_finalizer (buffer, dc)
|
||||
output_buffer *buffer;
|
||||
diagnostic_context *dc __attribute__ ((__unused__));
|
||||
cp_diagnostic_finalizer (context, diagnostic)
|
||||
diagnostic_context *context;
|
||||
diagnostic_info *diagnostic __attribute__((unused));
|
||||
{
|
||||
output_destroy_prefix (buffer);
|
||||
output_destroy_prefix (&context->buffer);
|
||||
}
|
||||
|
||||
/* Print current function onto BUFFER, in the process of reporting
|
||||
a diagnostic message. Called from cp_diagnostic_starter. */
|
||||
static void
|
||||
cp_print_error_function (buffer, dc)
|
||||
output_buffer *buffer;
|
||||
diagnostic_context *dc;
|
||||
cp_print_error_function (context, diagnostic)
|
||||
diagnostic_context *context;
|
||||
diagnostic_info *diagnostic;
|
||||
{
|
||||
if (error_function_changed ())
|
||||
if (diagnostic_last_function_changed (context))
|
||||
{
|
||||
char *prefix = diagnostic_file_location (dc)
|
||||
? file_name_as_prefix (diagnostic_file_location (dc))
|
||||
const char *old_prefix = output_prefix (&context->buffer);
|
||||
char *new_prefix = diagnostic->location.file
|
||||
? file_name_as_prefix (diagnostic->location.file)
|
||||
: NULL;
|
||||
output_state os;
|
||||
|
||||
os = output_buffer_state (buffer);
|
||||
output_set_prefix (buffer, prefix);
|
||||
output_set_prefix (&context->buffer, new_prefix);
|
||||
|
||||
if (current_function_decl == NULL)
|
||||
output_add_string (buffer, "At global scope:");
|
||||
output_add_string (&context->buffer, "At global scope:");
|
||||
else
|
||||
output_printf
|
||||
(buffer, "In %s `%s':", function_category (current_function_decl),
|
||||
cxx_printable_name (current_function_decl, 2));
|
||||
output_add_newline (buffer);
|
||||
output_printf (&context->buffer, "In %s `%s':",
|
||||
function_category (current_function_decl),
|
||||
cxx_printable_name (current_function_decl, 2));
|
||||
output_add_newline (&context->buffer);
|
||||
|
||||
record_last_error_function ();
|
||||
output_destroy_prefix (buffer);
|
||||
output_buffer_state (buffer) = os;
|
||||
diagnostic_set_last_function (context);
|
||||
output_destroy_prefix (&context->buffer);
|
||||
context->buffer.state.prefix = old_prefix;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2466,8 +2459,8 @@ function_category (fn)
|
|||
/* Report the full context of a current template instantiation,
|
||||
onto BUFFER. */
|
||||
static void
|
||||
print_instantiation_full_context (buffer)
|
||||
output_buffer *buffer;
|
||||
print_instantiation_full_context (context)
|
||||
diagnostic_context *context;
|
||||
{
|
||||
tree p = current_instantiation ();
|
||||
int line = lineno;
|
||||
|
@ -2486,7 +2479,8 @@ print_instantiation_full_context (buffer)
|
|||
if (current_function_decl == TINST_DECL (p))
|
||||
/* Avoid redundancy with the the "In function" line. */;
|
||||
else
|
||||
output_verbatim (buffer, "%s: In instantiation of `%s':\n", file,
|
||||
output_verbatim (&context->buffer,
|
||||
"%s: In instantiation of `%s':\n", file,
|
||||
decl_as_string (TINST_DECL (p),
|
||||
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
|
||||
|
||||
|
@ -2496,13 +2490,13 @@ print_instantiation_full_context (buffer)
|
|||
}
|
||||
}
|
||||
|
||||
print_instantiation_partial_context (buffer, p, file, line);
|
||||
print_instantiation_partial_context (context, p, file, line);
|
||||
}
|
||||
|
||||
/* Same as above but less verbose. */
|
||||
static void
|
||||
print_instantiation_partial_context (buffer, t, file, line)
|
||||
output_buffer *buffer;
|
||||
print_instantiation_partial_context (context, t, file, line)
|
||||
diagnostic_context *context;
|
||||
tree t;
|
||||
const char *file;
|
||||
int line;
|
||||
|
@ -2510,24 +2504,24 @@ print_instantiation_partial_context (buffer, t, file, line)
|
|||
for (; t; t = TREE_CHAIN (t))
|
||||
{
|
||||
output_verbatim
|
||||
(buffer, "%s:%d: instantiated from `%s'\n", file, line,
|
||||
(&context->buffer, "%s:%d: instantiated from `%s'\n", file, line,
|
||||
decl_as_string (TINST_DECL (t), TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
|
||||
line = TINST_LINE (t);
|
||||
file = TINST_FILE (t);
|
||||
}
|
||||
output_verbatim (buffer, "%s:%d: instantiated from here\n", file, line);
|
||||
output_verbatim (&context->buffer, "%s:%d: instantiated from here\n", file, line);
|
||||
}
|
||||
|
||||
/* Called from cp_thing to print the template context for an error. */
|
||||
static void
|
||||
maybe_print_instantiation_context (buffer)
|
||||
output_buffer *buffer;
|
||||
maybe_print_instantiation_context (context)
|
||||
diagnostic_context *context;
|
||||
{
|
||||
if (!problematic_instantiation_changed () || current_instantiation () == 0)
|
||||
return;
|
||||
|
||||
record_last_problematic_instantiation ();
|
||||
print_instantiation_full_context (buffer);
|
||||
print_instantiation_full_context (context);
|
||||
}
|
||||
|
||||
/* Report the bare minimum context of a template instantiation. */
|
||||
|
@ -2535,8 +2529,8 @@ void
|
|||
print_instantiation_context ()
|
||||
{
|
||||
print_instantiation_partial_context
|
||||
(diagnostic_buffer, current_instantiation (), input_filename, lineno);
|
||||
flush_diagnostic_buffer ();
|
||||
(global_dc, current_instantiation (), input_filename, lineno);
|
||||
diagnostic_flush_buffer (global_dc);
|
||||
}
|
||||
|
||||
/* Called from output_format -- during diagnostic message processing --
|
||||
|
@ -2552,26 +2546,27 @@ print_instantiation_context ()
|
|||
%Q assignment operator.
|
||||
%T type.
|
||||
%V cv-qualifier. */
|
||||
static int
|
||||
cp_printer (buffer)
|
||||
static bool
|
||||
cp_printer (buffer, text)
|
||||
output_buffer *buffer;
|
||||
text_info *text;
|
||||
{
|
||||
int verbose = 0;
|
||||
const char *result;
|
||||
#define next_tree va_arg (output_buffer_format_args (buffer), tree)
|
||||
#define next_tcode va_arg (output_buffer_format_args (buffer), enum tree_code)
|
||||
#define next_lang va_arg (output_buffer_format_args (buffer), enum languages)
|
||||
#define next_int va_arg (output_buffer_format_args (buffer), int)
|
||||
#define next_tree va_arg (*text->args_ptr, tree)
|
||||
#define next_tcode va_arg (*text->args_ptr, enum tree_code)
|
||||
#define next_lang va_arg (*text->args_ptr, enum languages)
|
||||
#define next_int va_arg (*text->args_ptr, int)
|
||||
|
||||
if (*output_buffer_text_cursor (buffer) == '+')
|
||||
++output_buffer_text_cursor (buffer);
|
||||
if (*output_buffer_text_cursor (buffer) == '#')
|
||||
if (*text->format_spec == '+')
|
||||
++text->format_spec;
|
||||
if (*text->format_spec == '#')
|
||||
{
|
||||
verbose = 1;
|
||||
++output_buffer_text_cursor (buffer);
|
||||
++text->format_spec;
|
||||
}
|
||||
|
||||
switch (*output_buffer_text_cursor (buffer))
|
||||
switch (*text->format_spec)
|
||||
{
|
||||
case 'A': result = args_to_string (next_tree, verbose); break;
|
||||
case 'C': result = code_to_string (next_tcode, verbose); break;
|
||||
|
@ -2586,11 +2581,11 @@ cp_printer (buffer)
|
|||
case 'V': result = cv_to_string (next_tree, verbose); break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
output_add_string (buffer, result);
|
||||
return 1;
|
||||
return true;
|
||||
#undef next_tree
|
||||
#undef next_tcode
|
||||
#undef next_lang
|
||||
|
@ -2684,7 +2679,7 @@ void
|
|||
cp_error_at VPARAMS ((const char *msgid, ...))
|
||||
{
|
||||
tree here;
|
||||
diagnostic_context dc;
|
||||
diagnostic_info diagnostic;
|
||||
|
||||
VA_OPEN (ap, msgid);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
@ -2694,10 +2689,9 @@ cp_error_at VPARAMS ((const char *msgid, ...))
|
|||
VA_OPEN (ap, msgid);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
||||
set_diagnostic_context (&dc, msgid, &ap,
|
||||
cp_file_of (here),
|
||||
cp_line_of (here), /* warning = */ 0);
|
||||
report_diagnostic (&dc);
|
||||
diagnostic_set_info (&diagnostic, msgid, &ap,
|
||||
cp_file_of (here), cp_line_of (here), DK_WARNING);
|
||||
report_diagnostic (&diagnostic);
|
||||
VA_CLOSE (ap);
|
||||
}
|
||||
|
||||
|
@ -2705,7 +2699,7 @@ void
|
|||
cp_warning_at VPARAMS ((const char *msgid, ...))
|
||||
{
|
||||
tree here;
|
||||
diagnostic_context dc;
|
||||
diagnostic_info diagnostic;
|
||||
|
||||
VA_OPEN (ap, msgid);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
@ -2715,10 +2709,9 @@ cp_warning_at VPARAMS ((const char *msgid, ...))
|
|||
VA_OPEN (ap, msgid);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
||||
set_diagnostic_context (&dc, msgid, &ap,
|
||||
cp_file_of (here),
|
||||
cp_line_of (here), /* warning = */ 1);
|
||||
report_diagnostic (&dc);
|
||||
diagnostic_set_info (&diagnostic, msgid, &ap,
|
||||
cp_file_of (here), cp_line_of (here), DK_WARNING);
|
||||
report_diagnostic (&diagnostic);
|
||||
VA_CLOSE (ap);
|
||||
}
|
||||
|
||||
|
@ -2726,7 +2719,7 @@ void
|
|||
cp_pedwarn_at VPARAMS ((const char *msgid, ...))
|
||||
{
|
||||
tree here;
|
||||
diagnostic_context dc;
|
||||
diagnostic_info diagnostic;
|
||||
|
||||
VA_OPEN (ap, msgid);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
@ -2736,10 +2729,9 @@ cp_pedwarn_at VPARAMS ((const char *msgid, ...))
|
|||
VA_OPEN (ap, msgid);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
||||
set_diagnostic_context (&dc, msgid, &ap,
|
||||
cp_file_of (here),
|
||||
cp_line_of (here),
|
||||
/* warning = */ !flag_pedantic_errors);
|
||||
report_diagnostic (&dc);
|
||||
diagnostic_set_info (&diagnostic, msgid, &ap,
|
||||
cp_file_of (here), cp_line_of (here),
|
||||
pedantic_error_kind());
|
||||
report_diagnostic (&diagnostic);
|
||||
VA_CLOSE (ap);
|
||||
}
|
||||
|
|
764
gcc/diagnostic.c
764
gcc/diagnostic.c
File diff suppressed because it is too large
Load Diff
191
gcc/diagnostic.h
191
gcc/diagnostic.h
|
@ -24,13 +24,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
|
||||
#include "obstack.h"
|
||||
|
||||
/* Forward declarations. */
|
||||
typedef struct output_buffer output_buffer;
|
||||
typedef struct diagnostic_context diagnostic_context;
|
||||
typedef void (*diagnostic_starter_fn) PARAMS ((output_buffer *,
|
||||
diagnostic_context *));
|
||||
typedef diagnostic_starter_fn diagnostic_finalizer_fn;
|
||||
/* The type of a text to be formatted according a format specification
|
||||
along with a list of things. */
|
||||
typedef struct
|
||||
{
|
||||
const char *format_spec;
|
||||
va_list *args_ptr;
|
||||
} text_info;
|
||||
|
||||
/* Contants used to discreminate diagnostics. */
|
||||
typedef enum
|
||||
{
|
||||
#define DEFINE_DIAGNOSTIC_KIND(K, M) K,
|
||||
|
@ -39,6 +41,27 @@ typedef enum
|
|||
DK_LAST_DIAGNOSTIC_KIND
|
||||
} diagnostic_t;
|
||||
|
||||
/* The data structure used to record the location of a diagnostic. */
|
||||
typedef struct
|
||||
{
|
||||
/* The name of the source file involved in the diagnostic. */
|
||||
const char *file;
|
||||
|
||||
/* The line-location in the source file. */
|
||||
int line;
|
||||
} location_t;
|
||||
|
||||
/* A diagnostic is described by the MESSAGE to send, the FILE and LINE of
|
||||
its context and its KIND (ice, error, warning, note, ...) See complete
|
||||
list in diagnostic.def. */
|
||||
typedef struct
|
||||
{
|
||||
text_info message;
|
||||
location_t location;
|
||||
/* The kind of diagnostic it is about. */
|
||||
diagnostic_t kind;
|
||||
} diagnostic_info;
|
||||
|
||||
#define pedantic_error_kind() (flag_pedantic_errors ? DK_ERROR : DK_WARNING)
|
||||
|
||||
/* How often diagnostics are prefixed by their locations:
|
||||
|
@ -53,11 +76,6 @@ typedef enum
|
|||
DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE = 0x2
|
||||
} diagnostic_prefixing_rule_t;
|
||||
|
||||
/* The type of front-end specific hook that formats trees into an
|
||||
output_buffer. A language specific printer returns a truth value if
|
||||
everything goes well. */
|
||||
typedef int (*printer_fn) PARAMS ((output_buffer *));
|
||||
|
||||
/* This data structure encapsulates an output_buffer's state. */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -83,15 +101,14 @@ typedef struct
|
|||
|
||||
/* Current prefixing rule. */
|
||||
diagnostic_prefixing_rule_t prefixing_rule;
|
||||
|
||||
/* The current char to output. Updated by front-end (*format_map) when
|
||||
it is called to report front-end printer for a specified format. */
|
||||
const char *cursor;
|
||||
|
||||
/* A pointer to the variable argument-list for formatting. */
|
||||
va_list *format_args;
|
||||
} output_state;
|
||||
|
||||
/* The type of a hook that formats client-specific data (trees mostly) into
|
||||
an output_buffer. A client-supplied formatter returns true if everything
|
||||
goes well. */
|
||||
typedef struct output_buffer output_buffer;
|
||||
typedef bool (*printer_fn) PARAMS ((output_buffer *, text_info *));
|
||||
|
||||
/* The output buffer datatype. This is best seen as an abstract datatype
|
||||
whose fields should not be accessed directly by clients. */
|
||||
struct output_buffer
|
||||
|
@ -112,35 +129,23 @@ struct output_buffer
|
|||
floating-point value. */
|
||||
char digit_buffer[128];
|
||||
|
||||
/* If non-NULL, this function formats data in the BUFFER. When called,
|
||||
output_buffer_text_cursor (BUFFER) points to a format code.
|
||||
FORMAT_DECODER should call output_add_string (and related functions)
|
||||
to add data to the BUFFER. FORMAT_DECODER can read arguments from
|
||||
output_buffer_format_args (BUFFER) using VA_ARG. If the BUFFER needs
|
||||
additional characters from the format string, it should advance
|
||||
the output_buffer_text_cursor (BUFFER) as it goes. When FORMAT_DECODER
|
||||
returns, output_buffer_text_cursor (BUFFER) should point to the last
|
||||
character processed. */
|
||||
|
||||
/* If non-NULL, this function formats a TEXT into the BUFFER. When called,
|
||||
TEXT->format_spec points to a format code. FORMAT_DECODER should call
|
||||
output_add_string (and related functions) to add data to the BUFFER.
|
||||
FORMAT_DECODER can read arguments from *TEXT->args_pts using VA_ARG.
|
||||
If the BUFFER needs additional characters from the format string, it
|
||||
should advance the TEXT->format_spec as it goes. When FORMAT_DECODER
|
||||
returns, TEXT->format_spec should point to the last character processed.
|
||||
*/
|
||||
printer_fn format_decoder;
|
||||
};
|
||||
} ;
|
||||
|
||||
/* Current state of an output_buffer. */
|
||||
#define output_buffer_state(BUFFER) (BUFFER)->state
|
||||
#define output_prefix(BUFFER) (BUFFER)->state.prefix
|
||||
|
||||
/* 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
|
||||
|
||||
/* 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
|
||||
|
||||
|
@ -161,6 +166,15 @@ struct output_buffer
|
|||
Zero means don't wrap lines. */
|
||||
#define output_line_cutoff(BUFFER) (BUFFER)->state.ideal_maximum_length
|
||||
|
||||
/* True if BUFFER is in line-wrapping mode. */
|
||||
#define output_is_line_wrapping(BUFFER) (output_line_cutoff (BUFFER) > 0)
|
||||
|
||||
/* Forward declarations. */
|
||||
typedef struct diagnostic_context diagnostic_context;
|
||||
typedef void (*diagnostic_starter_fn) PARAMS ((diagnostic_context *,
|
||||
diagnostic_info *));
|
||||
typedef diagnostic_starter_fn diagnostic_finalizer_fn;
|
||||
|
||||
/* This data structure bundles altogether any information relevant to
|
||||
the context of a diagnostic message. */
|
||||
struct diagnostic_context
|
||||
|
@ -170,22 +184,6 @@ struct diagnostic_context
|
|||
output_buffer. */
|
||||
output_buffer buffer;
|
||||
|
||||
/* The diagnostic message to output. */
|
||||
const char *message;
|
||||
|
||||
/* A pointer to a variable list of the arguments necessary for the
|
||||
purpose of message formatting. */
|
||||
va_list *args_ptr;
|
||||
|
||||
/* The name of the source file involved in the diagnostic. */
|
||||
const char *file;
|
||||
|
||||
/* The line-location in the source file. */
|
||||
int line;
|
||||
|
||||
/* Is this message a warning? */
|
||||
int warn;
|
||||
|
||||
/* The number of times we have issued diagnostics. */
|
||||
int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];
|
||||
|
||||
|
@ -196,34 +194,28 @@ struct diagnostic_context
|
|||
from "/home/gdr/src/nifty_printer.h:56:
|
||||
...
|
||||
*/
|
||||
void (*begin_diagnostic) PARAMS ((output_buffer *, diagnostic_context *));
|
||||
diagnostic_starter_fn begin_diagnostic;
|
||||
|
||||
/* This function is called after the diagnostic message is printed. */
|
||||
void (*end_diagnostic) PARAMS ((output_buffer *, diagnostic_context *));
|
||||
diagnostic_finalizer_fn end_diagnostic;
|
||||
|
||||
/* Client hook to report an internal error. */
|
||||
void (*internal_error) PARAMS ((const char *, va_list *));
|
||||
|
||||
/* Function of last diagnostic message; more generally, function such that
|
||||
if next diagnostic message is in it then we don't have to mention the
|
||||
function name. */
|
||||
tree last_function;
|
||||
|
||||
/* Used to detect when input_file_stack has changed since last described. */
|
||||
int last_module;
|
||||
|
||||
int lock;
|
||||
|
||||
/* Hook for front-end extensions. */
|
||||
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
|
||||
|
||||
|
@ -244,10 +236,25 @@ struct diagnostic_context
|
|||
Zero means don't wrap lines. */
|
||||
#define diagnostic_line_cutoff(DC) output_line_cutoff (&(DC)->buffer)
|
||||
|
||||
/* Same as output_buffer_state, but works on 'diagnostic_context *'. */
|
||||
#define diagnostic_state(DC) output_buffer_state (&(DC)->buffer)
|
||||
/* True if the last function in which a diagnostic was reported is
|
||||
different from the current one. */
|
||||
#define diagnostic_last_function_changed(DC) \
|
||||
((DC)->last_function != current_function_decl)
|
||||
|
||||
#define diagnostic_buffer (&global_dc->buffer)
|
||||
/* Remember the current function as being the last one in which we report
|
||||
a diagnostic. */
|
||||
#define diagnostic_set_last_function(DC) \
|
||||
(DC)->last_function = current_function_decl
|
||||
|
||||
/* True if the last module or file in which a diagnostic was reported is
|
||||
different from the current one. */
|
||||
#define diagnostic_last_module_changed(DC) \
|
||||
((DC)->last_module != input_file_stack_tick)
|
||||
|
||||
/* Remember the current module or file as being the last one in which we
|
||||
report a diagnostic. */
|
||||
#define diagnostic_set_last_module(DC) \
|
||||
(DC)->last_module = input_file_stack_tick
|
||||
|
||||
/* This diagnostic_context is used by front-ends that directly output
|
||||
diagnostic messages without going through `error', `warning',
|
||||
|
@ -270,18 +277,27 @@ extern diagnostic_context *global_dc;
|
|||
(!inhibit_warnings \
|
||||
&& !(in_system_header && !warn_system_headers))
|
||||
|
||||
#define report_diagnostic(D) diagnostic_report_diagnostic (global_dc, D)
|
||||
|
||||
/* Prototypes */
|
||||
extern void set_diagnostic_context PARAMS ((diagnostic_context *,
|
||||
const char *, va_list *,
|
||||
const char *, int, int));
|
||||
extern void report_diagnostic PARAMS ((diagnostic_context *));
|
||||
/* Dignostic related functions. */
|
||||
extern void diagnostic_initialize PARAMS ((diagnostic_context *));
|
||||
extern void diagnostic_report_current_module PARAMS ((diagnostic_context *));
|
||||
extern void diagnostic_report_current_function PARAMS ((diagnostic_context *));
|
||||
extern void diagnostic_flush_buffer PARAMS ((diagnostic_context *));
|
||||
extern bool diagnostic_count_error PARAMS ((diagnostic_context *,
|
||||
diagnostic_t));
|
||||
extern void diagnostic_report_diagnostic PARAMS ((diagnostic_context *,
|
||||
diagnostic_info *));
|
||||
extern void diagnostic_set_info PARAMS ((diagnostic_info *,
|
||||
const char *, va_list *,
|
||||
const char *, int,
|
||||
diagnostic_t));
|
||||
extern char *diagnostic_build_prefix PARAMS ((diagnostic_info *));
|
||||
|
||||
/* Pure text formatting support functions. */
|
||||
extern void init_output_buffer PARAMS ((output_buffer *,
|
||||
const char *, int));
|
||||
extern void flush_diagnostic_buffer PARAMS ((void));
|
||||
extern void output_clear PARAMS ((output_buffer *));
|
||||
extern const char *output_get_prefix PARAMS ((const output_buffer *));
|
||||
extern const char *output_last_position PARAMS ((const output_buffer *));
|
||||
extern void output_set_prefix PARAMS ((output_buffer *,
|
||||
const char *));
|
||||
|
@ -301,17 +317,10 @@ extern const char *output_finalize_message PARAMS ((output_buffer *));
|
|||
extern void output_clear_message_text PARAMS ((output_buffer *));
|
||||
extern void output_printf PARAMS ((output_buffer *, const char *,
|
||||
...)) ATTRIBUTE_PRINTF_2;
|
||||
extern int output_is_line_wrapping PARAMS ((output_buffer *));
|
||||
extern void output_verbatim PARAMS ((output_buffer *, const char *,
|
||||
...)) ATTRIBUTE_PRINTF_2;
|
||||
extern void verbatim PARAMS ((const char *, ...))
|
||||
ATTRIBUTE_PRINTF_1;
|
||||
extern char *context_as_prefix PARAMS ((const char *, int, int));
|
||||
extern char *file_name_as_prefix PARAMS ((const char *));
|
||||
extern int error_module_changed PARAMS ((void));
|
||||
extern void record_last_error_module PARAMS ((void));
|
||||
extern int error_function_changed PARAMS ((void));
|
||||
extern void record_last_error_function PARAMS ((void));
|
||||
extern void report_problematic_module PARAMS ((output_buffer *));
|
||||
|
||||
#endif /* ! GCC_DIAGNOSTIC_H */
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2002-06-04 Gabriel Dos Reis <gdr@codesourcery.com>
|
||||
|
||||
* bad.c (ffebad_start_): Adjust call to count_error.
|
||||
* Make-lang.in (f/bad.o): Depend on diagnostic.h
|
||||
* bad.c: #include diagnostic.h
|
||||
|
||||
2002-06-03 Geoffrey Keating <geoffk@redhat.com>
|
||||
|
||||
* Make-lang.in (f/com.o): Depend on debug.h.
|
||||
|
|
|
@ -352,7 +352,8 @@ f/bad.o: f/bad.c f/proj.h $(CONFIG_H) $(SYSTEM_H) f/bad.h f/bad.def f/where.h \
|
|||
glimits.h f/top.h f/malloc.h flags.h f/com.h f/com-rt.def $(TREE_H) f/bld.h \
|
||||
f/bld-op.def f/bit.h f/info.h f/info-b.def f/info-k.def f/info-w.def \
|
||||
f/target.h f/lex.h f/type.h f/intrin.h f/intrin.def f/lab.h f/symbol.h \
|
||||
f/symbol.def f/equiv.h f/storag.h f/global.h f/name.h toplev.h intl.h
|
||||
f/symbol.def f/equiv.h f/storag.h f/global.h f/name.h toplev.h intl.h \
|
||||
diagnostic.h
|
||||
f/bit.o: f/bit.c f/proj.h $(CONFIG_H) $(SYSTEM_H) glimits.h f/bit.h \
|
||||
f/malloc.h
|
||||
f/bld.o: f/bld.c f/proj.h $(CONFIG_H) $(SYSTEM_H) f/bld.h f/bld-op.def f/bit.h \
|
||||
|
|
|
@ -43,6 +43,7 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
#include "toplev.h"
|
||||
#include "where.h"
|
||||
#include "intl.h"
|
||||
#include "diagnostic.h"
|
||||
|
||||
/* Externals defined here. */
|
||||
|
||||
|
@ -202,7 +203,7 @@ ffebad_start_ (bool lex_override, ffebad errnum, ffebadSeverity sev,
|
|||
if ((ffebad_severity_ != FFEBAD_severityPEDANTIC)
|
||||
|| !flag_pedantic_errors)
|
||||
{
|
||||
if (count_error (1) == 0)
|
||||
if (!diagnostic_count_error (global_dc, DK_WARNING))
|
||||
{ /* User wants no warnings. */
|
||||
ffebad_is_temp_inhibited_ = TRUE;
|
||||
return FALSE;
|
||||
|
@ -214,7 +215,7 @@ ffebad_start_ (bool lex_override, ffebad errnum, ffebadSeverity sev,
|
|||
case FFEBAD_severityWEIRD:
|
||||
case FFEBAD_severitySEVERE:
|
||||
case FFEBAD_severityDISASTER:
|
||||
count_error (0);
|
||||
diagnostic_count_error (global_dc, DK_ERROR);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -420,7 +421,7 @@ ffebad_finish ()
|
|||
{
|
||||
if (bi != 0)
|
||||
fputc ('\n', stderr);
|
||||
report_error_function (fn);
|
||||
diagnostic_report_current_function (global_dc);
|
||||
fprintf (stderr,
|
||||
/* the trailing space on the <file>:<line>: line
|
||||
fools emacs19 compilation mode into finding the
|
||||
|
|
|
@ -90,7 +90,7 @@ $(srcdir)/objc/objc-parse.y: $(srcdir)/c-parse.in
|
|||
|
||||
objc-act.o : $(srcdir)/objc/objc-act.c \
|
||||
$(CONFIG_H) $(TREE_H) $(RTL_H) $(SYSTEM_H) $(EXPR_H) $(TARGET_H) \
|
||||
$(C_COMMON_H) $(srcdir)/c-tree.h \
|
||||
$(C_COMMON_H) $(srcdir)/c-tree.h $(srcdir)/diagnostic.h \
|
||||
$(srcdir)/toplev.h $(srcdir)/flags.h $(srcdir)/objc/objc-act.h \
|
||||
$(srcdir)/input.h $(srcdir)/function.h $(srcdir)/output.h $(srcdir)/debug.h \
|
||||
$(srcdir)/langhooks.h $(LANGHOOKS_DEF_H) gtype-objc.h
|
||||
|
|
|
@ -56,6 +56,7 @@ Boston, MA 02111-1307, USA. */
|
|||
#include "ggc.h"
|
||||
#include "debug.h"
|
||||
#include "target.h"
|
||||
#include "diagnostic.h"
|
||||
|
||||
/* This is the default way of generating a method name. */
|
||||
/* I am not sure it is really correct.
|
||||
|
@ -3415,9 +3416,9 @@ error_with_ivar (message, decl, rawdecl)
|
|||
tree decl;
|
||||
tree rawdecl;
|
||||
{
|
||||
count_error (0);
|
||||
diagnostic_count_error (global_dc, DK_ERROR);
|
||||
|
||||
report_error_function (DECL_SOURCE_FILE (decl));
|
||||
diagnostic_report_current_function (global_dc);
|
||||
|
||||
error_with_file_and_line (DECL_SOURCE_FILE (decl),
|
||||
DECL_SOURCE_LINE (decl),
|
||||
|
@ -6894,10 +6895,10 @@ warn_with_method (message, mtype, method)
|
|||
int mtype;
|
||||
tree method;
|
||||
{
|
||||
if (count_error (1) == 0)
|
||||
if (!diagnostic_count_error (global_dc, DK_WARNING))
|
||||
return;
|
||||
|
||||
report_error_function (DECL_SOURCE_FILE (method));
|
||||
diagnostic_report_current_function (global_dc);
|
||||
|
||||
/* Add a readable method name to the warning. */
|
||||
warning_with_file_and_line (DECL_SOURCE_FILE (method),
|
||||
|
|
|
@ -32,7 +32,8 @@ Boston, MA 02111-1307, USA. */
|
|||
#include "diagnostic.h"
|
||||
|
||||
static void file_and_line_for_asm PARAMS ((rtx, const char **, int *));
|
||||
static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *, int));
|
||||
static void diagnostic_for_asm PARAMS ((rtx, const char *, va_list *,
|
||||
diagnostic_t));
|
||||
|
||||
/* Figure file and line of the given INSN. */
|
||||
static void
|
||||
|
@ -74,18 +75,18 @@ file_and_line_for_asm (insn, pfile, pline)
|
|||
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
|
||||
diagnostic_for_asm (insn, msg, args_ptr, warn)
|
||||
diagnostic_for_asm (insn, msg, args_ptr, kind)
|
||||
rtx insn;
|
||||
const char *msg;
|
||||
va_list *args_ptr;
|
||||
int warn;
|
||||
diagnostic_t kind;
|
||||
{
|
||||
diagnostic_context dc;
|
||||
diagnostic_info diagnostic;
|
||||
|
||||
set_diagnostic_context (&dc, msg, args_ptr, NULL, 0, warn);
|
||||
file_and_line_for_asm (insn, &diagnostic_file_location (&dc),
|
||||
&diagnostic_line_location (&dc));
|
||||
report_diagnostic (&dc);
|
||||
diagnostic_set_info (&diagnostic, msg, args_ptr, NULL, 0, kind);
|
||||
file_and_line_for_asm (insn, &diagnostic.location.file,
|
||||
&diagnostic.location.line);
|
||||
report_diagnostic (&diagnostic);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -95,7 +96,7 @@ error_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
|
|||
VA_FIXEDARG (ap, rtx, insn);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
||||
diagnostic_for_asm (insn, msgid, &ap, /* warn = */ 0);
|
||||
diagnostic_for_asm (insn, msgid, &ap, DK_ERROR);
|
||||
VA_CLOSE (ap);
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,7 @@ warning_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
|
|||
VA_FIXEDARG (ap, rtx, insn);
|
||||
VA_FIXEDARG (ap, const char *, msgid);
|
||||
|
||||
diagnostic_for_asm (insn, msgid, &ap, /* warn = */ 1);
|
||||
diagnostic_for_asm (insn, msgid, &ap, DK_WARNING);
|
||||
VA_CLOSE (ap);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
extern int toplev_main PARAMS ((int, char **));
|
||||
extern int read_integral_parameter PARAMS ((const char *, const char *,
|
||||
const int));
|
||||
extern int count_error PARAMS ((int));
|
||||
extern void strip_off_ending PARAMS ((char *, int));
|
||||
extern void print_time PARAMS ((const char *, long));
|
||||
extern const char *trim_filename PARAMS ((const char *));
|
||||
|
@ -67,7 +66,6 @@ extern void warning_with_file_and_line PARAMS ((const char *, int,
|
|||
extern void error_with_file_and_line PARAMS ((const char *, int,
|
||||
const char *, ...));
|
||||
extern void sorry PARAMS ((const char *, ...));
|
||||
extern void report_error_function PARAMS ((const char *));
|
||||
|
||||
extern void rest_of_decl_compilation PARAMS ((union tree_node *,
|
||||
const char *, int, int));
|
||||
|
|
Loading…
Reference in New Issue