From c173c5771008522c13792bf89a27f6c95989dce5 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss <creatorsmithmdt@gmail.com>
Date: Fri, 18 Nov 2022 09:26:42 +1100
Subject: [PATCH 19/56] Revert "Move void_list_node init to common code".
 (8ff2a92a0450243e52d3299a13b30f208bafa7e0)

gcc/ada/ChangeLog:

	* gcc-interface/trans.cc (gigi): Initialize void_list_node.

gcc/c-family/ChangeLog:

	* c-common.cc (c_common_nodes_and_builtins): Initialize void_list_node.
	* c-common.h (build_void_list_node): Re-add.

gcc/c/ChangeLog:

	* c-decl.cc (build_void_list_node): Re-add.

gcc/cp/ChangeLog:

	* decl.cc (cxx_init_decl_processing): No longer inline last build_void_list_node call.
	(build_void_list_node): Re-add.

gcc/d/ChangeLog:

	* d-builtins.cc (d_build_c_type_nodes): Initialize void_list_node.

gcc/fortran/ChangeLog:

	* f95-lang.cc (gfc_init_decl_processing): Initialize void_list_node.

gcc/go/ChangeLog:

	* go-lang.cc (go_langhook_init): Initialize void_list_node.

gcc/jit/ChangeLog:

	* dummy-frontend.cc (jit_langhook_init): Initialize void_list_node.

gcc/lto/ChangeLog:

	* lto-lang.cc (lto_build_c_type_nodes): Initialize void_list_node.

gcc/ChangeLog:

	* tree.cc (build_common_tree_nodes): Do not initialize void_list_node here.
---
 gcc/ada/gcc-interface/trans.cc |  1 +
 gcc/c-family/c-common.cc       |  2 ++
 gcc/c-family/c-common.h        |  1 +
 gcc/c/c-decl.cc                |  8 ++++++++
 gcc/cp/decl.cc                 | 10 +++++++++-
 gcc/d/d-builtins.cc            |  1 +
 gcc/fortran/f95-lang.cc        |  2 ++
 gcc/go/go-lang.cc              |  3 +++
 gcc/jit/dummy-frontend.cc      |  3 +++
 gcc/lto/lto-lang.cc            |  1 +
 gcc/tree.cc                    |  2 --
 11 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 1cd621a9377..da18a4dd49b 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -413,6 +413,7 @@ gigi (Node_Id gnat_root,
   save_gnu_tree (gnat_literal, t, false);
 
   /* Declare the building blocks of function nodes.  */
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
   void_ftype = build_function_type_list (void_type_node, NULL_TREE);
   ptr_void_ftype = build_pointer_type (void_ftype);
 
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 6f1f21bc4c1..fe7bbcbc13b 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -4490,6 +4490,8 @@ c_common_nodes_and_builtins (void)
     TYPE_NAME (void_type_node) = void_name;
   }
 
+  void_list_node = build_void_list_node ();
+
   /* Make a type to be the domain of a few array types
      whose domains don't really matter.
      200 is small enough that it always fits in size_t
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index f9d0d2945a5..52962c0f19f 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -840,6 +840,7 @@ extern tree identifier_global_tag (tree);
 extern bool names_builtin_p (const char *);
 extern tree c_linkage_bindings (tree);
 extern void record_builtin_type (enum rid, const char *, tree);
+extern tree build_void_list_node (void);
 extern void start_fname_decls (void);
 extern void finish_fname_decls (void);
 extern const char *fname_as_string (int);
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 098e475f65d..6d81c37ca38 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -11236,6 +11236,14 @@ record_builtin_type (enum rid rid_index, const char *name, tree type)
     debug_hooks->type_decl (decl, false);
 }
 
+/* Build the void_list_node (void_type_node having been created).  */
+tree
+build_void_list_node (void)
+{
+  tree t = build_tree_list (NULL_TREE, void_type_node);
+  return t;
+}
+
 /* Return a c_parm structure with the given SPECS, ATTRS and DECLARATOR.  */
 
 struct c_parm *
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 544efdc9914..06740d420d9 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -4750,7 +4750,7 @@ cxx_init_decl_processing (void)
   record_unknown_type (init_list_type_node, "init list");
 
   /* Used when parsing to distinguish parameter-lists () and (void).  */
