]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Move Backend::error_variable to Bvariable::error_variable
authorOwen Avery <powerboat9.gamer@gmail.com>
Wed, 2 Aug 2023 19:51:38 +0000 (15:51 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:28 +0000 (19:00 +0100)
gcc/rust/ChangeLog:

* rust-backend.h
(Backend::error_variable): Remove.
(Gcc_backend::error_variable): Move to ...
* rust-gcc.cc
(Bvariable::error_variable): ... here ...
* rust-gcc.h
(Bvariable::error_variable): ... and declare here.
(Gcc_backend::global_variable): Update error_variable call.
(Gcc_backend::local_variable): Likewise.
(Gcc_backend::parameter_variable): Likewise.
(Gcc_backend::static_chain_variable): Likewise.
(Gcc_backend::temporary_variable): Likewise.
* backend/rust-compile-extern.h
(CompileExternItem::visit): Likewise.
* backend/rust-compile-fnparam.cc
(CompileFnParam::CompileFnParam): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/backend/rust-compile-extern.h
gcc/rust/backend/rust-compile-fnparam.cc
gcc/rust/rust-backend.h
gcc/rust/rust-gcc.cc
gcc/rust/rust-gcc.h

index 692e4e5fe6cbfc4ca466682206674dd593b6e41c..9fb2086ad2cc46e50572c662d0024d8d0c7d3135 100644 (file)
@@ -48,7 +48,7 @@ public:
   void visit (HIR::ExternalStaticItem &item) override
   {
     // check if its already been compiled
-    Bvariable *lookup = ctx->get_backend ()->error_variable ();
+    Bvariable *lookup = Bvariable::error_variable ();
     if (ctx->lookup_var_decl (item.get_mappings ().get_hirid (), &lookup))
       {
        reference = ctx->get_backend ()->var_expression (lookup, ref_locus);
index 1072ae0c07ad7a88449be7bc43143dce8c492dbe..fb6049f25d5db329ed2762ba14f922ce396c0a57 100644 (file)
@@ -27,7 +27,7 @@ namespace Compile {
 CompileFnParam::CompileFnParam (Context *ctx, tree fndecl, tree decl_type,
                                location_t locus)
   : HIRCompileBase (ctx), fndecl (fndecl), decl_type (decl_type), locus (locus),
-    compiled_param (ctx->get_backend ()->error_variable ())
+    compiled_param (Bvariable::error_variable ())
 {}
 
 Bvariable *
index 3674591bbd4a2ee5a1526b00ea40229e393bfce5..e1c22e38a9fae1438851165b7e619f983c3c9b71 100644 (file)
@@ -346,11 +346,6 @@ public:
 
   // Variables.
 
-  // Create an error variable.  This is used for cases which should
-  // not occur in a correct program, in order to keep the compilation
-  // going without crashing.
-  virtual Bvariable *error_variable () = 0;
-
   // Create a global variable. NAME is the package-qualified name of
   // the variable.  ASM_NAME is the encoded identifier for the
   // variable, incorporating the package, and made safe for the
@@ -655,8 +650,6 @@ public:
 
   // Variables.
 
-  Bvariable *error_variable () { return new Bvariable (error_mark_node); }
-
   Bvariable *global_variable (const std::string &var_name,
                              const std::string &asm_name, tree type,
                              bool is_external, bool is_hidden,
index 673ddaaef1c69e499083e465ce4ec109cd3741a4..5f9dbfe4333d7297f795e2f7ac18b68fd646a00b 100644 (file)
@@ -77,6 +77,12 @@ Bvariable::get_tree (location_t location) const
   return build_fold_indirect_ref_loc (location, t);
 }
 
+Bvariable *
+Bvariable::error_variable ()
+{
+  return new Bvariable (error_mark_node);
+}
+
 // This file implements the interface between the Rust frontend proper
 // and the gcc IR.  This implements specific instantiations of
 // abstract classes defined by the Rust frontend proper.  The Rust
@@ -2048,7 +2054,7 @@ Gcc_backend::global_variable (const std::string &var_name,
                              bool in_unique_section, location_t location)
 {
   if (type_tree == error_mark_node)
-    return this->error_variable ();
+    return Bvariable::error_variable ();
 
   // The GNU linker does not like dynamic variables with zero size.
   tree orig_type_tree = type_tree;
@@ -2113,7 +2119,7 @@ Gcc_backend::local_variable (tree function, const std::string &name,
                             location_t location)
 {
   if (type_tree == error_mark_node)
-    return this->error_variable ();
+    return Bvariable::error_variable ();
   tree decl = build_decl (location, VAR_DECL, get_identifier_from_string (name),
                          type_tree);
   DECL_CONTEXT (decl) = function;
@@ -2134,7 +2140,7 @@ Gcc_backend::parameter_variable (tree function, const std::string &name,
                                 tree type_tree, location_t location)
 {
   if (type_tree == error_mark_node)
-    return this->error_variable ();
+    return Bvariable::error_variable ();
   tree decl = build_decl (location, PARM_DECL,
                          get_identifier_from_string (name), type_tree);
   DECL_CONTEXT (decl) = function;
@@ -2151,7 +2157,7 @@ Gcc_backend::static_chain_variable (tree fndecl, const std::string &name,
                                    tree type_tree, location_t location)
 {
   if (type_tree == error_mark_node)
-    return this->error_variable ();
+    return Bvariable::error_variable ();
   tree decl = build_decl (location, PARM_DECL,
                          get_identifier_from_string (name), type_tree);
   DECL_CONTEXT (decl) = fndecl;
@@ -2188,7 +2194,7 @@ Gcc_backend::temporary_variable (tree fndecl, tree bind_tree, tree type_tree,
       || fndecl == error_mark_node)
     {
       *pstatement = error_mark_node;
-      return this->error_variable ();
+      return Bvariable::error_variable ();
     }
 
   tree var;
index 1a5c1fa33f010522b18504da97e50f4230d45c1a..1f251a3149f8fd5ee1f86c6b0ccc948aa7f0e444 100644 (file)
@@ -49,6 +49,11 @@ public:
   // Get the actual decl;
   tree get_decl () const { return this->t_; }
 
+  // Create an error variable.  This is used for cases which should
+  // not occur in a correct program, in order to keep the compilation
+  // going without crashing.
+  static Bvariable *error_variable ();
+
 private:
   tree t_;
   tree orig_type_;