https://gcc.gnu.org/g:d9884aac17cbf942fd980fbf3bfae300eb7cb2a9
commit r17-4651-gd9884aac17cbf942fd980fbf3bfae300eb7cb2a9 Author: Jose E. Marchesi <[email protected]> Date: Wed Sep 23 10:44:35 2026 +0200 a68: introduce a68_add_global_decl and a68_global_context Signed-off-by: Jose E. Marchesi <[email protected]> gcc/algol68/ChangeLog * a68.h: Add prototypes for a68_add_global_decl and a68_global_context. * a68-low-ranges.cc (a68_add_global_decl): New function. (a68_global_context): Likewise. Diff: --- gcc/algol68/a68-low-ranges.cc | 29 +++++++++++++++++++++++++++++ gcc/algol68/a68.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/gcc/algol68/a68-low-ranges.cc b/gcc/algol68/a68-low-ranges.cc index 70e189344d97..f6058fbd357d 100644 --- a/gcc/algol68/a68-low-ranges.cc +++ b/gcc/algol68/a68-low-ranges.cc @@ -253,6 +253,27 @@ a68_add_stmt (tree exp) ¤t_range->stmt_list); } +/* Add a new declaration to the global range. */ + +void +a68_add_global_decl (tree decl) +{ + gcc_assert (current_range != NULL); + + tree n = global_range->names; + while (n != decl && n != NULL) + n = TREE_CHAIN (n); + if (n != decl) + { + if (decl != current_function_decl) + DECL_CONTEXT (decl) = global_range->context; + /* Note this list needs to be in reverse order for compatibility with + GCC. */ + TREE_CHAIN (decl) = global_range->names; + global_range->names = decl; + } +} + /* Add a new declaration to the current range. */ void @@ -332,6 +353,14 @@ a68_range_context (void) return current_range->context; } +/* Get the global context. */ + +tree +a68_global_context (void) +{ + return global_range->context; +} + /* Get the list of declarations in the current range. */ tree diff --git a/gcc/algol68/a68.h b/gcc/algol68/a68.h index 00b99075f272..7130cd0948ad 100644 --- a/gcc/algol68/a68.h +++ b/gcc/algol68/a68.h @@ -748,10 +748,12 @@ void a68_push_serial_clause_range (MOID_T *clause_mode, bool save_restore_stack = false); tree a68_pop_serial_clause_range (void); void a68_add_stmt (tree exp); +void a68_add_global_decl (tree decl); void a68_add_decl (tree decl); void a68_add_decl_expr (tree decl_expr); void a68_add_completer (void); tree a68_range_context (void); +tree a68_global_context (void); tree a68_range_names (void); tree a68_range_stmt_list (void);
