From bfda391bdbd38d916e9007d35ed27abdaf7e39af Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 11 Mar 2019 10:37:41 +0100 Subject: Backport r268789 2019-03-11 Martin Liska Backport from mainline 2019-02-11 David Malcolm PR lto/88147 * input.c (selftest::test_line_offset_overflow): New selftest. (selftest::input_c_tests): Call it. 2019-03-11 Martin Liska Backport from mainline 2019-02-11 Martin Liska PR lto/88147 * line-map.c (linemap_line_start): Don't reuse the existing line map if the line offset is sufficiently large to cause overflow when computing location_t values. From-SVN: r269570 --- libcpp/ChangeLog | 10 ++++++++++ libcpp/line-map.c | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'libcpp') diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index afc70cf..e29f66d 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,13 @@ +2019-03-11 Martin Liska + + Backport from mainline + 2019-02-11 Martin Liska + + PR lto/88147 + * line-map.c (linemap_line_start): Don't reuse the existing line + map if the line offset is sufficiently large to cause overflow + when computing location_t values. + 2019-02-22 Release Manager * GCC 8.3.0 released. diff --git a/libcpp/line-map.c b/libcpp/line-map.c index a84084c..42aecd6 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -755,6 +755,10 @@ linemap_line_start (struct line_maps *set, linenum_type to_line, if (line_delta < 0 || last_line != ORDINARY_MAP_STARTING_LINE_NUMBER (map) || SOURCE_COLUMN (map, highest) >= (1U << (column_bits - range_bits)) + || ( /* We can't reuse the map if the line offset is sufficiently + large to cause overflow when computing location_t values. */ + (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map)) + >= (1U << (CHAR_BIT * sizeof (linenum_type) - column_bits))) || range_bits < map->m_range_bits) map = linemap_check_ordinary (const_cast -- cgit v1.1