From 6df8934f6ad73b97181fc0a997b3eb8cd799b6a0 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 28 Nov 2017 19:24:35 +0000 Subject: 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. From-SVN: r255214 --- libcpp/include/line-map.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libcpp/include') diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 8b7e5dc..1151484 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -280,6 +280,11 @@ enum lc_reason worked example in libcpp/location-example.txt. */ typedef unsigned int source_location; +/* Do not track column numbers higher than this one. As a result, the + range of column_bits is [12, 18] (or 0 if column numbers are + disabled). */ +const unsigned int LINE_MAP_MAX_COLUMN_NUMBER = (1U << 12); + /* Do not pack ranges if locations get higher than this. If you change this, update: gcc.dg/plugin/location-overflow-test-*.c. */ -- cgit v1.1