Yongqiang Tian <[email protected]> writes: > 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. > > PR modula2/127991 > > gcc/m2/ChangeLog: > > * gm2-gcc/m2decl.cc (m2decl_DeclareKnownConstant): Build the > anonymous constant declaration without a name. > > gcc/testsuite/ChangeLog: > > * gm2.dg/dump/pim/pass/anonymousconst.mod: New test. > * gm2.dg/dump/pim/pass/dg-dump-pim-pass.exp: New test. > > Signed-off-by: Yongqiang Tian <[email protected]>
many thanks for the patch, I've tested it (amd64) and looked at it. lgtm regards, Gaius
