summaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2019-09-06 12:54:19 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2019-09-06 12:54:19 +0000
commit400b8274e6992c348a822a99ef0c38290aede386 (patch)
tree15ee707e72667a7bc08d9754ef8502189f2cdc9a /libcpp/directives.c
parentaff342a3c1808044323044506e0d034b55310bf1 (diff)
[preprocessor] Popping "" file names
https://gcc.gnu.org/ml/gcc-patches/2019-08/msg02069.html New # semantics for popping to "" name. libcpp/ * directives.c (do_linemarker): Popping to "" name means get the name from the include stack.. From-SVN: r275457
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r--libcpp/directives.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 1c6b31e143b..61f1fef9489 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1088,9 +1088,17 @@ do_linemarker (cpp_reader *pfile)
map = LINEMAPS_LAST_ORDINARY_MAP (line_table);
const line_map_ordinary *from
= linemap_included_from_linemap (line_table, map);
- if (MAIN_FILE_P (map)
- || (from
- && filename_cmp (ORDINARY_MAP_FILE_NAME (from), new_file) != 0))
+
+ if (!from)
+ /* Not nested. */;
+ else if (!new_file[0])
+ /* Leaving to "" means fill in the popped-to name. */
+ new_file = ORDINARY_MAP_FILE_NAME (from);
+ else if (filename_cmp (ORDINARY_MAP_FILE_NAME (from), new_file) != 0)
+ /* It's the wrong name, Grommit! */
+ from = NULL;
+
+ if (!from)
{
cpp_warning (pfile, CPP_W_NONE,
"file \"%s\" linemarker ignored due to "
@@ -1098,6 +1106,7 @@ do_linemarker (cpp_reader *pfile)
return;
}
}
+
/* Compensate for the increment in linemap_add that occurs in
_cpp_do_file_change. We're currently at the start of the line
*following* the #line directive. A separate location_t for this