From d9020fe61291812489bd4bb954c0c04ac088ac6f Mon Sep 17 00:00:00 2001 From: dmalcolm Date: Thu, 15 Sep 2016 23:57:01 +0000 Subject: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240169 138bc75d-0d04-0410-961f-82ee72b054a4 --- libcpp/include/line-map.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libcpp/include') diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 939bfcc5712..747609d4393 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1551,6 +1551,8 @@ class fixit_hint; Attempts to add a fix-it hint within a macro expansion will fail. + We do not yet support newlines in fix-it text; attempts to do so will fail. + The rich_location API handles these failures gracefully, so that diagnostics can attempt to add fix-it hints without each needing extensive checking. -- cgit v1.2.1