Fix locations within raw strings
commitf9f267593af83bc4b4327294ae00a4b77955f295
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Nov 2016 15:55:26 +0000 (17 15:55 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Nov 2016 15:55:26 +0000 (17 15:55 +0000)
treec847c4257bce9fb3b4aec31453d07ca3f78bf42f
parent9794389d5d5188a140471d3b90df62b2b5b5a308
Fix locations within raw strings

Whilst investigating PR preprocessor/78324 I noticed that the
substring location code currently doesn't handle raw strings
correctly, by not skipping the 'R', opening quote, delimiter
and opening parenthesis.

For example, an attempt to underline chars 4-7 with caret at 6 of
this raw string yields this erroneous output:
   __emit_string_literal_range (R"foo(0123456789)foo",
                                    ~~^~

With the patch, the correct range/caret is printed:

   __emit_string_literal_range (R"foo(0123456789)foo",
                                          ~~^~

gcc/ChangeLog:
* input.c (selftest::test_lexer_string_locations_long_line): New
function.
(selftest::test_lexer_string_locations_raw_string_multiline): New
function.
(selftest::input_c_tests): Call the new functions, via
for_each_line_table_case.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic-test-string-literals-1.c
(test_raw_string_one_liner): New function.
(test_raw_string_multiline): New function.

libcpp/ChangeLog:
* charset.c (cpp_interpret_string_1): Skip locations from
loc_reader when advancing 'p' when handling raw strings.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242552 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/input.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/diagnostic-test-string-literals-1.c
libcpp/ChangeLog
libcpp/charset.c