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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <[email protected]>:

https://gcc.gnu.org/g:5a696df0da45397886341fee4618720384798259

commit r17-5596-g5a696df0da45397886341fee4618720384798259
Author: Gaius Mulley <[email protected]>
Date:   Mon Oct 26 20:46:41 2026 +0000

    PR modula2/127991: Fix tree-dump crash on anonymous constants

    m2decl_DeclareKnownConstant creates an IDENTIFIER_NODE without setting
    its string, even though the constant is intended to be anonymous.  Tree
    dumps treat the nonnull DECL_NAME as printable and dereference its null
    string, causing a crash for anonymous set constants.

    Build the CONST_DECL with a NULL_TREE name instead.  The dumper then
    uses the declaration's generated name.  Add a dump regression test.

    The test case was found by a non-AI automated testing tool.
    The investigation was assisted by OpenAI Codex 5.6 Sol and Claude.

    gcc/m2/ChangeLog:

            PR modula2/127991
            * gm2-gcc/m2decl.cc (m2decl_DeclareKnownConstant): Build the
            anonymous constant declaration without a name.

    gcc/testsuite/ChangeLog:

            PR modula2/127991
            * gm2.dg/dump/pim/pass/anonymousconst.mod: New test.
            * gm2.dg/dump/pim/pass/dg-dump-pim-pass.exp: New test.

            Authored-by: Yongqiang Tian <[email protected]>
    Signed-off-by: Gaius Mulley <[email protected]>

Reply via email to