-  explicit_void_list_node = build_tree_list (NULL_TREE, void_type_node);
+  explicit_void_list_node = build_void_list_node ();
 
   {
     /* Make sure we get a unique function type, so we can give
@@ -18659,6 +18659,14 @@ cp_tree_node_structure (union lang_tree_node * t)
     }
 }
 
+/* Build the void_list_node (void_type_node having been created).  */
+tree
+build_void_list_node (void)
+{
+  tree t = build_tree_list (NULL_TREE, void_type_node);
+  return t;
+}
+
 bool
 cp_missing_noreturn_ok_p (tree decl)
 {
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index 51e562a96c1..6533c7e205f 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -892,6 +892,7 @@ static GTY(()) tree signed_size_type_node;
 static void
 d_build_c_type_nodes (void)
 {
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
   string_type_node = build_pointer_type (char_type_node);
   const_string_type_node
     = build_pointer_type (build_qualified_type (char_type_node,
diff --git a/gcc/fortran/f95-lang.cc b/gcc/fortran/f95-lang.cc
index 0d83f3f8b69..8cb4a314aee 100644
--- a/gcc/fortran/f95-lang.cc
+++ b/gcc/fortran/f95-lang.cc
@@ -530,6 +530,8 @@ gfc_init_decl_processing (void)
      only use it for actual characters, not for INTEGER(1).  */
   build_common_tree_nodes (false);
 
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
+
   /* Set up F95 type nodes.  */
   gfc_init_kinds ();
   gfc_init_types ();
diff --git a/gcc/go/go-lang.cc b/gcc/go/go-lang.cc
index 4743370ff66..d519a69e647 100644
--- a/gcc/go/go-lang.cc
+++ b/gcc/go/go-lang.cc
@@ -98,6 +98,9 @@ go_langhook_init (void)
 {
   build_common_tree_nodes (false);
 
+  /* I don't know why this has to be done explicitly.  */
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
+
   /* We must create the gogo IR after calling build_common_tree_nodes
      (because Gogo::define_builtin_function_trees refers indirectly
      to, e.g., unsigned_char_type_node) but before calling
diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc
index 0687567bc88..84ff359bfe3 100644
--- a/gcc/jit/dummy-frontend.cc
+++ b/gcc/jit/dummy-frontend.cc
@@ -594,6 +594,9 @@ jit_langhook_init (void)
 
   build_common_tree_nodes (false);
 
+  /* I don't know why this has to be done explicitly.  */
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
+
   build_common_builtin_nodes ();
 
   /* The default precision for floating point numbers.  This is used
diff --git a/gcc/lto/lto-lang.cc b/gcc/lto/lto-lang.cc
index d36453ba25d..972a0336f75 100644
--- a/gcc/lto/lto-lang.cc
+++ b/gcc/lto/lto-lang.cc
@@ -1239,6 +1239,7 @@ lto_build_c_type_nodes (void)
 {
   gcc_assert (void_type_node);
 
+  void_list_node = build_tree_list (NULL_TREE, void_type_node);
   string_type_node = build_pointer_type (char_type_node);
   const_string_type_node
     = build_pointer_type (build_qualified_type (char_type_node, TYPE_QUAL_CONST));
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 579001be722..0dbac1cb1f4 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -9409,8 +9409,6 @@ build_common_tree_nodes (bool signed_char)
   void_node = make_node (VOID_CST);
   TREE_TYPE (void_node) = void_type_node;
 
-  void_list_node = build_tree_list (NULL_TREE, void_type_node);
-
   null_pointer_node = build_int_cst (build_pointer_type (void_type_node), 0);
   layout_type (TREE_TYPE (null_pointer_node));
 
-- 
2.38.1

