diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-04-12 08:20:36 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-04-12 08:20:36 +0200 |
commit | f3065bdb6e2161e61ebabe5f4efb6eaef0ae910d (patch) | |
tree | ab5a7c6ce0bc1945a5d6a869ec16bae2b8848b7e /gcc/diagnostic-color.h | |
parent | 4b84d650e82e29bd3ff901a1e34b08435ee99871 (diff) | |
download | gcc-f3065bdb6e2161e61ebabe5f4efb6eaef0ae910d.tar.gz |
opts.c: Include diagnostic-color.h.
* 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.
From-SVN: r197842
Diffstat (limited to 'gcc/diagnostic-color.h')
-rw-r--r-- | gcc/diagnostic-color.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/gcc/diagnostic-color.h b/gcc/diagnostic-color.h new file mode 100644 index 00000000000..e643e5188c0 --- /dev/null +++ b/gcc/diagnostic-color.h @@ -0,0 +1,66 @@ +/* Copyright (C) 2013 Free Software Foundation, Inc. + Contributed by Manuel Lopez-Ibanez <manu@gcc.gnu.org> + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +/* Based on code from: */ +/* grep.c - main driver file for grep. + Copyright (C) 1992, 1997-2002, 2004-2013 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA + 02110-1301, USA. + + Written July 1992 by Mike Haertel. */ + +#ifndef GCC_DIAGNOSTIC_COLOR_H +#define GCC_DIAGNOSTIC_COLOR_H + +/* How often diagnostics are prefixed by their locations: + o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported; + o DIAGNOSTICS_SHOW_PREFIX_ONCE: emit only once; + o DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: emit each time a physical + line is started. */ +typedef enum +{ + DIAGNOSTICS_COLOR_NO = 0, + DIAGNOSTICS_COLOR_YES = 1, + DIAGNOSTICS_COLOR_AUTO = 2 +} diagnostic_color_rule_t; + +const char *colorize_start (bool, const char *, size_t); +const char *colorize_stop (bool); +bool colorize_init (diagnostic_color_rule_t); + +inline const char * +colorize_start (bool show_color, const char *name) +{ + return colorize_start (show_color, name, strlen (name)); +} + +#endif /* ! GCC_DIAGNOSTIC_COLOR_H */ |