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 <jemarch@gnu.org> 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 --git a/gcc/algol68/a68-low-generator.cc b/gcc/algol68/a68-low-generator.cc index e321b7d..e619b04 100644 --- a/gcc/algol68/a68-low-generator.cc +++ b/gcc/algol68/a68-low-generator.cc
@@ -509,6 +509,9 @@ 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 0000000..6cf40f4 --- /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 0000000..9e67620 --- /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