]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/120673: Mutually dependent types crash the compiler
authorGaius Mulley <gaiusmod2@gmail.com>
Tue, 17 Jun 2025 16:41:21 +0000 (17:41 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Tue, 17 Jun 2025 16:41:21 +0000 (17:41 +0100)
commitfba2f08152375e2c1c167ec921a0197e4c07efc6
tree8b047bdf131674e5d0fce7becf304fda64390ff2
parent260252e7dc07bd6e201c76c24d858efaea4a1a78
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 <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2GCCDeclare.mod
gcc/m2/gm2-compiler/M2MetaError.mod
gcc/m2/gm2-compiler/P2SymBuild.mod
gcc/testsuite/gm2/pim/fail/badmodvar.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/fail/cyclictypes.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/fail/cyclictypes2.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/fail/cyclictypes4.mod [new file with mode: 0644]