aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gm2
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2024-03-14 11:23:42 +0000
committerGaius Mulley <gaiusmod2@gmail.com>2024-03-14 11:23:42 +0000
commitb7f70cfdb6f7ab369ecca14a99a0064d2a11ddd2 (patch)
treeb61a26fb86444cf55c83ab48a79cd7efac603387 /gcc/testsuite/gm2
parentddf852dac2abaca317c10b8323f338123b0585c8 (diff)
downloadgcc-b7f70cfdb6f7ab369ecca14a99a0064d2a11ddd2.zip
gcc-b7f70cfdb6f7ab369ecca14a99a0064d2a11ddd2.tar.gz
gcc-b7f70cfdb6f7ab369ecca14a99a0064d2a11ddd2.tar.bz2
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 <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc/testsuite/gm2')
-rw-r--r--gcc/testsuite/gm2/cse/pass/testcse54.mod7
-rw-r--r--gcc/testsuite/gm2/iso/run/pass/array9.mod28
-rw-r--r--gcc/testsuite/gm2/iso/run/pass/strcons3.mod30
-rw-r--r--gcc/testsuite/gm2/iso/run/pass/strcons4.mod36
-rw-r--r--gcc/testsuite/gm2/pim/fail/badset1.mod13
-rw-r--r--gcc/testsuite/gm2/pim/fail/badset2.mod13
-rw-r--r--gcc/testsuite/gm2/pim/fail/badset3.mod11
-rw-r--r--gcc/testsuite/gm2/pim/fail/badset4.mod11
8 files changed, 149 insertions, 0 deletions
diff --git a/gcc/testsuite/gm2/cse/pass/testcse54.mod b/gcc/testsuite/gm2/cse/pass/testcse54.mod
new file mode 100644
index 0000000..5cc1e64
--- /dev/null
+++ b/gcc/testsuite/gm2/cse/pass/testcse54.mod
@@ -0,0 +1,7 @@
+MODULE testcse54 ;
+
+VAR
+ a: ARRAY [0..10] OF CHAR ;
+BEGIN
+ a := 'hello'
+END testcse54.
diff --git a/gcc/testsuite/gm2/iso/run/pass/array9.mod b/gcc/testsuite/gm2/iso/run/pass/array9.mod
new file mode 100644
index 0000000..dd3304e
--- /dev/null
+++ b/gcc/testsuite/gm2/iso/run/pass/array9.mod
@@ -0,0 +1,28 @@
+(* Copyright (C) 2009 Free Software Foundation, Inc. *)
+(* This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with gm2; see the file COPYING. If not, write to the Free Software
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
+
+MODULE array9 ;
+
+
+PROCEDURE assign (a: ARRAY OF ARRAY OF CARDINAL) ;
+END assign ;
+
+VAR
+ e: ARRAY [1..5] OF ARRAY [0..29] OF CARDINAL ;
+BEGIN
+ assign(e)
+END array9.
diff --git a/gcc/testsuite/gm2/iso/run/pass/strcons3.mod b/gcc/testsuite/gm2/iso/run/pass/strcons3.mod
new file mode 100644
index 0000000..7950e64
--- /dev/null
+++ b/gcc/testsuite/gm2/iso/run/pass/strcons3.mod
@@ -0,0 +1,30 @@
+(* Copyright (C) 2024 Free Software Foundation, Inc. *)
+(* This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with gm2; see the file COPYING. If not, write to the Free Software
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
+
+MODULE strcons3 ;
+
+
+TYPE
+ NameType = ARRAY [0..24] OF CHAR ;
+ PersonType = RECORD
+ name: NameType ;
+ END ;
+VAR
+ person: PersonType ;
+BEGIN
+ person := PersonType{"Blaise Pascal"}
+END strcons3.
diff --git a/gcc/testsuite/gm2/iso/run/pass/strcons4.mod b/gcc/testsuite/gm2/iso/run/pass/strcons4.mod
new file mode 100644
index 0000000..1c0e350
--- /dev/null
+++ b/gcc/testsuite/gm2/iso/run/pass/strcons4.mod
@@ -0,0 +1,36 @@
+(* Copyright (C) 2024 Free Software Foundation, Inc. *)
+(* This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with gm2; see the file COPYING. If not, write to the Free Software
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
+
+MODULE strcons4 ;
+
+
+TYPE
+ NameType = ARRAY [0..24] OF CHAR ;
+ DateType = RECORD
+ year, month, day: CARDINAL ;
+ END ;
+ PersonType = RECORD
+ name: NameType ;
+ DateOfBirth: DateType ;
+ END ;
+VAR
+ date : DateType ;
+ person: PersonType ;
+BEGIN
+ date := DateType{1623, 6, 19} ;
+ person := PersonType{"Blaise Pascal", date} ;
+END strcons4.
diff --git a/gcc/testsuite/gm2/pim/fail/badset1.mod b/gcc/testsuite/gm2/pim/fail/badset1.mod
new file mode 100644
index 0000000..de56fe3
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/fail/badset1.mod
@@ -0,0 +1,13 @@
+MODULE badset1 ;
+
+FROM libc IMPORT printf ;
+
+VAR
+ s: SET OF [1..10] ;
+ c: CARDINAL ;
+BEGIN
+ IF c = s
+ THEN
+ printf ("broken\n")
+ END
+END badset1.
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.
diff --git a/gcc/testsuite/gm2/pim/fail/badset3.mod b/gcc/testsuite/gm2/pim/fail/badset3.mod
new file mode 100644
index 0000000..fcbf177
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/fail/badset3.mod
@@ -0,0 +1,11 @@
+MODULE badset3 ;
+
+
+VAR
+ s10: SET OF [1..10] ;
+ s20: SET OF [1..20] ;
+BEGIN
+ IF s10 = s20
+ THEN
+ END
+END badset3.
diff --git a/gcc/testsuite/gm2/pim/fail/badset4.mod b/gcc/testsuite/gm2/pim/fail/badset4.mod
new file mode 100644
index 0000000..2382e4e
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/fail/badset4.mod
@@ -0,0 +1,11 @@
+MODULE badset4 ;
+
+
+VAR
+ s10: SET OF [1..10] ;
+ s20: SET OF [1..20] ;
+BEGIN
+ IF s10 > s20
+ THEN
+ END
+END badset4.