]> git.ipfire.org Git - thirdparty/gcc.git/commit
diagnostics: Make line-ending logic consistent with libcpp [PR91733]
authorLewis Hyatt <lhyatt@gmail.com>
Thu, 7 Jul 2022 17:59:27 +0000 (13:59 -0400)
committerLewis Hyatt <lhyatt@gmail.com>
Fri, 8 Jul 2022 13:43:33 +0000 (09:43 -0400)
commit2bd15617e73acf76207127e5580cd10b1fab91a5
tree35be9178e2ae2b13bc5a7c6bf4ff695c2f2f565e
parent6da7f7c5ac03f85a753989712588511e5f56e73d
diagnostics: Make line-ending logic consistent with libcpp [PR91733]

libcpp recognizes a lone \r as a valid line ending, so the infrastructure
for retrieving source lines to be output in diagnostics needs to do the
same. This patch fixes file_cache_slot::get_next_line() accordingly so that
diagnostics display the correct part of the source when \r line endings are in
use.

gcc/ChangeLog:

PR preprocessor/91733
* input.cc (find_end_of_line): New helper function.
(file_cache_slot::get_next_line): Recognize \r as a line ending.
* diagnostic-show-locus.cc (test_escaping_bytes_1): Adapt selftest
since \r will now be interpreted as a line-ending.

gcc/testsuite/ChangeLog:

PR preprocessor/91733
* c-c++-common/pr91733.c: New test.
gcc/diagnostic-show-locus.cc
gcc/input.cc
gcc/testsuite/c-c++-common/pr91733.c [new file with mode: 0644]