aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/module.cc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2021-04-13 11:57:55 +0200
committerEric Botcazou <ebotcazou@adacore.com>2021-04-13 11:57:55 +0200
commit1174314811af52779497462f26d21ea0038d1a85 (patch)
treeaad313e4824374849b6d2af98aaa348318d7380f /gcc/cp/module.cc
parent89e95ad2e7679322b2f5ee9070ff2721d5ca1d6d (diff)
downloadgcc-1174314811af52779497462f26d21ea0038d1a85.zip
gcc-1174314811af52779497462f26d21ea0038d1a85.tar.gz
gcc-1174314811af52779497462f26d21ea0038d1a85.tar.bz2
Fix thinko in libcpp preparation patch for modules
The problem is that the new IS_MACRO_LOC macro: inline bool IS_MACRO_LOC (location_t loc) { return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc); } is not fully correct since the position of the macro lines is not fixed: /* Returns the lowest location [of a token resulting from macro expansion] encoded in this line table. */ inline location_t LINEMAPS_MACRO_LOWEST_LOCATION (const line_maps *set) { return LINEMAPS_MACRO_USED (set) ? MAP_START_LOCATION (LINEMAPS_LAST_MACRO_MAP (set)) : MAX_LOCATION_T + 1; } In Ada, LINEMAPS_MACRO_USED is false so LINEMAPS_MACRO_LOWEST_LOCATION is MAX_LOCATION_T + 1, but IS_MACRO_LOC nevertheless returns true for anything in the range [LINE_MAP_MAX_LOCATION; MAX_LOCATION_T], thus yielding an ICE in linemap_macro_map_lookup for very large files. libcpp/ * include/line-map.h (IS_MACRO_LOC): Delete. * line-map.c (linemap_location_from_macro_expansion_p): Test LINEMAPS_MACRO_LOWEST_LOCATION of the linemap. gcc/cp/ * module.cc (ordinary_loc_of): Test LINEMAPS_MACRO_LOWEST_LOCATION of the linemap. (module_state::write_location): Likewise.
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r--gcc/cp/module.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index c80c7bc..ab8b1f1 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -13709,7 +13709,7 @@ ordinary_loc_of (line_maps *lmaps, location_t from)
{
if (IS_ADHOC_LOC (from))
from = get_location_from_adhoc_loc (lmaps, from);
- if (IS_MACRO_LOC (from))
+ if (from >= LINEMAPS_MACRO_LOWEST_LOCATION (lmaps))
{
/* Find the ordinary location nearest FROM. */
const line_map *map = linemap_lookup (lmaps, from);
@@ -15554,7 +15554,7 @@ module_state::write_location (bytes_out &sec, location_t loc)
write_location (sec, range.m_start);
write_location (sec, range.m_finish);
}
- else if (IS_MACRO_LOC (loc))
+ else if (loc >= LINEMAPS_MACRO_LOWEST_LOCATION (line_table))
{
if (const loc_spans::span *span = spans.macro (loc))
{