]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/112893 full type checking between proctype and procedure not implemented
authorGaius Mulley <gaiusmod2@gmail.com>
Sat, 20 Apr 2024 13:35:18 +0000 (14:35 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Sat, 20 Apr 2024 13:35:18 +0000 (14:35 +0100)
commitf9a48fe7032d9894e88d0d121ba6f75b08ea5dcb
tree3ae1fa24d2c2d684382135ed2200d6836017e9fb
parent1690e47e101c1e273b1ee052de21d5214257c13a
PR modula2/112893 full type checking between proctype and procedure not implemented

This patch implements full type checking between proctype and procedures.
The change implements an associated proc type built for each
procedure.  M2Check.mod will request GetProcedureProcType if it encounters
a procedure.  Before this patch a procedure was associated with the type
ADDRESS in the type checking module M2Check.  The
gm2/pim/pass/proccard.mod have been corrected now this assumption has
been removed.

gcc/m2/ChangeLog:

PR modula2/112893
* gm2-compiler/M2Check.mod (GetProcedureProcType): Import.
(getType): Return value using GetProcedureProcType if sym is a
procedure.
* gm2-compiler/M2Range.mod (FoldTypeExpr): Remove quad if
expression is type compatible.
* gm2-compiler/SymbolTable.def (GetProcedureProcType): New
procedure function.
* gm2-compiler/SymbolTable.mod (Procedure): Add ProcedureType.
(MakeProcedure): Initialize ProcedureType.
(PutParam): Call AddProcedureProcTypeParam.
(PutVarParam): Call AddProcedureProcTypeParam.
(AddProcedureProcTypeParam): New procedure.
(GetProcedureProcType): New procedure function.

gcc/testsuite/ChangeLog:

PR modula2/112893
* gm2/pim/pass/another.mod: Correct bug exposed by type checker.
Swap ProcA and ProcB assignments.
* gm2/pim/pass/proccard.mod: Use VAL to convert procedure into a
cardinal.
* gm2/iso/const/fail/castproctype.mod: New test.
* gm2/pim/fail/badproctype.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2Check.mod
gcc/m2/gm2-compiler/M2Range.mod
gcc/m2/gm2-compiler/SymbolTable.def
gcc/m2/gm2-compiler/SymbolTable.mod
gcc/testsuite/gm2/iso/const/fail/castproctype.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/fail/badproctype.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/pass/another.mod
gcc/testsuite/gm2/pim/pass/proccard.mod