[COMMITTED] algol68: selection of multiples
Jose E. Marchesi
jemarch@gnu.org
Sun May 25 15:55:44 GMT 2025
---
gcc/algol68/a68-low-units.cc | 12 ++++++++----
gcc/testsuite/algol68/execute/mcts/stow06.a68 | 2 +-
.../algol68/execute/selection-multiple-1.a68 | 12 ++++++++++++
.../algol68/execute/selection-multiple-2.a68 | 18 ++++++++++++++++++
4 files changed, 39 insertions(+), 5 deletions(-)
create mode 100644 gcc/testsuite/algol68/execute/selection-multiple-1.a68
create mode 100644 gcc/testsuite/algol68/execute/selection-multiple-2.a68
diff --git a/gcc/algol68/a68-low-units.cc b/gcc/algol68/a68-low-units.cc
index 89ca410e261..85a94a8b0ac 100644
--- a/gcc/algol68/a68-low-units.cc
+++ b/gcc/algol68/a68-low-units.cc
@@ -773,9 +773,9 @@ a68_lower_selection (NODE_T *p, LOW_CTX_T ctx)
{
/* This is the selection of a multiple of structs.
- The result is a multiple with same dimensions and dimension bounds
- than the indexed multiple. The elements pointer is made to point to
- the selected field of the first struct. */
+ The result is a multiple with same dimensions, dimension bounds and
+ strides than the indexed multiple. The elements pointer is made to
+ point to the selected field of the first struct. */
MOID_T *result_mode = MOID (p);
if (IS_REF (result_mode))
@@ -796,10 +796,13 @@ a68_lower_selection (NODE_T *p, LOW_CTX_T ctx)
tree size_dim = size_int (dim);
tree lower_bound = a68_multiple_lower_bound (multiple, size_dim);
tree upper_bound = a68_multiple_upper_bound (multiple, size_dim);
+ tree stride = a68_multiple_stride (multiple, size_dim);
a68_add_stmt (a68_multiple_set_lower_bound (selection, size_dim,
lower_bound));
a68_add_stmt (a68_multiple_set_upper_bound (selection, size_dim,
upper_bound));
+ a68_add_stmt (a68_multiple_set_stride (selection, size_dim,
+ stride));
}
/* Now set the elements pointer, which is the elements pointer of the
@@ -864,7 +867,8 @@ a68_lower_selection (NODE_T *p, LOW_CTX_T ctx)
}
/* The selection of a name yields a name. */
- if (IS_REF (secondary_mode))
+ if (IS_REF (MOID (secondary)))
+ /* XXX This may require copying. */
return fold_build1 (ADDR_EXPR, CTYPE (MOID (p)), res);
else
return res;
diff --git a/gcc/testsuite/algol68/execute/mcts/stow06.a68 b/gcc/testsuite/algol68/execute/mcts/stow06.a68
index afd9aaf05af..127914da5e4 100644
--- a/gcc/testsuite/algol68/execute/mcts/stow06.a68
+++ b/gcc/testsuite/algol68/execute/mcts/stow06.a68
@@ -1,7 +1,7 @@
# { dg-options "-fstropping=upper" } #
# Against over-optimization of string comparison. #
BEGIN
- STRING newline = "\n";
+ STRING newline = "'n";
STRING str = "string with step > 1"; STRING ref str:= str;
[1:UPB str] STRUCT(REAL flub, CHAR c) rst;
diff --git a/gcc/testsuite/algol68/execute/selection-multiple-1.a68 b/gcc/testsuite/algol68/execute/selection-multiple-1.a68
new file mode 100644
index 00000000000..1dc67eae28e
--- /dev/null
+++ b/gcc/testsuite/algol68/execute/selection-multiple-1.a68
@@ -0,0 +1,12 @@
+begin [10]struct (int age, string name) persons;
+
+ for i to UPB persons
+ do age of persons[i] := 20 + i;
+ name of persons[i] := "x" * i
+ od;
+
+ for i to UPB name of persons
+ do assert ((age of persons)[i] = 20 + i);
+ assert ((name of persons)[i] = "x" * i)
+ od
+end
diff --git a/gcc/testsuite/algol68/execute/selection-multiple-2.a68 b/gcc/testsuite/algol68/execute/selection-multiple-2.a68
new file mode 100644
index 00000000000..89f848df60b
--- /dev/null
+++ b/gcc/testsuite/algol68/execute/selection-multiple-2.a68
@@ -0,0 +1,18 @@
+begin [10,5]struct (int age, string name) persons;
+
+ for i to 1 UPB persons
+ do for j to 2 UPB persons
+ do age of persons[i,j] := 20 + i + j;
+ name of persons[i,j] := "x" * (i + j)
+ od
+ od;
+
+ assert (1 UPB name of persons = 10);
+ assert (2 UPB name of persons = 5);
+ for i to 1 UPB name of persons
+ do for j to 2 UPB name of persons
+ do assert ((age of persons)[i,j] = 20 + i + j);
+ assert ((name of persons)[i,j] = "x" * (i + j))
+ od
+ od
+end
--
2.30.2
More information about the Algol68
mailing list