[COMMITTED] a68: fix wrapping C functions returning void [PR algol68/124322]
Jose E. Marchesi
jemarch@gnu.org
Thu Mar 5 15:29:20 GMT 2026
This patch fixes a68_wrap_formal_proc_hole so it doesn't assume that
wrapped C functions returning void return Algol 68 void values, which
are empty records.
Tested in i686-linux-gnu and x86_64-linux-gnu.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
PR algol68/124322
* a68-low-holes.cc (a68_wrap_formal_proc_hole): Wrap functions
returning void properly.
---
gcc/algol68/a68-low-holes.cc | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/gcc/algol68/a68-low-holes.cc b/gcc/algol68/a68-low-holes.cc
index 156cbe46f46..06c69064993 100644
--- a/gcc/algol68/a68-low-holes.cc
+++ b/gcc/algol68/a68-low-holes.cc
@@ -110,7 +110,7 @@ a68_wrap_formal_proc_hole (NODE_T *p, tree wrapper)
/* Now build the type of the wrapped function. */
tree wrapper_ret_type = TREE_TYPE (TREE_TYPE (wrapper));
- tree wrapped_ret_type = (SUB (m) == M_STRING
+ tree wrapped_ret_type = (SUB (m) == M_STRING || SUB (m) == M_VOID
? void_type_node : wrapper_ret_type);
tree *wrapped_args_types = XALLOCAVEC (tree, wrapped_nargs);
int nwrappedarg = 0;
@@ -227,6 +227,15 @@ a68_wrap_formal_proc_hole (NODE_T *p, tree wrapper)
}
body = a68_pop_range ();
}
+ else if (SUB (m) == M_VOID)
+ {
+ a68_push_range (M_VOID);
+ a68_add_stmt (build_call_vec (TREE_TYPE (wrapped_type),
+ wrapped,
+ wrapped_args));
+ a68_add_stmt (a68_get_empty ());
+ body = a68_pop_range ();
+ }
else
body = build_call_vec (TREE_TYPE (wrapped_type), wrapped, wrapped_args);
}
--
2.39.5
More information about the Algol68
mailing list