aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2017-06-20 10:40:38 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2017-06-20 10:40:38 +0000
commitc7a980b80b3a46ad24940269f6b85a75cdb94a60 (patch)
treefe86d10819506cdb8f17e6172d8ed766eb12c2fa /libcpp/include
parentad2f2a35d33ea79f95b70f8d96ee1445fabed402 (diff)
downloadgcc-c7a980b80b3a46ad24940269f6b85a75cdb94a60.zip
gcc-c7a980b80b3a46ad24940269f6b85a75cdb94a60.tar.gz
gcc-c7a980b80b3a46ad24940269f6b85a75cdb94a60.tar.bz2
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. From-SVN: r249403
Diffstat (limited to 'libcpp/include')
-rw-r--r--libcpp/include/line-map.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index be3041d..f5c19e3 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1556,6 +1556,8 @@ class fixit_hint;
inserting at the start of a line, and finishing with a newline
(with no interior newline characters). Other attempts to add
fix-it hints containing newline characters will fail.
+ Similarly, attempts to delete or replace a range *affecting* multiple
+ lines will fail.
The rich_location API handles these failures gracefully, so that
diagnostics can attempt to add fix-it hints without each needing