From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id 1DE0D385802B; Tue, 16 Jan 2024 18:05:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DE0D385802B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705428347; bh=P+e66feMj/ElgWGYnX7dlfqQaLIOL3tGgUtzDZahSgk=; h=From:To:Subject:Date:From; b=Zn8PBAoGpPHrz86PbGHEMOStMTIKosPWkWelAekihrlmwZmcbs0fAVONWMXxcMSKP 1sEp0kd+R158Nu8kARMbXCf4HmZb6cvvvJlCNhL+VoparQBoTogPT/4/k74Wi5pIzC 0N+lI+T52gUq9792rarm51UY7DEzoNVKm63cf5UI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-7901] gccrs: Move Backend::error_variable to Bvariable::error_variable X-Act-Checkin: gcc X-Git-Author: Owen Avery X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 79b52e69569552551abbcb8ee1436c819bce3979 X-Git-Newrev: 77fbe55f8e68a2fbdff00500faec32f85e8c6d74 Message-Id: <20240116180547.1DE0D385802B@sourceware.org> Date: Tue, 16 Jan 2024 18:05:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:77fbe55f8e68a2fbdff00500faec32f85e8c6d74 commit r14-7901-g77fbe55f8e68a2fbdff00500faec32f85e8c6d74 Author: Owen Avery Date: Wed Aug 2 15:51:38 2023 -0400 gccrs: Move Backend::error_variable to Bvariable::error_variable 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 Diff: --- gcc/rust/backend/rust-compile-extern.h | 2 +- gcc/rust/backend/rust-compile-fnparam.cc | 2 +- gcc/rust/rust-backend.h | 7 ------- gcc/rust/rust-gcc.cc | 16 +++++++++++----- gcc/rust/rust-gcc.h | 5 +++++ 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h index 692e4e5fe6c..9fb2086ad2c 100644 --- a/gcc/rust/backend/rust-compile-extern.h +++ b/gcc/rust/backend/rust-compile-extern.h @@ -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); diff --git a/gcc/rust/backend/rust-compile-fnparam.cc b/gcc/rust/backend/rust-compile-fnparam.cc index 1072ae0c07a..fb6049f25d5 100644 --- a/gcc/rust/backend/rust-compile-fnparam.cc +++ b/gcc/rust/backend/rust-compile-fnparam.cc @@ -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 * diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h index 3674591bbd4..e1c22e38a9f 100644 --- a/gcc/rust/rust-backend.h +++ b/gcc/rust/rust-backend.h @@ -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, diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 673ddaaef1c..5f9dbfe4333 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -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; diff --git a/gcc/rust/rust-gcc.h b/gcc/rust/rust-gcc.h index 1a5c1fa33f0..1f251a3149f 100644 --- a/gcc/rust/rust-gcc.h +++ b/gcc/rust/rust-gcc.h @@ -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_;