diff --git a/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H b/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H index c1b40a53924..82ee340798f 100644 --- a/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H +++ b/gcc/testsuite/g++.dg/modules/dashinclude-1_a.H @@ -1,4 +1,3 @@ -// { dg-module-do run } // { dg-additional-options "-fmodule-header" } // { dg-module-cmi {} } diff --git a/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C b/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C index 6e6a33407a4..f257a1d658e 100644 --- a/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C +++ b/gcc/testsuite/g++.dg/modules/dashinclude-1_b.C @@ -6,4 +6,6 @@ int main () return f(); } +#error foo // { dg-error "foo" } + // { dg-final { scan-lang-dump {Translating include to import} module } } diff --git a/libcpp/files.cc b/libcpp/files.cc index 1cbce4947ee..a60fe1fb6ea 100644 --- a/libcpp/files.cc +++ b/libcpp/files.cc @@ -977,8 +977,11 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, include_type type, that. (We also need an extra newline, so this looks like a regular file, which we do that to to make sure we don't fall off the end in the middle of a line. */ - static uchar newlines[] = "\n\n\n"; - cpp_push_buffer (pfile, newlines, 2, true); + if (type != IT_CMDLINE) + { + static uchar newlines[] = "\n\n\n"; + cpp_push_buffer (pfile, newlines, 2, true); + } size_t len = strlen (buf); buf[len] = '\n'; /* See above */ @@ -986,6 +989,9 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, include_type type, = cpp_push_buffer (pfile, reinterpret_cast (buf), len, true); buffer->to_free = buffer->buf; + if (type == IT_CMDLINE) + /* Tell _cpp_pop_buffer to change files. */ + buffer->file = file; file->header_unit = +1; _cpp_mark_file_once_only (pfile, file);