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

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

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

commit r16-1546-gfba2f08152375e2c1c167ec921a0197e4c07efc6
Author: Gaius Mulley <gaiusm...@gmail.com>
Date:   Tue Jun 17 17:41:21 2025 +0100

    PR modula2/120673: Mutually dependent types crash the compiler

    This patch fixes an ICE which will occur if cyclic dependent types
    are used when declaring a variable.  This patch detects the
    cyclic dependency and issues an error message for each outstanding
    component.

    gcc/m2/ChangeLog:

            PR modula2/120673
            * gm2-compiler/M2GCCDeclare.mod (ErrorDepList): New
            global variable set containing every errant dependency symbol.
            (mystop): Remove.
            (EmitCircularDependancyError): Replace with ...
            (EmitCircularDependencyError): ... this.
            (AssertAllTypesDeclared): Rewrite.
            (DoVariableDeclaration): Ditto.
            (TypeDependentsDeclared): New procedure function.
            (PrepareGCCVarDeclaration): Ditto.
            (DeclareVariable): Remove assert.
            (DeclareLocalVariable): Ditto.
            (Constructor): Initialize ErrorDepList.
            * gm2-compiler/M2MetaError.mod (doErrorScopeProc): Rewrite
            and ensure that a symbol with a module scope does not lookup
            from a definition module.
            * gm2-compiler/P2SymBuild.mod (BuildType): Rewrite so that
            a synonym type is created using the token refering to the name
            on the lhs.

    gcc/testsuite/ChangeLog:

            PR modula2/120673
            * gm2/pim/fail/badmodvar.mod: New test.
            * gm2/pim/fail/cyclictypes.mod: New test.
            * gm2/pim/fail/cyclictypes2.mod: New test.
            * gm2/pim/fail/cyclictypes4.mod: New test.

    Signed-off-by: Gaius Mulley <gaiusm...@gmail.com>

Reply via email to