Fix use-after-free lexing unterminated raw strings (PR preprocessor/78811)
commit0ccd6e7a49dd6f2501386034a81c3da9493f6d82
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Dec 2016 18:05:05 +0000 (15 18:05 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Dec 2016 18:05:05 +0000 (15 18:05 +0000)
tree6691b9007e679032843ddb4ba453fa49409bf3d2
parent3eb2dcec8ac53ff1f0020128383ad13de93e84b6
Fix use-after-free lexing unterminated raw strings (PR preprocessor/78811)

gcc/ChangeLog:
PR preprocessor/78680
PR preprocessor/78811
* input.c (struct selftest::lexer_test): Add field
m_implicitly_expect_EOF.
(selftest::lexer_error_sink): New class.
(selftest::lexer_error_sink::s_singleton): New global.
(selftest::lexer_test::lexer_test): Initialize new field
"m_implicitly_expect_EOF".
(selftest::lexer_test::~lexer_test): Conditionalize the
check for the EOF token on the new field.
(selftest::test_lexer_string_locations_raw_string_unterminated):
New function.
(selftest::input_c_tests): Call the new test.

libcpp/ChangeLog:
PR preprocessor/78680
PR preprocessor/78811
* lex.c (_cpp_lex_direct): Only determine the end-location of
the token and build a range for non-reserved start locations.
Do not do it for EOF tokens.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243721 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/input.c
libcpp/ChangeLog
libcpp/lex.c