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

commit r16-7614-gd394677a349ab57a9453f3e6158f83334b3888c3
Author: Jose E. Marchesi <[email protected]>
Date:   Sat Feb 21 17:12:24 2026 +0100

    a68: fix handling of & in C formal hole symbols
    
    Signed-off-by: Jose E. Marchesi <[email protected]>
    
    gcc/algol68/ChangeLog
    
            * a68-low.cc (a68_make_formal_hole_decl): Get a boolean indicating
            whether the declaration is for the address of the given symbol.
            * a68.h: Update prototype of a68_make_formal_hole_decl.
            * a68-low-holes.cc (a68_wrap_formal_var_hole): Pass a boolean to
            a68_make_formal_hole_decl indicating whether an address is
            required.

Diff:
---
 gcc/algol68/a68-low-holes.cc |  5 +++--
 gcc/algol68/a68-low.cc       | 19 +++++++++++--------
 gcc/algol68/a68.h            |  2 +-
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gcc/algol68/a68-low-holes.cc b/gcc/algol68/a68-low-holes.cc
index a1c5073c3b20..156cbe46f46d 100644
--- a/gcc/algol68/a68-low-holes.cc
+++ b/gcc/algol68/a68-low-holes.cc
@@ -75,8 +75,9 @@ tree
 a68_wrap_formal_var_hole (NODE_T *p)
 {
   gcc_assert (!IS (MOID (p), PROC_SYMBOL));
-  const char *symbol = get_hole_symbol (p, NULL /* addrp */);
-  return a68_make_formal_hole_decl (p, symbol);
+  bool addrp;
+  const char *symbol = get_hole_symbol (p, &addrp);
+  return a68_make_formal_hole_decl (p, symbol, addrp);
 }
 
 /* Build the body for a wrapper to the formal hole in P, which is of a proc
diff --git a/gcc/algol68/a68-low.cc b/gcc/algol68/a68-low.cc
index e4c4355ea88f..09cd5339b686 100644
--- a/gcc/algol68/a68-low.cc
+++ b/gcc/algol68/a68-low.cc
@@ -634,29 +634,32 @@ a68_make_variable_declaration_decl (NODE_T *identifier,
 
 /* Make an extern declaration for a formal hole.
 
+   If ADDRP is true then it is the address of the external symbol we are
+   interested in.  In that case the mode of P shall be a ref.
+   
    Note that this function is not used for formal holes with proc modes, called
    from a68_wrap_formal_var_hole.  See a68_wrap_formal_proc_hole.  */
 
 tree
-a68_make_formal_hole_decl (NODE_T *p, const char *extern_symbol)
+a68_make_formal_hole_decl (NODE_T *p, const char *extern_symbol,
+                          bool addrp)
 {
   gcc_assert (!IS (MOID (p), PROC_SYMBOL));
 
   tree type = CTYPE (MOID (p));
-  const char *sym = (strlen (extern_symbol) > 0 && extern_symbol[0] == '&'
-                    ? extern_symbol + 1
-                    : extern_symbol);
-
   tree decl = build_decl (a68_get_node_location (p),
                          VAR_DECL,
-                         get_identifier (sym),
+                         get_identifier (extern_symbol),
                          type);
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
   DECL_INITIAL (decl) = a68_get_skip_tree (MOID (p));
 
-  if (extern_symbol[0] == '&')
-    decl = fold_build1 (ADDR_EXPR, type, decl);
+  if (addrp)
+    {
+      gcc_assert (IS_REF (MOID (p)));
+      decl = fold_build1 (ADDR_EXPR, type, decl);
+    }
   return decl;
 }
 
diff --git a/gcc/algol68/a68.h b/gcc/algol68/a68.h
index d3cf81d05c71..66088efa3b2a 100644
--- a/gcc/algol68/a68.h
+++ b/gcc/algol68/a68.h
@@ -798,7 +798,7 @@ tree a68_make_variable_declaration_decl (NODE_T 
*identifier, const char *module_
 tree a68_make_proc_identity_declaration_decl (NODE_T *identifier, const char 
*module_name = NULL,
                                              bool indicant = false, bool 
external = false,
                                              const char *extern_symbol = NULL);
-tree a68_make_formal_hole_decl (NODE_T *p, const char *extern_symbol);
+tree a68_make_formal_hole_decl (NODE_T *p, const char *extern_symbol, bool 
addrp);
 tree a68_make_anonymous_routine_decl (MOID_T *mode);
 tree a68_get_skip_tree (MOID_T *m);
 tree a68_get_empty (void);

Reply via email to