diagnostic_show_locus: move initial newline to callers
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 10 Dec 2019 01:48:42 +0000 (01:48 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 10 Dec 2019 01:48:42 +0000 (01:48 +0000)
commitd3e28653fa2cd9ad8d5c6acb4bd182bd473c0995
tree6a32daf2c3f7dda13f11c307644131f4996f3520
parent41aeca8d1bfc03f0db4437d5866c5f3d9343013f
diagnostic_show_locus: move initial newline to callers

diagnostic_show_locus adds a newline before doing anything (including
the do-nothing-else case).

This patch removes this initial newline, adding it to all callers
of diagnostic_show_locus instead.

Doing so makes diagnostic_show_locus more flexible, allowing it to be
used in my analyzer patch kit for printing diagnostic paths.

gcc/c-family/ChangeLog:
* c-format.c (selftest::test_type_mismatch_range_labels): Remove
initial newline from expected outputs.
* c-opts.c (c_diagnostic_finalizer): Add pp_newline call before
call to diagnostic_show_locus.

gcc/ChangeLog:
* diagnostic-show-locus.c (diagnostic_show_locus): Remove initial
newline.
(selftest::test_diagnostic_show_locus_unknown_location): Remove
initial newline from expected outputs.
(selftest::test_one_liner_simple_caret): Likewise.
(selftest::test_one_liner_caret_and_range): Likewise.
(selftest::test_one_liner_multiple_carets_and_ranges): Likewise.
(selftest::test_one_liner_fixit_insert_before): Likewise.
(selftest::test_one_liner_fixit_insert_after): Likewise.
(selftest::test_one_liner_fixit_remove): Likewise.
(selftest::test_one_liner_fixit_replace): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range):
Likewise.
(selftest::test_one_liner_fixit_replace_equal_secondary_range):
Likewise.
(selftest::test_one_liner_fixit_validation_adhoc_locations):
Likewise.
(selftest::test_one_liner_many_fixits_1): Likewise.
(selftest::test_one_liner_many_fixits_2): Likewise.
(selftest::test_one_liner_labels): Likewise.
(selftest::test_one_liner_simple_caret_utf8): Likewise.
(selftest::test_one_liner_caret_and_range_utf8): Likewise.
(selftest::test_one_liner_multiple_carets_and_ranges_utf8):
Likewise.
(selftest::test_one_liner_fixit_insert_before_utf8): Likewise.
(selftest::test_one_liner_fixit_insert_after_utf8): Likewise.
(selftest::test_one_liner_fixit_remove_utf8): Likewise.
(selftest::test_one_liner_fixit_replace_utf8): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range_utf8):
Likewise.
(selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8):
Likewise.
(selftest::test_one_liner_fixit_validation_adhoc_locations_utf8):
Likewise.
(selftest::test_one_liner_many_fixits_1_utf8): Likewise.
(selftest::test_one_liner_many_fixits_2_utf8): Likewise.
(selftest::test_one_liner_labels_utf8): Likewise.
(selftest::test_add_location_if_nearby): Likewise.
(selftest::test_diagnostic_show_locus_fixit_lines): Likewise.
(selftest::test_overlapped_fixit_printing): Likewise.
(selftest::test_overlapped_fixit_printing_utf8): Likewise.
(selftest::test_overlapped_fixit_printing_2): Likewise.
(selftest::test_fixit_insert_containing_newline): Likewise.
(selftest::test_fixit_insert_containing_newline_2): Likewise.
(selftest::test_fixit_replace_containing_newline): Likewise.
(selftest::test_fixit_deletion_affecting_newline): Likewise.
(selftest::test_line_numbers_multiline_range): Likewise.
* diagnostic.c (default_diagnostic_finalizer): Add pp_newline call
before call to diagnostic_show_locus.
(diagnostic_append_note): Likewise.

gcc/fortran/ChangeLog:
* error.c (gfc_diagnostic_starter): Add pp_newline call before
call to diagnostic_show_locus.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
(custom_diagnostic_finalizer): Add pp_newline call before call to
diagnostic_show_locus.

From-SVN: r279152
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-format.c
gcc/c-family/c-opts.c
gcc/diagnostic-show-locus.c
gcc/diagnostic.c
gcc/fortran/ChangeLog
gcc/fortran/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c