===================================================================
@@ -41,12 +41,10 @@ along with GCC; see the file COPYING3.
#define permissive_error_option(DC) ((DC)->opt_permissive)
/* Prototypes. */
static void error_recursion (diagnostic_context *) ATTRIBUTE_NORETURN;
-static void diagnostic_action_after_output (diagnostic_context *,
- diagnostic_info *);
static void real_abort (void) ATTRIBUTE_NORETURN;
/* Name of program invoked, sans directories. */
const char *progname;
@@ -464,15 +462,15 @@ bt_err_callback (void *data ATTRIBUTE_UN
errnum == 0 ? "" : xstrerror (errnum));
}
/* Take any action which is expected to happen after the diagnostic
is written out. This function does not always return. */
-static void
+void
diagnostic_action_after_output (diagnostic_context *context,
- diagnostic_info *diagnostic)
+ diagnostic_t diag_kind)
{
- switch (diagnostic->kind)
+ switch (diag_kind)
{
case DK_DEBUG:
case DK_NOTE:
case DK_ANACHRONISM:
case DK_WARNING:
@@ -488,11 +486,12 @@ diagnostic_action_after_output (diagnost
diagnostic_finish (context);
exit (FATAL_EXIT_CODE);
}
if (context->max_errors != 0
&& ((unsigned) (diagnostic_kind_count (context, DK_ERROR)
- + diagnostic_kind_count (context, DK_SORRY))
+ + diagnostic_kind_count (context, DK_SORRY)
+ + diagnostic_kind_count (context, DK_WERROR))
>= context->max_errors))
{
fnotice (stderr,
"compilation terminated due to -fmax-errors=%u.\n",
context->max_errors);
@@ -845,11 +844,11 @@ diagnostic_report_diagnostic (diagnostic
diagnostic->x_data = NULL;
pp_format (context->printer, &diagnostic->message);
(*diagnostic_starter (context)) (context, diagnostic);
pp_output_formatted_text (context->printer);
(*diagnostic_finalizer (context)) (context, diagnostic);
- diagnostic_action_after_output (context, diagnostic);
+ diagnostic_action_after_output (context, diagnostic->kind);
diagnostic->message.format_spec = saved_format_spec;
diagnostic->x_data = NULL;
context->lock--;
@@ -1245,22 +1244,19 @@ fnotice (FILE *file, const char *cmsgid,
This mustn't use internal_error, that will cause infinite recursion. */
static void
error_recursion (diagnostic_context *context)
{
- diagnostic_info diagnostic;
-
if (context->lock < 3)
pp_newline_and_flush (context->printer);
fnotice (stderr,
"Internal compiler error: Error reporting routines re-entered.\n");
/* Call diagnostic_action_after_output to get the "please submit a bug
- report" message. It only looks at the kind field of diagnostic_info. */
- diagnostic.kind = DK_ICE;
- diagnostic_action_after_output (context, &diagnostic);
+ report" message. */
+ diagnostic_action_after_output (context, DK_ICE);
/* Do not use gcc_unreachable here; that goes through internal_error
and therefore would cause infinite recursion. */
real_abort ();
}
===================================================================
@@ -292,10 +292,11 @@ extern void diagnostic_append_note (diag
#endif
extern char *diagnostic_build_prefix (diagnostic_context *, const diagnostic_info *);
void default_diagnostic_starter (diagnostic_context *, diagnostic_info *);
void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *);
void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
+void diagnostic_action_after_output (diagnostic_context *, diagnostic_t);
void diagnostic_file_cache_fini (void);
/* Expand the location of this diagnostic. Use this function for consistency. */
===================================================================
@@ -53,13 +53,10 @@ output_buffer::~output_buffer ()
{
obstack_free (&chunk_obstack, NULL);
obstack_free (&formatted_obstack, NULL);
}
-/* A pointer to the formatted diagnostic message. */
-#define pp_formatted_text_data(PP) \
- ((const char *) obstack_base (pp_buffer (PP)->obstack))
/* Format an integer given by va_arg (ARG, type-specifier T) where
type-specifier is a precision modifier as indicated by PREC. F is
a string used to construct the appropriate format-specifier. */
#define pp_integer_with_precision(PP, ARG, PREC, T, F) \
@@ -223,12 +220,11 @@ pp_maybe_wrap_text (pretty_printer *pp,
/* Append to the output area of PRETTY-PRINTER a string specified by its
STARTing character and LENGTH. */
static inline void
pp_append_r (pretty_printer *pp, const char *start, int length)
{
- obstack_grow (pp_buffer (pp)->obstack, start, length);
- pp_buffer (pp)->line_length += length;
+ output_buffer_append_r (pp_buffer (pp), start, length);
}
/* Insert enough spaces into the output area of PRETTY-PRINTER to bring
the column position to the current indentation level, assuming that a
newline has just been written to the buffer. */
@@ -824,25 +820,19 @@ pp_append_text (pretty_printer *pp, cons
/* Finishes constructing a NULL-terminated character string representing
the PRETTY-PRINTED text. */
const char *
pp_formatted_text (pretty_printer *pp)
{
- obstack_1grow (pp_buffer (pp)->obstack, '\0');
- return pp_formatted_text_data (pp);
+ return output_buffer_formatted_text (pp_buffer (pp));
}
/* Return a pointer to the last character emitted in PRETTY-PRINTER's
output area. A NULL pointer means no character available. */
const char *
pp_last_position_in_text (const pretty_printer *pp)
{
- const char *p = NULL;
- struct obstack *text = pp_buffer (pp)->obstack;
-
- if (obstack_base (text) != obstack_next_free (text))
- p = ((const char *) obstack_next_free (text)) - 1;
- return p;
+ return output_buffer_last_position_in_text (pp_buffer (pp));
}
/* Return the amount of characters PRETTY-PRINTER can accept to
make a full line. Meaningful only in line-wrapping mode. */
int
===================================================================
@@ -105,10 +105,42 @@ struct output_buffer
appropriate. Otherwise, text is buffered until either
pp_really_flush or pp_clear_output_area are called. */
bool flush_p;
};
+/* Finishes constructing a NULL-terminated character string representing
+ the buffered text. */
+static inline const char *
+output_buffer_formatted_text (output_buffer *buff)
+{
+ obstack_1grow (buff->obstack, '\0');
+ return (const char *) obstack_base (buff->obstack);
+}
+
+/* Append to the output buffer a string specified by its
+ STARTing character and LENGTH. */
+static inline void
+output_buffer_append_r (output_buffer *buff, const char *start, int length)
+{
+ obstack_grow (buff->obstack, start, length);
+ buff->line_length += length;
+}
+
+/* Return a pointer to the last character emitted in the
+ output_buffer. A NULL pointer means no character available. */
+static inline const char *
+output_buffer_last_position_in_text (const output_buffer *buff)
+{
+ const char *p = NULL;
+ struct obstack *text = buff->obstack;
+
+ if (obstack_base (text) != obstack_next_free (text))
+ p = ((const char *) obstack_next_free (text)) - 1;
+ return p;
+}
+
+
/* The type of pretty-printer flags passed to clients. */
typedef unsigned int pp_flags;
enum pp_padding
{