aboutsummaryrefslogtreecommitdiff
path: root/libcpp/lex.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-10-20 07:51:40 -0700
committerNathan Sidwell <nathan@acm.org>2020-10-20 08:01:34 -0700
commitdbcc6b1577bedd2bf5879393c862b6c461787503 (patch)
tree7c7367f1c312b308ff6755df41cbeea55c62fbe8 /libcpp/lex.c
parent35f258f4bbba7fa044f90b4f14d1bc942db58089 (diff)
downloadgcc-dbcc6b1577bedd2bf5879393c862b6c461787503.zip
gcc-dbcc6b1577bedd2bf5879393c862b6c461787503.tar.gz
gcc-dbcc6b1577bedd2bf5879393c862b6c461787503.tar.bz2
preprocessor: Further fix for EOF in macro args [PR97471]
My previous attempt at fixing this was incorrect. The problem occurs earlier in that _cpp_lex_direct processes the unwinding EOF needs in collect_args mode. This patch changes it not to do that, in the same way as directive parsing works. Also collect_args shouldn't push_back such fake EOFs, and neither should funlike_invocation_p. libcpp/ * lex.c (_cpp_lex_direct): Do not complete EOF processing when parsing_args. * macro.c (collect_args): Do not unwind fake EOF. (funlike_invocation_p): Do not unwind fake EOF. (cpp_context): Replace abort with gcc_assert. gcc/testsuite/ * gcc.dg/cpp/endif.c: Move to ... * c-c++-common/cpp/endif.c: ... here. * gcc.dg/cpp/endif.h: Move to ... * c-c++-common/cpp/endif.h: ... here. * c-c++-common/cpp/eof-2.c: Adjust diagnostic. * c-c++-common/cpp/eof-3.c: Adjust diagnostic.
Diffstat (limited to 'libcpp/lex.c')
-rw-r--r--libcpp/lex.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 2fe77d1..fb22292 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -2768,7 +2768,10 @@ _cpp_lex_direct (cpp_reader *pfile)
if (!_cpp_get_fresh_line (pfile))
{
result->type = CPP_EOF;
- if (!pfile->state.in_directive)
+ /* Not a real EOF in a directive or arg parsing -- we refuse
+ to advance to the next file now, and will once we're out
+ of those modes. */
+ if (!pfile->state.in_directive && !pfile->state.parsing_args)
{
/* Tell the compiler the line number of the EOF token. */
result->src_loc = pfile->line_table->highest_line;