From b7f70cfdb6f7ab369ecca14a99a0064d2a11ddd2 Mon Sep 17 00:00:00 2001 From: Gaius Mulley Date: Thu, 14 Mar 2024 11:23:42 +0000 Subject: PR modula2/114333 set type comparison against a cardinal should cause an error The type checker M2Check.mod needs extending to detect if a set, array or record is in either operand at the end of the cascaded test list. gcc/m2/ChangeLog: PR modula2/114333 * gm2-compiler/M2Check.mod (checkUnbounded): New procedure function. (checkArrayTypeEquivalence): Extend checking to cover unbounded arrays, arrays and constants. (IsTyped): Simplified the expression and corrected a test for IsConstructor. (checkTypeKindViolation): New procedure function. (doCheckPair): Call checkTypeKindViolation. * gm2-compiler/M2GenGCC.mod (CodeStatement): Remove parameters to CodeEqu and CodeNotEqu. (PerformCodeIfEqu): New procedure. (CodeIfEqu): Rewrite. (PerformCodeIfNotEqu): New procedure. (CodeIfNotEqu): Rewrite. * gm2-compiler/M2Quads.mod (BuildRelOpFromBoolean): Correct comment. gcc/testsuite/ChangeLog: PR modula2/114333 * gm2/cse/pass/testcse54.mod: New test. * gm2/iso/run/pass/array9.mod: New test. * gm2/iso/run/pass/strcons3.mod: New test. * gm2/iso/run/pass/strcons4.mod: New test. * gm2/pim/fail/badset1.mod: New test. * gm2/pim/fail/badset2.mod: New test. * gm2/pim/fail/badset3.mod: New test. * gm2/pim/fail/badset4.mod: New test. Signed-off-by: Gaius Mulley --- gcc/testsuite/gm2/pim/fail/badset2.mod | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 gcc/testsuite/gm2/pim/fail/badset2.mod (limited to 'gcc/testsuite/gm2/pim/fail/badset2.mod') diff --git a/gcc/testsuite/gm2/pim/fail/badset2.mod b/gcc/testsuite/gm2/pim/fail/badset2.mod new file mode 100644 index 0000000..b8c798f --- /dev/null +++ b/gcc/testsuite/gm2/pim/fail/badset2.mod @@ -0,0 +1,13 @@ +MODULE badset2 ; + +FROM libc IMPORT printf ; + +VAR + s: SET OF [1..10] ; + c: CARDINAL ; +BEGIN + IF c # s + THEN + printf ("broken\n") + END +END badset2. -- cgit v1.1