summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-14 17:43:07 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-14 17:43:07 +0000
commitb774505566c67b4b2c7ea7d0a77fca74800c230c (patch)
treeb781b90377bc541c8e3d8bcfd552fca41205b0b0 /libcpp
parentd32b1ac21b1c6eb25105e015bf1b5da1a0a853f0 (diff)
downloadgcc-b774505566c67b4b2c7ea7d0a77fca74800c230c.tar.gz
2016-04-14 Basile Starynkevitch <basile@starynkevitch.net>
{{merging with even more of GCC 6, using subversion 1.9 svn merge -r227943:228400 ^/trunk }} [gcc/] 2016-04-14 Basile Starynkevitch <basile@starynkevitch.net> * melt-runtime.h: Use more systematically the melt*ptr_t types. * melt-runtime.cc (meltgc_ppout_gimple_seq) (meltgc_ppout_basicblock): Ditto. * melt/libmelt-ana-gimple.melt: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@234982 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/line-map.c34
2 files changed, 26 insertions, 14 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 3173bf558d1..5cb23d03267 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-21 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ PR c/66415
+ * line-map.c (linemap_position_for_loc_and_offset): Handle the
+ case of long lines encoded in multiple maps.
+
2015-09-07 Marek Polacek <polacek@redhat.com>
* system.h (INTTYPE_MINIMUM): Rewrite to avoid shift warning.
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index d58cad23fdb..3d82e9bfca9 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -688,28 +688,34 @@ linemap_position_for_loc_and_offset (struct line_maps *set,
/* We find the real location and shift it. */
loc = linemap_resolve_location (set, loc, LRK_SPELLING_LOCATION, &map);
/* The new location (loc + offset) should be higher than the first
- location encoded by MAP.
- FIXME: We used to linemap_assert_fails here and in the if below,
- but that led to PR66415. So give up for now. */
- if ((MAP_START_LOCATION (map) >= loc + offset))
+ location encoded by MAP. This can fail if the line information
+ is messed up because of line directives (see PR66415). */
+ if (MAP_START_LOCATION (map) >= loc + offset)
return loc;
+ linenum_type line = SOURCE_LINE (map, loc);
+ unsigned int column = SOURCE_COLUMN (map, loc);
+
/* If MAP is not the last line map of its set, then the new location
(loc + offset) should be less than the first location encoded by
- the next line map of the set. */
- if (map != LINEMAPS_LAST_ORDINARY_MAP (set))
- if ((loc + offset >= MAP_START_LOCATION (&map[1])))
- return loc;
+ the next line map of the set. Otherwise, we try to encode the
+ location in the next map. */
+ while (map != LINEMAPS_LAST_ORDINARY_MAP (set)
+ && loc + offset >= MAP_START_LOCATION (&map[1]))
+ {
+ map = &map[1];
+ /* If the next map starts in a higher line, we cannot encode the
+ location there. */
+ if (line < ORDINARY_MAP_STARTING_LINE_NUMBER (map))
+ return loc;
+ }
- offset += SOURCE_COLUMN (map, loc);
- if (linemap_assert_fails
- (offset < (1u << map->column_bits)))
+ offset += column;
+ if (linemap_assert_fails (offset < (1u << map->column_bits)))
return loc;
source_location r =
- linemap_position_for_line_and_column (map,
- SOURCE_LINE (map, loc),
- offset);
+ linemap_position_for_line_and_column (map, line, offset);
if (linemap_assert_fails (r <= set->highest_location)
|| linemap_assert_fails (map == linemap_lookup (set, r)))
return loc;