diff options
author | Jason Merrill <jason@redhat.com> | 2021-06-18 05:45:02 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-05-06 16:34:51 -0400 |
commit | 69dd5ca3484ee514c1323dfbcf4ef4358cea57bb (patch) | |
tree | 977459ac84579eac53c159e7d22f2e957bcf793a /gcc/doc | |
parent | e4e053a63b153039a7905901806a4f4a3154988b (diff) | |
download | gcc-69dd5ca3484ee514c1323dfbcf4ef4358cea57bb.zip gcc-69dd5ca3484ee514c1323dfbcf4ef4358cea57bb.tar.gz gcc-69dd5ca3484ee514c1323dfbcf4ef4358cea57bb.tar.bz2 |
c++: add color to function decl printing
In reading C++ diagnostics, it's often hard to find the name of the function
in the middle of the template header, return type, parameters, and template
arguments. So let's colorize it, and maybe the template argument bindings
while we're at it.
I've somewhat arbitrarily chosen bold green for the function name, and
non-bold magenta for the template arguments.
A side-effect of this is that when this happens in a quote (i.e. %qD), the
rest of the quote after the function name is no longer bold. I think that's
acceptable; returning to the bold would require maintaining a colorize stack
instead of the on/off controls we have now.
gcc/cp/ChangeLog:
* error.cc (decl_to_string): Add show_color parameter.
(subst_to_string): Likewise.
(cp_printer): Pass it.
(type_to_string): Set pp_show_color.
(dump_function_name): Use "fnname" color.
(dump_template_bindings): Use "targs" color.
(struct colorize_guard): New.
(reinit_cxx_pp): Clear pp_show_color.
gcc/ChangeLog:
* diagnostic-color.cc: Add fnname and targs color entries.
* doc/invoke.texi: Document them.
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/function-color1.C: New test.
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/invoke.texi | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 3f4d6f2..7a35d96 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4845,7 +4845,7 @@ The default @env{GCC_COLORS} is error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ -type-diff=01;32 +type-diff=01;32:fnname=01;32:targs=35 @end smallexample @noindent where @samp{01;31} is bold red, @samp{01;35} is bold magenta, @@ -4890,6 +4890,14 @@ SGR substring for location information, @samp{file:line} or @vindex quote GCC_COLORS @r{capability} SGR substring for information printed within quotes. +@item fnname= +@vindex fnname GCC_COLORS @r{capability} +SGR substring for names of C++ functions. + +@item targs= +@vindex targs GCC_COLORS @r{capability} +SGR substring for C++ function template parameter bindings. + @item fixit-insert= @vindex fixit-insert GCC_COLORS @r{capability} SGR substring for fix-it hints suggesting text to |