diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-08-03 18:27:42 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-08-03 18:27:42 +0200 |
commit | a68f416a706bc61bb323773295189c4ea413ffd6 (patch) | |
tree | 6b6865fb4c0705d7430c2ceddf0c66a67df33a6a /libgo/runtime/go-int-array-to-string.c | |
parent | 5ecbe70d0f34ac9dadefc21c809fb6a2369d1bad (diff) | |
download | gcc-a68f416a706bc61bb323773295189c4ea413ffd6.zip gcc-a68f416a706bc61bb323773295189c4ea413ffd6.tar.gz gcc-a68f416a706bc61bb323773295189c4ea413ffd6.tar.bz2 |
libcpp: Fix up cpp_maybe_module_directive [PR120845]
My changes for "Module Declarations Shouldn’t be Macros" paper broke
the following testcase. The backup handling intentionally tries to
drop CPP_PRAGMA_EOL token if things go wrong, which is desirable for the
case where we haven't committed to the module preprocessing directive
(i.e. changed the first token to the magic one). In that case there is
no preprocessing directive start and so CPP_PRAGMA_EOL would be wrong.
If there is a premature new-line after we've changed the first token though,
we shouldn't drop CPP_PRAGMA_EOL, because otherwise we ICE in the FE.
While clang++ and MSVC accept the testcase, in my reading it is incorrect
at least in the C++23 and newer wordings and I think the changes have been
a DR, https://eel.is/c++draft/cpp.module has no exception for new-lines
and https://eel.is/c++draft/cpp.pre#1.sentence-2 says that new-line (unless
deleted during phase 2 when after backslash) ends the preprocessing
directive.
The patch arranges for eol being set only in the not_module case.
2025-08-03 Jakub Jelinek <jakub@redhat.com>
PR c++/120845
libcpp/
* lex.cc (cpp_maybe_module_directive): Move eol variable declaration
to the start of the function, initialize to false and only set it to
peek->type == CPP_PRAGMA_EOL in the not_module case. Formatting fix.
gcc/testsuite/
* g++.dg/modules/cpp-21.C: New test.
Diffstat (limited to 'libgo/runtime/go-int-array-to-string.c')
0 files changed, 0 insertions, 0 deletions