https://gcc.gnu.org/g:3781bb37cf83b8a6849c626236e5023b9eb9fe12
commit r17-1535-g3781bb37cf83b8a6849c626236e5023b9eb9fe12 Author: Jose E. Marchesi <[email protected]> Date: Sat Jun 13 18:44:27 2026 +0200 a68: avoid coalescing of stmt_lists in a68_lower_unit_list At it happens, a68_lower_unit_list collects units as members of a stmt_list, lowering them and appending them. Problem is, stmt_lists get coalesced when appended (or prepended) to another stmt_list. One of the units that may lower in a stmt_list are generators, and the coalescing manifests itself when the generators are found in collateral clauses. This patch puts in place a temporary workaround for this, which is to wrap the stmt_list into a NOP_EXPR. This avoid the coalescing, but a less hackish solution will probably consist on changing the way unit_lists get collected instead. Signed-off-by: Jose E. Marchesi <[email protected]> gcc/algol68/ChangeLog * a68-low-generator.cc (a68_low_generator): Wrap the resulting stmt_list into a nop_expr. gcc/testsuite/ChangeLog * algol68/execute/gen-in-constructor-1.a68: New test. * algol68/execute/gen-in-constructor-2.a68: Likewise. Diff: --- gcc/algol68/a68-low-generator.cc | 3 +++ gcc/testsuite/algol68/execute/gen-in-constructor-1.a68 | 7 +++++++ gcc/testsuite/algol68/execute/gen-in-constructor-2.a68 | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/gcc/algol68/a68-low-generator.cc b/gcc/algol68/a68-low-generator.cc index e321b7d5ec28..e619b046a038 100644 --- a/gcc/algol68/a68-low-generator.cc +++ b/gcc/algol68/a68-low-generator.cc @@ -509,6 +509,9 @@ a68_low_generator (NODE_T *declarer, tree_stmt_iterator bounds_iter = tsi_start (bounds); tree gen = gen_mode (mode, &bounds_iter, heap ? a68_lower_malloc : a68_lower_alloca); + /* XXX ugly hack to avoid the resulting stmt_list to be coalesced + on the current stmt_list in a68_lower_unit_list. */ + gen = build1 (NOP_EXPR, TREE_TYPE (gen), gen); return gen; } } diff --git a/gcc/testsuite/algol68/execute/gen-in-constructor-1.a68 b/gcc/testsuite/algol68/execute/gen-in-constructor-1.a68 new file mode 100644 index 000000000000..6cf40f44b755 --- /dev/null +++ b/gcc/testsuite/algol68/execute/gen-in-constructor-1.a68 @@ -0,0 +1,7 @@ +begin mode Foo = struct (ref[]int lala, bool sign); + Foo zero = (heap[3:10]int, true); + assert(sign'zero = true); + assert(UPB lala'zero = 10); + assert(LWB lala'zero = 3); + skip +end diff --git a/gcc/testsuite/algol68/execute/gen-in-constructor-2.a68 b/gcc/testsuite/algol68/execute/gen-in-constructor-2.a68 new file mode 100644 index 000000000000..9e67620c4d21 --- /dev/null +++ b/gcc/testsuite/algol68/execute/gen-in-constructor-2.a68 @@ -0,0 +1,7 @@ +begin mode Foo = struct (bool sign, ref[]int lala); + Foo zero = (false, heap[0:-1]int); + assert(sign'zero = false); + assert(UPB lala'zero = -1); + assert(LWB lala'zero = 0); + skip +end
