[COMMITTED 1/4] a68: introduce a68_add_global_decl and a68_global_context

Jose E. Marchesi jemarch@gnu.org
Fri Sep 25 12:07:24 GMT 2026


Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>

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.
---
 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 70e189344d9..f6058fbd357 100644
--- a/gcc/algol68/a68-low-ranges.cc
+++ b/gcc/algol68/a68-low-ranges.cc
@@ -253,6 +253,27 @@ a68_add_stmt (tree exp)
 				  &current_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 00b99075f27..7130cd0948a 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);
 
-- 
2.39.5



More information about the Algol68 mailing list