Skip to content

Commit

Permalink
PR modula2/112946 set expression type checking
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Gaius Mulley committed Jan 11, 2024
1 parent be9b682 commit 96a9355
Show file tree
Hide file tree
Showing 7 changed files with 405 additions and 159 deletions.

0 comments on commit 96a9355

Please sign in to comment.