diff options
author | Jason Merrill <jason@redhat.com> | 2024-11-26 16:19:05 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-11-26 23:53:37 -0500 |
commit | 134dc932e1ceb13519846795c895319f77df3235 (patch) | |
tree | 5ed0da4750a8ed3c5ffeabe0a3df79937ad20d4d /libcpp | |
parent | 5e718a7a789b39ef877e0d66c7a6a85b54eb112f (diff) | |
download | gcc-134dc932e1ceb13519846795c895319f77df3235.zip gcc-134dc932e1ceb13519846795c895319f77df3235.tar.gz gcc-134dc932e1ceb13519846795c895319f77df3235.tar.bz2 |
libcpp: modules and -include again
I enabled include translation to header units in r15-1104-ga29f481bbcaf2b,
but it seems that patch wasn't sufficient, as any diagnostics in the main
source file would show up as coming from the header instead.
Fixed by setting buffer->file for leaving the file transition that my
previous patch made us enter. And don't push a buffer of newlines, in this
case that messes up line numbers instead of aligning them.
libcpp/ChangeLog:
* files.cc (_cpp_stack_file): Handle -include of header unit more
specially.
gcc/testsuite/ChangeLog:
* g++.dg/modules/dashinclude-1_b.C: Add an #error.
* g++.dg/modules/dashinclude-1_a.H: Remove dg-module-do run.
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/files.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libcpp/files.cc b/libcpp/files.cc index 1cbce49..a60fe1f 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<unsigned char *> (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); |