/* Various declarations for language-independent diagnostics subroutines.
- Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
This file is part of GCC.
#define GCC_DIAGNOSTIC_H
#include "obstack.h"
+#include "input.h"
/* The type of a text to be formatted according a format specification
along with a list of things. */
{
const char *format_spec;
va_list *args_ptr;
+ int err_no; /* for %m */
} text_info;
-/* Contants used to discreminate diagnostics. */
+/* Contants used to discriminate diagnostics. */
typedef enum
{
#define DEFINE_DIAGNOSTIC_KIND(K, M) K,
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. */
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 *));
+typedef bool (*printer_fn) (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. */
/* True if BUFFER is in line-wrapping mode. */
#define output_is_line_wrapping(BUFFER) (output_line_cutoff (BUFFER) > 0)
+#define output_formatted_scalar(BUFFER, FORMAT, SCALAR) \
+ do \
+ { \
+ sprintf ((BUFFER)->digit_buffer, FORMAT, SCALAR); \
+ output_add_string (BUFFER, (BUFFER)->digit_buffer); \
+ } \
+ while (0)
+
/* Forward declarations. */
typedef struct diagnostic_context diagnostic_context;
-typedef void (*diagnostic_starter_fn) PARAMS ((diagnostic_context *,
- diagnostic_info *));
+typedef void (*diagnostic_starter_fn) (diagnostic_context *,
+ diagnostic_info *);
typedef diagnostic_starter_fn diagnostic_finalizer_fn;
/* This data structure bundles altogether any information relevant to
/* The number of times we have issued diagnostics. */
int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];
+ /* True if we should display the "warnings are being tread as error"
+ message, usually displayed once per compiler run. */
+ bool warnings_are_errors_message;
+
+ /* True if we should raise a SIGABRT on errors. */
+ bool abort_on_error;
+
/* This function is called before any message is printed out. It is
responsible for preparing message prefix and such. For example, it
might say:
diagnostic_finalizer_fn end_diagnostic;
/* Client hook to report an internal error. */
- void (*internal_error) PARAMS ((const char *, va_list *));
+ void (*internal_error) (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
#define diagnostic_set_last_module(DC) \
(DC)->last_module = input_file_stack_tick
+/* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */
+#define diagnostic_abort_on_error(DC) \
+ (DC)->abort_on_error = true
+
/* This diagnostic_context is used by front-ends that directly output
diagnostic messages without going through `error', `warning',
and similar functions. */
extern diagnostic_context *global_dc;
-/* The total count of a KIND of diagnostics meitted so far. */
+/* The total count of a KIND of diagnostics emitted so far. */
#define diagnostic_kind_count(DC, DK) (DC)->diagnostic_count[(int) (DK)]
/* The number of errors that have been issued so far. Ideally, these
/* Similarly, but for sorrys. */
#define sorrycount diagnostic_kind_count (global_dc, DK_SORRY)
-/* Returns non-zero if warnings should be emitted. */
+/* Returns nonzero if warnings should be emitted. */
#define diagnostic_report_warnings_p() \
(!inhibit_warnings \
&& !(in_system_header && !warn_system_headers))
#define report_diagnostic(D) diagnostic_report_diagnostic (global_dc, D)
-/* 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 *));
+/* Diagnostic related functions. */
+extern void diagnostic_initialize (diagnostic_context *);
+extern void diagnostic_report_current_module (diagnostic_context *);
+extern void diagnostic_report_current_function (diagnostic_context *);
+extern void diagnostic_flush_buffer (diagnostic_context *);
+extern void diagnostic_report_diagnostic (diagnostic_context *,
+ diagnostic_info *);
+extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
+ const char *, int, diagnostic_t);
+extern char *diagnostic_build_prefix (diagnostic_info *);
/* Pure text formatting support functions. */
-extern void init_output_buffer PARAMS ((output_buffer *,
- const char *, int));
-extern void output_clear PARAMS ((output_buffer *));
-extern const char *output_last_position PARAMS ((const output_buffer *));
-extern void output_set_prefix PARAMS ((output_buffer *,
- const char *));
-extern void output_destroy_prefix PARAMS ((output_buffer *));
-extern void output_set_maximum_length PARAMS ((output_buffer *, int));
-extern void output_emit_prefix PARAMS ((output_buffer *));
-extern void output_add_newline PARAMS ((output_buffer *));
-extern void output_add_space PARAMS ((output_buffer *));
-extern int output_space_left PARAMS ((const output_buffer *));
-extern void output_append PARAMS ((output_buffer *, const char *,
- const char *));
-extern void output_add_character PARAMS ((output_buffer *, int));
-extern void output_decimal PARAMS ((output_buffer *, int));
-extern void output_add_string PARAMS ((output_buffer *,
- const char *));
-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 void output_verbatim PARAMS ((output_buffer *, const char *,
- ...)) ATTRIBUTE_PRINTF_2;
-extern void verbatim PARAMS ((const char *, ...))
- ATTRIBUTE_PRINTF_1;
-extern char *file_name_as_prefix PARAMS ((const char *));
+extern void init_output_buffer (output_buffer *, const char *, int);
+extern void output_clear (output_buffer *);
+extern const char *output_last_position (const output_buffer *);
+extern void output_set_prefix (output_buffer *, const char *);
+extern void output_destroy_prefix (output_buffer *);
+extern void output_set_maximum_length (output_buffer *, int);
+extern void output_emit_prefix (output_buffer *);
+extern void output_add_newline (output_buffer *);
+extern void output_add_space (output_buffer *);
+extern int output_space_left (const output_buffer *);
+extern void output_append (output_buffer *, const char *, const char *);
+extern void output_add_character (output_buffer *, int);
+extern void output_decimal (output_buffer *, int);
+extern void output_add_string (output_buffer *, const char *);
+extern void output_add_identifier (output_buffer *, tree);
+extern const char *output_finalize_message (output_buffer *);
+extern void output_clear_message_text (output_buffer *);
+extern void output_printf (output_buffer *, const char *, ...)
+ ATTRIBUTE_PRINTF_2;
+extern void output_verbatim (output_buffer *, const char *, ...);
+extern void verbatim (const char *, ...);
+extern char *file_name_as_prefix (const char *);
+extern void inform (const char *, ...);
#endif /* ! GCC_DIAGNOSTIC_H */