gcc/libcpp
David Malcolm a4553534df linemap_line_start: protect against location_t overflow (PR lto/88147)
PR lto/88147 reports an assertion failure due to a bogus location_t value
when adding a line to a pre-existing line map, when there's a large
difference between the two line numbers.

For some "large differences", this leads to a location_t value that exceeds
LINE_MAP_MAX_LOCATION, in which case linemap_line_start returns 0.  This
isn't ideal, but at least should lead to safe degradation of location
information.

However, if the difference is very large, it's possible for the line
number offset (relative to the start of the map) to be sufficiently large
that overflow occurs when left-shifted by the column-bits, and hence
the check against the LINE_MAP_MAX_LOCATION limit fails, leading to
a seemingly-valid location_t value, but encoding the wrong location.  This
triggers the assertion failure:
  linemap_assert (SOURCE_LINE (map, r) == to_line);

The fix (thanks to Martin) is to check for overflow when determining
whether to reuse an existing map, and to not reuse it if it would occur.

gcc/ChangeLog: David Malcolm  <dmalcolm@redhat.com>
	PR lto/88147
	* input.c (selftest::test_line_offset_overflow): New selftest.
	(selftest::input_c_tests): Call it.

libcpp/ChangeLog: Martin Liska  <mliska@suse.cz>
	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: r268789
2019-02-12 01:09:31 +00:00
..
include Update copyright years. 2019-01-01 13:31:55 +01:00
po * eo.po: Update. 2019-02-06 21:02:28 +00:00
aclocal.m4
ChangeLog linemap_line_start: protect against location_t overflow (PR lto/88147) 2019-02-12 01:09:31 +00:00
ChangeLog.jit
charset.c Update copyright years. 2019-01-01 13:31:55 +01:00
config.in
configure iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS. 2018-11-07 15:41:21 -07:00
configure.ac
directives-only.c Update copyright years. 2019-01-01 13:31:55 +01:00
directives.c re PR preprocessor/88974 (ICE: Segmentation fault (in linemap_resolve_location)) 2019-01-26 11:08:00 +01:00
errors.c Update copyright years. 2019-01-01 13:31:55 +01:00
expr.c re PR preprocessor/88974 (ICE: Segmentation fault (in linemap_resolve_location)) 2019-01-26 11:08:00 +01:00
files.c Update copyright years. 2019-01-01 13:31:55 +01:00
identifiers.c Update copyright years. 2019-01-01 13:31:55 +01:00
init.c Update copyright years. 2019-01-01 13:31:55 +01:00
internal.h re PR preprocessor/88974 (ICE: Segmentation fault (in linemap_resolve_location)) 2019-01-26 11:08:00 +01:00
lex.c Update copyright years. 2019-01-01 13:31:55 +01:00
line-map.c linemap_line_start: protect against location_t overflow (PR lto/88147) 2019-02-12 01:09:31 +00:00
location-example.txt PR preprocessor/83173: Enhance -fdump-internal-locations output 2018-11-27 16:04:31 +00:00
macro.c Update copyright years. 2019-01-01 13:31:55 +01:00
Makefile.in Update copyright years. 2019-01-01 13:31:55 +01:00
makeucnid.c Update copyright years. 2019-01-01 13:31:55 +01:00
mkdeps.c Update copyright years. 2019-01-01 13:31:55 +01:00
pch.c Update copyright years. 2019-01-01 13:31:55 +01:00
symtab.c Update copyright years. 2019-01-01 13:31:55 +01:00
system.h Update copyright years. 2019-01-01 13:31:55 +01:00
traditional.c Update copyright years. 2019-01-01 13:31:55 +01:00
ucnid.h Update copyright years. 2019-01-01 13:31:55 +01:00
ucnid.tab Update copyright years. 2019-01-01 13:31:55 +01:00