diff options
author | Nathan Sidwell <nathan@acm.org> | 2019-09-05 11:23:48 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2019-09-05 11:23:48 +0000 |
commit | 056f95ec951178a110b57e58a2ee434907de2e38 (patch) | |
tree | a8e6ad6be4a477e263294cb8c34feef8df71253e /libcpp/lex.c | |
parent | e7414688f16c4c9db2dacbc31da683887b4ba1bd (diff) | |
download | gcc-056f95ec951178a110b57e58a2ee434907de2e38.zip gcc-056f95ec951178a110b57e58a2ee434907de2e38.tar.gz gcc-056f95ec951178a110b57e58a2ee434907de2e38.tar.bz2 |
[preprocessor/91639] #includes at EOF
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00280.html
libcpp/
PR preprocessor/91639
* directives.c (do_include_common): Tell lexer we're a #include.
* files.c (_cpp_stack_file): Lexer will have always incremented.
* internal.h (struct cpp_context): Extend in_directive's
semantics.
* lex.c (_cpp_lex_direct): Increment line for final \n when lexing
for an ISO #include.
* line-map.c (linemap_line_start): Remember if we overflowed.
gcc/testsuite/
PR preprocessor/91639
* c-c++-common/cpp/pr91639.c: New.
* c-c++-common/cpp/pr91639-one.h: New.
* c-c++-common/cpp/pr91639-two.h: New.
From-SVN: r275402
Diffstat (limited to 'libcpp/lex.c')
-rw-r--r-- | libcpp/lex.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libcpp/lex.c b/libcpp/lex.c index 16ded6e..52e5bce 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -2771,7 +2771,13 @@ _cpp_lex_direct (cpp_reader *pfile) goto skipped_white; case '\n': - if (buffer->cur < buffer->rlimit) + /* Increment the line, unless this is the last line ... */ + if (buffer->cur < buffer->rlimit + /* ... or this is a #include, (where _cpp_stack_file needs to + unwind by one line) ... */ + || (pfile->state.in_directive > 1 + /* ... except traditional-cpp increments this elsewhere. */ + && !CPP_OPTION (pfile, traditional))) CPP_INCREMENT_LINE (pfile, 0); buffer->need_line = true; goto fresh_line; |