diff --git a/gcc/testsuite/g++.dg/modules/pr99072.H b/gcc/testsuite/g++.dg/modules/pr99072.H new file mode 100644 index 00000000000..eda0c07f9e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/pr99072.H @@ -0,0 +1,10 @@ +# 0 "REALNAME" +# 0 "" +# 0 "" +# 0 "" +# 1 "/usr/include/stdc-predef.h" 1 3 4 +# 0 "" 2 +# 1 "REALNAME" + +// { dg-additional-options {-fmodule-header -fpreprocessed -fdump-lang-module-lineno} } +// { dg-final { scan-lang-dump { 4 source file names\n Source file\[0\]=REALNAME\n Source file\[1\]=\n Source file\[2\]=\n Source file\[3\]=/usr/include/stdc-predef.h\n} module } } diff --git a/libcpp/init.c b/libcpp/init.c index 17b0d251cda..68ed2c761b9 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -752,6 +752,23 @@ read_original_filename (cpp_reader *pfile) if (_cpp_handle_directive (pfile, token->flags & PREV_WHITE)) { read_original_directory (pfile); + + auto *penult = &linemap_check_ordinary + (LINEMAPS_LAST_MAP (pfile->line_table, false))[-1]; + if (penult[1].reason == LC_RENAME_VERBATIM) + { + /* Expunge any evidence of the original linemap. */ + pfile->line_table->highest_location + = pfile->line_table->highest_line + = penult[0].start_location; + + penult[1].start_location = penult[0].start_location; + penult[1].reason = penult[0].reason; + penult[0] = penult[1]; + pfile->line_table->info_ordinary.used--; + pfile->line_table->info_ordinary.cache = 0; + } + return true; } }