diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-04-12 06:19:58 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-04-12 06:19:58 +0000 |
commit | 41609f8bc12a3e7feeaf7749a03f880e5b3c2819 (patch) | |
tree | 6c0949bd9c81eb35e9a104c1b13c71602bef3a0c /gcc/pretty-print.c | |
parent | 79f85ed59b356e24986dda057360c8782a652e69 (diff) | |
download | gcc-41609f8bc12a3e7feeaf7749a03f880e5b3c2819.tar.gz |
* opts.c: Include diagnostic-color.h.
(common_handle_option): Handle OPT_fdiagnostics_color_.
* Makefile.in (OBJS-libcommon): Add diagnostic-color.o.
(diagnostic.o, opts.o, pretty-print.o): Depend on diagnostic-color.h.
(diagnostic-color.o): New.
* common.opt (fdiagnostics-color, fdiagnostics-color=): New options.
(diagnostic_color_rule): New enum.
* dwarf2out.c (gen_producer_string): Don't print -fdiagnostics-color*.
* langhooks.c (lhd_print_error_function): Add %r "locus" and %R around
the location string.
* diagnostic.def: Add 3rd argument to DEFINE_DIAGNOSTIC_KIND macros,
either NULL, or color kind.
* diagnostic-color.c: New file.
* diagnostic-color.h: New file.
* diagnostic-core.h (DEFINE_DIAGNOSTIC_KIND): Adjust macro for 3
arguments.
* doc/invoke.texi (-fdiagnostics-color): Document.
* pretty-print.h (pp_show_color): Define.
(struct pretty_print_info): Add show_color field.
* diagnostic.c: Include diagnostic-color.h.
(diagnostic_build_prefix): Adjust for 3 argument DEFINE_DIAGNOSTIC_KIND
macros. Colorize error:, warning: etc. strings and also the location
string.
(diagnostic_show_locus): Colorize the caret line.
* pretty-print.c: Include diagnostic-color.h.
(pp_base_format): Handle %r and %R format specifiers. Colorize strings
inside of %< %> quotes or quoted through q format modifier.
c-family/
* c-format.c (gcc_diag_char_table, gcc_tdiag_char_table,
gcc_cdiag_char_table, gcc_cxxdiag_char_table): Add %r and %R format
specifiers.
cp/
* error.c (cp_print_error_function,
print_instantiation_partial_context_line,
maybe_print_constexpr_context): Colorize locus strings.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197841 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/pretty-print.c')
-rw-r--r-- | gcc/pretty-print.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index 4c45e51ec7f..fe46464538e 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "intl.h" #include "pretty-print.h" +#include "diagnostic-color.h" #if HAVE_ICONV #include <iconv.h> @@ -226,6 +227,8 @@ pp_base_indent (pretty_printer *pp) %c: character. %s: string. %p: pointer. + %r: if pp_show_color(pp), switch to color identified by const char *. + %R: if pp_show_color(pp), reset color. %m: strerror(text->err_no) - does not consume a value from args_ptr. %%: '%'. %<: opening quote. @@ -300,18 +303,37 @@ pp_base_format (pretty_printer *pp, text_info *text) continue; case '<': - obstack_grow (&buffer->chunk_obstack, - open_quote, strlen (open_quote)); - p++; - continue; + { + obstack_grow (&buffer->chunk_obstack, + open_quote, strlen (open_quote)); + const char *colorstr + = colorize_start (pp_show_color (pp), "quote"); + obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr)); + p++; + continue; + } case '>': + { + const char *colorstr = colorize_stop (pp_show_color (pp)); + obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr)); + } + /* FALLTHRU */ case '\'': obstack_grow (&buffer->chunk_obstack, close_quote, strlen (close_quote)); p++; continue; + case 'R': + { + const char *colorstr = colorize_stop (pp_show_color (pp)); + obstack_grow (&buffer->chunk_obstack, colorstr, + strlen (colorstr)); + p++; + continue; + } + case 'm': { const char *errstr = xstrerror (text->err_no); @@ -466,10 +488,19 @@ pp_base_format (pretty_printer *pp, text_info *text) gcc_assert (!wide || precision == 0); if (quote) - pp_string (pp, open_quote); + { + pp_string (pp, open_quote); + pp_string (pp, colorize_start (pp_show_color (pp), "quote")); + } switch (*p) { + case 'r': + pp_string (pp, colorize_start (pp_show_color (pp), + va_arg (*text->args_ptr, + const char *))); + break; + case 'c': pp_character (pp, va_arg (*text->args_ptr, int)); break; @@ -563,7 +594,10 @@ pp_base_format (pretty_printer *pp, text_info *text) } if (quote) - pp_string (pp, close_quote); + { + pp_string (pp, colorize_stop (pp_show_color (pp))); + pp_string (pp, close_quote); + } obstack_1grow (&buffer->chunk_obstack, '\0'); *formatters[argno] = XOBFINISH (&buffer->chunk_obstack, const char *); |