aboutsummaryrefslogtreecommitdiff
path: root/gcc/pretty-print.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2019-10-01 21:58:17 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2019-10-01 21:58:17 +0000
commite9c9a142b49d069c5b7c24d47b07756e9d591956 (patch)
tree1733bd2afdb942dcf5381fec2e6e5d79071d9db8 /gcc/pretty-print.c
parenta16bc2f317ddfeb45a6b293aec4d89afe0e79a72 (diff)
downloadgcc-e9c9a142b49d069c5b7c24d47b07756e9d591956.zip
gcc-e9c9a142b49d069c5b7c24d47b07756e9d591956.tar.gz
gcc-e9c9a142b49d069c5b7c24d47b07756e9d591956.tar.bz2
Support prefixes in diagnostic_show_locus
Previously, diagnostic_show_locus saved and restored the pretty_printer's prefix, clearing it for the duration of the call. I have a patch kit in development that can benefit from applying a prefix to the output of d_s_l, so this patch adds support to d_s_l for printing such prefixes. It moves the save and restore of the pp's prefix from d_s_l to all of its callers, and updates diagnostic-show-locus.c to properly handle prefixes. gcc/c-family/ChangeLog: * c-opts.c (c_diagnostic_finalizer): Temporarily clear prefix when calling diagnostic_show_locus, rather than destroying it afterwards. gcc/ChangeLog: * diagnostic-show-locus.c (layout::print_gap_in_line_numbering): Call pp_emit_prefix. (layout::print_source_line): Likewise. (layout::start_annotation_line): Likewise. (diagnostic_show_locus): Remove call to temporarily clear the prefix. (selftest::test_one_liner_fixit_remove): Add test coverage for the interaction of pp_set_prefix with rulers and fix-it hints. * diagnostic.c (default_diagnostic_finalizer): Temporarily clear prefix when calling diagnostic_show_locus, rather than destroying it afterwards. (print_parseable_fixits): Temporarily clear prefix. * pretty-print.c (pp_format): Save and restore line_length, rather than assuming it is zero. (pp_output_formatted_text): Remove assertion that line_length is zero. gcc/fortran/ChangeLog: * error.c (gfc_diagnostic_starter): Clear the prefix before calling diagnostic_show_locus. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_group_plugin.c (test_begin_group_cb): Clear the prefix before emitting the "END GROUP" line. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (custom_diagnostic_finalizer): Temporarily clear prefix when calling diagnostic_show_locus, rather than destroying it afterwards. From-SVN: r276433
Diffstat (limited to 'gcc/pretty-print.c')
-rw-r--r--gcc/pretty-print.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index 6948971..2b6c585 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -1192,6 +1192,7 @@ pp_format (pretty_printer *pp, text_info *text)
/* Set output to the argument obstack, and switch line-wrapping and
prefixing off. */
buffer->obstack = &buffer->chunk_obstack;
+ const int old_line_length = buffer->line_length;
old_wrapping_mode = pp_set_verbatim_wrapping (pp);
/* Second phase. Replace each formatter with the formatted text it
@@ -1412,7 +1413,7 @@ pp_format (pretty_printer *pp, text_info *text)
/* Revert to normal obstack and wrapping mode. */
buffer->obstack = &buffer->formatted_obstack;
- buffer->line_length = 0;
+ buffer->line_length = old_line_length;
pp_wrapping_mode (pp) = old_wrapping_mode;
pp_clear_state (pp);
}
@@ -1427,7 +1428,6 @@ pp_output_formatted_text (pretty_printer *pp)
const char **args = chunk_array->args;
gcc_assert (buffer->obstack == &buffer->formatted_obstack);
- gcc_assert (buffer->line_length == 0);
/* This is a third phase, first 2 phases done in pp_format_args.
Now we actually print it. */