diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-09-15 23:57:01 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-09-15 23:57:01 +0000 |
commit | 31316208638e76c2273a82864d32457a9cb9806d (patch) | |
tree | 802052306a708cf70c39ab01f29991c7f405d639 /libcpp/line-map.c | |
parent | 902d624f45c2be8ca865017539f0c224c913f146 (diff) | |
download | gcc-31316208638e76c2273a82864d32457a9cb9806d.zip gcc-31316208638e76c2273a82864d32457a9cb9806d.tar.gz gcc-31316208638e76c2273a82864d32457a9cb9806d.tar.bz2 |
fix-it hints can't contain newlines
I hope to implement newline support within fix-it hints at some point,
but currently it's not supported, and leads to misleading diagnostic
output, so for now, fail gracefully.
gcc/ChangeLog:
* diagnostic-show-locus.c
(selftest::test_fixit_insert_containing_newline): New function.
(selftest::test_fixit_replace_containing_newline): New function.
(selftest::diagnostic_show_locus_c_tests): Call the above.
libcpp/ChangeLog:
* include/line-map.h (class rich_location): Note that newlines
aren't supported in fix-it text.
* line-map.c (rich_location::add_fixit_insert_before): Reject
attempts to add fix-its containing newlines.
(rich_location::add_fixit_replace): Likewise.
From-SVN: r240169
Diffstat (limited to 'libcpp/line-map.c')
-rw-r--r-- | libcpp/line-map.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libcpp/line-map.c b/libcpp/line-map.c index 742af0a..07e3acb 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -2128,6 +2128,12 @@ rich_location::add_fixit_insert_before (source_location where, if (reject_impossible_fixit (start)) return; + /* We do not yet support newlines within fix-it hints. */ + if (strchr (new_content, '\n')) + { + stop_supporting_fixits (); + return; + } add_fixit (new fixit_insert (start, new_content)); } @@ -2271,6 +2277,13 @@ rich_location::add_fixit_replace (source_range src_range, if (reject_impossible_fixit (src_range.m_finish)) return; + /* We do not yet support newlines within fix-it hints. */ + if (strchr (new_content, '\n')) + { + stop_supporting_fixits (); + return; + } + /* Consolidate neighboring fixits. */ fixit_hint *prev = get_last_fixit_hint (); if (prev) |