]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
modula2: Add constant aggregate tests
authorGaius Mulley <gaiusmod2@gmail.com>
Fri, 8 Mar 2024 06:26:55 +0000 (06:26 +0000)
committerGaius Mulley <gaiusmod2@gmail.com>
Fri, 8 Mar 2024 06:26:55 +0000 (06:26 +0000)
This patch adds four constant aggregate tests and assignment of
arrays by a constant in two different scopes.

gcc/testsuite/ChangeLog:

* gm2/iso/pass/arrayconst.mod: New test.
* gm2/iso/pass/arrayconst2.mod: New test.
* gm2/iso/pass/arrayconst3.mod: New test.
* gm2/iso/pass/arrayconst4.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/testsuite/gm2/iso/pass/arrayconst.mod [new file with mode: 0644]
gcc/testsuite/gm2/iso/pass/arrayconst2.mod [new file with mode: 0644]
gcc/testsuite/gm2/iso/pass/arrayconst3.mod [new file with mode: 0644]
gcc/testsuite/gm2/iso/pass/arrayconst4.mod [new file with mode: 0644]

diff --git a/gcc/testsuite/gm2/iso/pass/arrayconst.mod b/gcc/testsuite/gm2/iso/pass/arrayconst.mod
new file mode 100644 (file)
index 0000000..05ce4c9
--- /dev/null
@@ -0,0 +1,31 @@
+MODULE arrayconst ;
+
+
+PROCEDURE foo ;
+TYPE
+   array = ARRAY [0..3] OF REAL ;
+CONST
+   value = array {1.0, 2.0, 3.0, 4.0} ;
+VAR
+   r: REAL ;
+BEGIN
+   r := value[1] ;
+END foo ;
+
+
+PROCEDURE bar ;
+TYPE
+   array = ARRAY [0..3] OF REAL ;
+CONST
+   value = array {5.0, 6.0, 7.0, 8.0} ;
+VAR
+   r: REAL ;
+BEGIN
+   r := value[1] ;
+END bar ;
+
+
+BEGIN
+   foo ;
+   bar
+END arrayconst.
diff --git a/gcc/testsuite/gm2/iso/pass/arrayconst2.mod b/gcc/testsuite/gm2/iso/pass/arrayconst2.mod
new file mode 100644 (file)
index 0000000..cee4b14
--- /dev/null
@@ -0,0 +1,31 @@
+MODULE arrayconst ;
+
+
+PROCEDURE foo ;
+TYPE
+   array = ARRAY [0..3] OF REAL ;
+CONST
+   value = array {1.0, 2.0, 3.0, 4.0} ;
+VAR
+   c: array ;
+BEGIN
+   c := value
+END foo ;
+
+
+PROCEDURE bar ;
+TYPE
+   array = ARRAY [0..3] OF REAL ;
+CONST
+   value = array {5.0, 6.0, 7.0, 8.0} ;
+VAR
+   c: array ;
+BEGIN
+   c := value
+END bar ;
+
+
+BEGIN
+   foo ;
+   bar
+END arrayconst.
diff --git a/gcc/testsuite/gm2/iso/pass/arrayconst3.mod b/gcc/testsuite/gm2/iso/pass/arrayconst3.mod
new file mode 100644 (file)
index 0000000..0402e6f
--- /dev/null
@@ -0,0 +1,35 @@
+MODULE arrayconst3 ;
+
+
+PROCEDURE foo ;
+CONST
+   len = 4 ;
+TYPE
+   array = ARRAY [0..len -1] OF REAL ;
+CONST
+   value = array {1.0, 2.0, 3.0, 4.0} ;
+VAR
+   r: REAL ;
+BEGIN
+   r := value[1] ;
+END foo ;
+
+
+PROCEDURE bar ;
+CONST
+   len = 2 ;
+TYPE
+   array = ARRAY [0..len -1] OF REAL ;
+CONST
+   value = array {5.0, 6.0} ;
+VAR
+   r: REAL ;
+BEGIN
+   r := value[1] ;
+END bar ;
+
+
+BEGIN
+   foo ;
+   bar
+END arrayconst3.
diff --git a/gcc/testsuite/gm2/iso/pass/arrayconst4.mod b/gcc/testsuite/gm2/iso/pass/arrayconst4.mod
new file mode 100644 (file)
index 0000000..0b14229
--- /dev/null
@@ -0,0 +1,35 @@
+MODULE arrayconst4 ;
+
+
+PROCEDURE foo ;
+CONST
+   len = 4 ;
+TYPE
+   array = ARRAY [0..len -1] OF REAL ;
+CONST
+   value = array {1.0, 2.0, 3.0, 4.0} ;
+VAR
+   c: array ;
+BEGIN
+   c := value
+END foo ;
+
+
+PROCEDURE bar ;
+CONST
+   len = 2 ;
+TYPE
+   array = ARRAY [0..len -1] OF REAL ;
+CONST
+   value = array {5.0, 6.0} ;
+VAR
+   c: array ;
+BEGIN
+   c := value
+END bar ;
+
+
+BEGIN
+   foo ;
+   bar
+END arrayconst4.