diff options
Diffstat (limited to 'gcc/input.c')
-rw-r--r-- | gcc/input.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/input.c b/gcc/input.c index 0cd212e..82e79be 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -986,10 +986,11 @@ linemap_client_expand_location_to_spelling_point (location_t loc, } -/* If LOCATION is in a system header and if it is a virtual location for - a token coming from the expansion of a macro, unwind it to the - location of the expansion point of the macro. Otherwise, just return - LOCATION. +/* If LOCATION is in a system header and if it is a virtual location + for a token coming from the expansion of a macro, unwind it to + the location of the expansion point of the macro. If the expansion + point is also in a system header return the original LOCATION. + Otherwise, return the location of the expansion point. This is used for instance when we want to emit diagnostics about a token that may be located in a macro that is itself defined in a @@ -1001,11 +1002,13 @@ linemap_client_expand_location_to_spelling_point (location_t loc, location_t expansion_point_location_if_in_system_header (location_t location) { - if (in_system_header_at (location)) - location = linemap_resolve_location (line_table, location, - LRK_MACRO_EXPANSION_POINT, - NULL); - return location; + if (!in_system_header_at (location)) + return location; + + location_t xloc = linemap_resolve_location (line_table, location, + LRK_MACRO_EXPANSION_POINT, + NULL); + return in_system_header_at (xloc) ? location : xloc; } /* If LOCATION is a virtual location for a token coming from the expansion |