https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120845

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:a68f416a706bc61bb323773295189c4ea413ffd6

commit r16-2724-ga68f416a706bc61bb323773295189c4ea413ffd6
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Sun Aug 3 18:27:42 2025 +0200

    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  <ja...@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.

Reply via email to