]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR modula2/112946 set expression type checking
authorGaius Mulley <gaiusmod2@gmail.com>
Thu, 11 Jan 2024 00:53:56 +0000 (00:53 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Thu, 11 Jan 2024 00:53:56 +0000 (00:53 +0000)
commit96a9355a3d5b24f010fa6ad0b51bba5cc3f334f1
tree2f4f5ade3a9423aa1410d376a2e3e3b72d51f741
parentbe9b6820a09f9b660eeae187ef3eb967e718232f
PR modula2/112946 set expression type checking

This patch adds type checking for binary set operators.
It also checks the IN operator and improves the := type checking.

gcc/m2/ChangeLog:

PR modula2/112946
* gm2-compiler/M2GenGCC.mod (IsExpressionCompatible): Import.
(ExpressionTypeCompatible): Import.
(CodeStatement): Remove op1, op2, op3 parameters from CodeSetOr,
CodeSetAnd, CodeSetSymmetricDifference, CodeSetLogicalDifference.
(checkArrayElements): Rename op1 to des and op3 to expr.
Use despos and exprpos instead of CurrentQuadToken.
(checkRecordTypes): Rename op1 to des and op2 to expr.
Use virtpos instead of CurrentQuadToken.
(checkIncorrectMeta): Ditto.
(checkBecomes): Rename op1 to des and op3 to expr.
Use virtpos instead of CurrentQuadToken.
(NoWalkProcedure): New procedure stub.
(CheckBinaryExpressionTypes): New procedure function.
(CheckElementSetTypes): New procedure function.
(CodeBinarySet): Re-write.
(FoldBinarySet): Re-write.
(CodeSetOr): Remove parameters op1, op2 and op3.
(CodeSetAnd): Ditto.
(CodeSetLogicalDifference): Ditto.
(CodeSetSymmetricDifference): Ditto.
(CodeIfIn): Call CheckBinaryExpressionTypes and
CheckElementSetTypes.
* gm2-compiler/M2Quads.mod (BuildRotateFunction): Correct
parameters to MakeVirtualTok to reflect parameter block
passed to Rotate.

gcc/testsuite/ChangeLog:

PR modula2/112946
* gm2/pim/fail/badbecomes.mod: New test.
* gm2/pim/fail/badexpression.mod: New test.
* gm2/pim/fail/badexpression2.mod: New test.
* gm2/pim/fail/badifin.mod: New test.
* gm2/pim/pass/goodifin.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-compiler/M2GenGCC.mod
gcc/m2/gm2-compiler/M2Quads.mod
gcc/testsuite/gm2/pim/fail/badbecomes.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/fail/badexpression.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/fail/badexpression2.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/fail/badifin.mod [new file with mode: 0644]
gcc/testsuite/gm2/pim/pass/goodifin.mod [new file with mode: 0644]