C++ template type diff printing
commit4d1eda3ac6f22a81b1df2015f95060777908b42c
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 May 2017 20:38:14 +0000 (30 20:38 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 May 2017 20:38:14 +0000 (30 20:38 +0000)
tree02e8550289f6ec4b17f911b6571757f54cfb3e19
parent460ff77d914849b7185e31f1e5ed4080eae84e1f
C++ template type diff printing

gcc/ChangeLog:
* diagnostic-color.c (color_dict): Add "type-diff".
(parse_gcc_colors): Update comment.
* doc/invoke.texi (Diagnostic Message Formatting Options): Add
-fdiagnostics-show-template-tree and -fno-elide-type.
(GCC_COLORS): Add type-diff to example.
(type-diff=): New.
(-fdiagnostics-show-template-tree): New.
(-fno-elide-type): New.
* pretty-print.c (pp_format): Pass quote and formatters[argno] to
the pp_format_decoder callback.  Call any m_format_postprocessor's
"handle" method.
(pretty_printer::pretty_printer): Initialize
m_format_postprocessor.
(pretty_printer::~pretty_printer): Delete any
m_format_postprocessor.
* pretty-print.h (printer_fn): Add bool and const char **
parameters.
(class format_postprocessor): New class.
(struct pretty_printer::format_decoder): Document the new
parameters.
(struct pretty_printer::m_format_postprocessor): New field.
* tree-diagnostic.c (default_tree_printer): Update for new
bool and const char ** params.
* tree-diagnostic.h (default_tree_printer): Likewise.

gcc/c/ChangeLog:
* c-objc-common.c (c_tree_printer): Gain bool and const char **
parameters.

gcc/c-family/ChangeLog:
* c-format.c (gcc_cxxdiag_char_table): Add 'H' and 'I' to
format_chars.
* c.opt (fdiagnostics-show-template-tree): New option.
(felide-type): New option.

gcc/cp/ChangeLog:
* call.c (perform_implicit_conversion_flags): Convert
"from %qT to %qT" to "from %qH to %qI" in diagnostic.
(print_conversion_rejection): Replace pairs of %qT with
%qH and %qI in various places.
(build_user_type_conversion_1): Likewise.
(build_integral_nontype_arg_conv): Likewise.
(build_conditional_expr_1): Likewise.
(convert_like_real): Likewise.
(convert_arg_to_ellipsis): Likewise.
(joust): Likewise.
(initialize_reference): Likewise.
* cvt.c (cp_convert_to_pointer): Likewise.
(cp_convert_to_pointer): Likewise.
(convert_to_reference): Likewise.
(ocp_convert): Likewise.
* error.c (cp_printer): Gain bool and const char ** parameters.
(struct deferred_printed_type): New struct.
(class cxx_format_postprocessor): New class.
(cxx_initialize_diagnostics): Wire up a cxx_format_postprocessor
to pp->m_format_postprocessor.
(comparable_template_types_p): New function.
(newline_and_indent): New function.
(arg_to_string): New function.
(print_nonequal_arg): New function.
(print_template_differences): New function.
(type_to_string_with_compare): New function.
(print_template_tree_comparison): New function.
(append_formatted_chunk): New function.
(add_quotes): New function.
(cxx_format_postprocessor::handle): New function.
(defer_phase_2_of_type_diff): New function.
(cp_printer): Add "quoted" and "buffer_ptr" params.  Implement
%H and %I.
* typeck.c (cp_build_binary_op): Replace pairs of %qT with
%qH and %qI in various places.
(convert_member_func_to_ptr): Likewise.
(build_reinterpret_cast_1): Likewise.
(convert_for_assignment): Likewise.
* typeck2.c (check_narrowing): Likewise.

gcc/fortran/ChangeLog:
* error.c (gfc_format_decoder): Update for new bool and
const char ** params.

gcc/testsuite/ChangeLog:
* g++.dg/plugin/plugin.exp (plugin_test_list): Add...
* g++.dg/plugin/show-template-tree-color-no-elide-type.C: New
test case.
* g++.dg/plugin/show-template-tree-color.C: New test case.
* g++.dg/plugin/show_template_tree_color_plugin.c: New plugin.
* g++.dg/template/show-template-tree-2.C: New test case.
* g++.dg/template/show-template-tree-3.C: New test case.
* g++.dg/template/show-template-tree-4.C: New test case.
* g++.dg/template/show-template-tree-no-elide-type.C: New test case.
* g++.dg/template/show-template-tree.C: New test case.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248698 138bc75d-0d04-0410-961f-82ee72b054a4
30 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-format.c
gcc/c-family/c.opt
gcc/c/ChangeLog
gcc/c/c-objc-common.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cvt.c
gcc/cp/error.c
gcc/cp/typeck.c
gcc/cp/typeck2.c
gcc/diagnostic-color.c
gcc/doc/invoke.texi
gcc/fortran/ChangeLog
gcc/fortran/error.c
gcc/pretty-print.c
gcc/pretty-print.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/plugin/plugin.exp
gcc/testsuite/g++.dg/plugin/show-template-tree-color-no-elide-type.C [new file with mode: 0644]
gcc/testsuite/g++.dg/plugin/show-template-tree-color.C [new file with mode: 0644]
gcc/testsuite/g++.dg/plugin/show_template_tree_color_plugin.c [new file with mode: 0644]
gcc/testsuite/g++.dg/template/show-template-tree-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/show-template-tree-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/show-template-tree-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/show-template-tree-no-elide-type.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/show-template-tree.C [new file with mode: 0644]
gcc/tree-diagnostic.c
gcc/tree-diagnostic.h