https://gcc.gnu.org/g:ee8ca6c927ec949a5983f1b9b9a896b5b3044454

commit r16-7917-gee8ca6c927ec949a5983f1b9b9a896b5b3044454
Author: Jose E. Marchesi <[email protected]>
Date:   Thu Mar 5 15:31:18 2026 +0100

    a68: fix wrapping C functions returning void [PR algol68/124322]
    
    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 <[email protected]>
    
    gcc/algol68/ChangeLog
    
            PR algol68/124322
            * a68-low-holes.cc (a68_wrap_formal_proc_hole): Wrap functions
            returning void properly.

Diff:
---
 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 156cbe46f46d..06c690649939 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);
   }

Reply via email to