@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "c-objc-common.h"
static bool c_tree_printer (pretty_printer *, text_info *, const char *,
- int, bool, bool, bool);
+ int, bool, bool, bool, bool, const char **);
bool
c_missing_noreturn_ok_p (tree decl)
@@ -75,7 +75,8 @@ c_objc_common_init (void)
diagnostic machinery. */
static bool
c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
- int precision, bool wide, bool set_locus, bool hash)
+ int precision, bool wide, bool set_locus, bool hash,
+ bool, const char **)
{
tree t = NULL_TREE;
tree name;
@@ -99,7 +99,7 @@ static void cp_diagnostic_starter (diagnostic_context *, diagnostic_info *);
static void cp_print_error_function (diagnostic_context *, diagnostic_info *);
static bool cp_printer (pretty_printer *, text_info *, const char *,
- int, bool, bool, bool);
+ int, bool, bool, bool, bool, const char **);
/* CONTEXT->printer is a basic pretty printer that was constructed
presumably by diagnostic_initialize(), called early in the
@@ -3582,7 +3582,8 @@ maybe_print_constexpr_context (diagnostic_context *context)
%X exception-specification. */
static bool
cp_printer (pretty_printer *pp, text_info *text, const char *spec,
- int precision, bool wide, bool set_locus, bool verbose)
+ int precision, bool wide, bool set_locus, bool verbose,
+ bool, const char **)
{
const char *result;
tree t = NULL;
@@ -174,6 +174,7 @@ static struct color_cap color_dict[] =
{ "diff-hunk", SGR_SEQ (COLOR_FG_CYAN), 9, false },
{ "diff-delete", SGR_SEQ (COLOR_FG_RED), 11, false },
{ "diff-insert", SGR_SEQ (COLOR_FG_GREEN), 11, false },
+ { "type-diff", SGR_SEQ (COLOR_BOLD COLOR_SEPARATOR COLOR_FG_GREEN), 9, false },
{ NULL, NULL, 0, false }
};
@@ -204,8 +205,9 @@ colorize_stop (bool show_color)
/* Parse GCC_COLORS. The default would look like:
GCC_COLORS='error=01;31:warning=01;35:note=01;36:\
range1=32:range2=34:locus=01:quote=01:\
- fixit-insert=32:fixit-delete=31'\
- diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32'
+ fixit-insert=32:fixit-delete=31:'\
+ diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
+ type-diff=01;32'
No character escaping is needed or supported. */
static bool
parse_gcc_colors (void)
@@ -3442,7 +3442,8 @@ The default @env{GCC_COLORS} is
@smallexample
error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
quote=01:fixit-insert=32:fixit-delete=31:\
-diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32
+diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
+type-diff=01;32
@end smallexample
@noindent
where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
@@ -3506,6 +3507,11 @@ SGR substring for deleted lines within generated patches.
@item diff-insert=
@vindex diff-insert GCC_COLORS @r{capability}
SGR substring for inserted lines within generated patches.
+
+@item type-diff=
+@vindex type-diff GCC_COLORS @r{capability}
+SGR substring for highlighting mismatching types within template
+arguments in the C++ frontend.
@end table
@item -fno-diagnostics-show-option
@@ -917,7 +917,8 @@ gfc_notify_std (int std, const char *gmsgid, ...)
*/
static bool
gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec,
- int precision, bool wide, bool set_locus, bool hash)
+ int precision, bool wide, bool set_locus, bool hash,
+ bool quoted, const char **buffer_ptr)
{
switch (*spec)
{
@@ -948,7 +949,7 @@ gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec,
etc. diagnostics can use the FE printer while the FE is still
active. */
return default_tree_printer (pp, text, spec, precision, wide,
- set_locus, hash);
+ set_locus, hash, quoted, buffer_ptr);
}
}
@@ -677,7 +677,8 @@ pp_format (pretty_printer *pp, text_info *text)
gcc_assert (pp_format_decoder (pp));
ok = pp_format_decoder (pp) (pp, text, p,
- precision, wide, plus, hash);
+ precision, wide, plus, hash, quote,
+ formatters[argno]);
gcc_assert (ok);
}
}
@@ -696,6 +697,11 @@ pp_format (pretty_printer *pp, text_info *text)
for (; argno < PP_NL_ARGMAX; argno++)
gcc_assert (!formatters[argno]);
+ /* If the client supplied a postprocessing object, call its "handle"
+ hook here. */
+ if (pp->m_format_postprocessor)
+ pp->m_format_postprocessor->handle (pp);
+
/* Revert to normal obstack and wrapping mode. */
buffer->obstack = &buffer->formatted_obstack;
buffer->line_length = 0;
@@ -847,6 +853,7 @@ pretty_printer::pretty_printer (const char *p, int l)
indent_skip (),
wrapping (),
format_decoder (),
+ m_format_postprocessor (NULL),
emitted_prefix (),
need_newline (),
translate_identifiers (true),
@@ -860,6 +867,8 @@ pretty_printer::pretty_printer (const char *p, int l)
pretty_printer::~pretty_printer ()
{
+ if (m_format_postprocessor)
+ delete m_format_postprocessor;
buffer->~output_buffer ();
XDELETE (buffer);
}
@@ -180,11 +180,20 @@ struct pp_wrapping_mode_t
A client-supplied formatter returns true if everything goes well,
otherwise it returns false. */
typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *,
- int, bool, bool, bool);
+ int, bool, bool, bool, bool, const char **);
/* Client supplied function used to decode formats. */
#define pp_format_decoder(PP) (PP)->format_decoder
+/* Base class for an optional client-supplied object for doing additional
+ processing between stages 2 and 3 of formatted printing. */
+class format_postprocessor
+{
+ public:
+ virtual ~format_postprocessor () {}
+ virtual void handle (pretty_printer *) = 0;
+};
+
/* TRUE if a newline character needs to be added before further
formatting. */
#define pp_needs_newline(PP) (PP)->need_newline
@@ -239,9 +248,16 @@ struct pretty_printer
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.
- */
+ The QUOTE and BUFFER_PTR are passed in, to allow for deferring-handling
+ of format codes (e.g. %H and %I in the C++ frontend). */
printer_fn format_decoder;
+ /* If non-NULL, this is called by pp_format once after all format codes
+ have been processed, to allow for client-specific postprocessing.
+ This is used by the C++ frontend for handling the %H and %I
+ format codes (which interract with each other). */
+ format_postprocessor *m_format_postprocessor;
+
/* Nonzero if current PREFIX was emitted at least once. */
bool emitted_prefix;
@@ -245,7 +245,8 @@ virt_loc_aware_diagnostic_finalizer (diagnostic_context *context,
/* Default tree printer. Handles declarations only. */
bool
default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
- int precision, bool wide, bool set_locus, bool hash)
+ int precision, bool wide, bool set_locus, bool hash,
+ bool, const char **)
{
tree t;
@@ -55,6 +55,6 @@ void virt_loc_aware_diagnostic_finalizer (diagnostic_context *,
void tree_diagnostics_defaults (diagnostic_context *context);
bool default_tree_printer (pretty_printer *, text_info *, const char *,
- int, bool, bool, bool);
+ int, bool, bool, bool, bool, const char **);
#endif /* ! GCC_TREE_DIAGNOSTIC_H */