]> git.ipfire.org Git - thirdparty/gcc.git/commit
Prevent fix-it hints from affecting more than one line
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Jun 2017 10:40:38 +0000 (10:40 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Jun 2017 10:40:38 +0000 (10:40 +0000)
commitc2403f36287ffd90629aa67b204f35844fc237fb
treefe86d10819506cdb8f17e6172d8ed766eb12c2fa
parent199666f5a9eb29a00514ce8277c7b122e3297dd1
Prevent fix-it hints from affecting more than one line

Attempts to apply a removal or replacement fix-it hint to a source
range that covers multiple lines currently lead to nonsensical
results from the printing code in diagnostic-show-locus.c.

We were already filtering them out in edit-context.c (leading
to -fdiagnostics-generate-patch not generating any output for
the whole TU).

Reject attempts to add such fix-it hints within rich_location,
fixing the diagnostic-show-locus.c issue.

gcc/ChangeLog:
* diagnostic-show-locus.c
(selftest::test_fixit_deletion_affecting_newline): New function.
(selftest::diagnostic_show_locus_c_tests): Call it.

libcpp/ChangeLog:
* include/line-map.h (class rich_location): Document that attempts
to delete or replace a range *affecting* multiple lines will fail.
* line-map.c (rich_location::maybe_add_fixit): Implement this
restriction.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249403 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/diagnostic-show-locus.c
libcpp/ChangeLog
libcpp/include/line-map.h
libcpp/line-map.c