summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog10
-rw-r--r--libcpp/line-map.c19
2 files changed, 28 insertions, 1 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 082291d5648..208e1d52e6f 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,13 @@
+2017-01-10 David Malcolm <dmalcolm@redhat.com>
+
+ PR c++/77949
+ * line-map.c (linemap_position_for_column): When calling
+ linemap_start_line, detect if a new linemap was created with
+ 0 column bits, and bail out early if this is the case.
+ (linemap_position_for_loc_and_offset): Replace overzealous
+ linemap_assert_fails with a simple conditional; use correct
+ bit count.
+
2017-01-07 David Malcolm <dmalcolm@redhat.com>
PR c++/72803
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index b410c00e367..949489eb1a1 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -816,8 +816,22 @@ linemap_position_for_column (struct line_maps *set, unsigned int to_column)
}
else
{
+ /* Otherwise, attempt to start a new line that can hold TO_COLUMN,
+ with some space to spare. This may or may not lead to a new
+ linemap being created. */
line_map_ordinary *map = LINEMAPS_LAST_ORDINARY_MAP (set);
r = linemap_line_start (set, SOURCE_LINE (map, r), to_column + 50);
+ map = LINEMAPS_LAST_ORDINARY_MAP (set);
+ if (map->m_column_and_range_bits == 0)
+ {
+ /* ...then the linemap has column-tracking disabled,
+ presumably due to exceeding either
+ LINE_MAP_MAX_LOCATION_WITH_COLS (overall) or
+ LINE_MAP_MAX_COLUMN_NUMBER (within this line).
+ Return the start of the linemap, which encodes column 0, for
+ the whole line. */
+ return r;
+ }
}
}
line_map_ordinary *map = LINEMAPS_LAST_ORDINARY_MAP (set);
@@ -905,7 +919,10 @@ linemap_position_for_loc_and_offset (struct line_maps *set,
}
column += column_offset;
- if (linemap_assert_fails (column < (1u << map->m_column_and_range_bits)))
+
+ /* Bail out if the column is not representable within the existing
+ linemap. */
+ if (column >= (1u << (map->m_column_and_range_bits - map->m_range_bits)))
return loc;
source_location r =