Reject fix-it hints for various awkward boundary cases (PR c/82050)
commit011f5d3ea30fc4404ce75deb172d1b3eeab1dcca
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Nov 2017 19:24:35 +0000 (28 19:24 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Nov 2017 19:24:35 +0000 (28 19:24 +0000)
tree573d13446d8c970c3e108f5272ecd2119546e821
parent944ee40d1902385754eb10090eb10e154a22959f
Reject fix-it hints for various awkward boundary cases (PR c/82050)

PR c/82050 reports a failed assertion deep within diagnostic_show_locus's
code for printing fix-it hints.

The root cause is a fix-it hint suggesting a textual replacement,
where the affected column numbers straddle the LINE_MAP_MAX_COLUMN_NUMBER
boundary, so that the start of the range has a column number, but the
end of the range doesn't.

The fix is to verify that the column numbers are sane when adding fix-it
hints to a rich_location, rejecting fix-it hints where they are not.

libcpp/ChangeLog:
PR c/82050
* include/line-map.h (LINE_MAP_MAX_COLUMN_NUMBER): Move here.
* line-map.c (LINE_MAP_MAX_COLUMN_NUMBER): ...from here.
(rich_location::maybe_add_fixit): Reject fix-it hints in which
the start column exceeds the next column.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255214 138bc75d-0d04-0410-961f-82ee72b054a4
libcpp/ChangeLog
libcpp/include/line-map.h
libcpp/line-map.c