public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Remove unused parameter caller from generating Call expressions
@ 2022-06-08 12:40 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ae085ac7b12809cadaf6bfdb18c34f1a177290c1

commit ae085ac7b12809cadaf6bfdb18c34f1a177290c1
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Thu Apr 28 14:28:27 2022 +0100

    Remove unused parameter caller from generating Call expressions
    
    Within const context the fncontext maybe empty which in turn results in a
    segv for generating const calls which will be evaluated by the const-expr
    code anyway.
    
    Addresses #1130

Diff:
---
 gcc/rust/backend/rust-compile-expr.cc | 27 ++++++++++-----------------
 gcc/rust/rust-backend.h               |  3 +--
 gcc/rust/rust-gcc.cc                  |  5 ++---
 3 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 2128f25f296..edeea8d2fbd 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -497,10 +497,8 @@ CompileExpr::visit (HIR::CallExpr &expr)
 
   // must be a call to a function
   auto fn_address = CompileExpr::Compile (expr.get_fnexpr (), ctx);
-  auto fncontext = ctx->peek_fn ();
-  translated
-    = ctx->get_backend ()->call_expression (fncontext.fndecl, fn_address, args,
-					    nullptr, expr.get_locus ());
+  translated = ctx->get_backend ()->call_expression (fn_address, args, nullptr,
+						     expr.get_locus ());
 }
 
 void
@@ -610,10 +608,8 @@ CompileExpr::visit (HIR::MethodCallExpr &expr)
       args.push_back (rvalue);
     }
 
-  auto fncontext = ctx->peek_fn ();
-  translated
-    = ctx->get_backend ()->call_expression (fncontext.fndecl, fn_expr, args,
-					    nullptr, expr.get_locus ());
+  translated = ctx->get_backend ()->call_expression (fn_expr, args, nullptr,
+						     expr.get_locus ());
 }
 
 tree
@@ -696,8 +692,8 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn,
   tree fn_expr
     = ctx->get_backend ()->var_expression (fn_convert_expr_tmp, expr_locus);
 
-  return ctx->get_backend ()->call_expression (fnctx.fndecl, fn_expr, args,
-					       nullptr, expr_locus);
+  return ctx->get_backend ()->call_expression (fn_expr, args, nullptr,
+					       expr_locus);
 }
 
 tree
@@ -866,9 +862,8 @@ CompileExpr::resolve_operator_overload (
   if (rhs != nullptr)	 // can be null for negation_expr (unary ones)
     args.push_back (rhs);
 
-  auto fncontext = ctx->peek_fn ();
-  return ctx->get_backend ()->call_expression (fncontext.fndecl, fn_expr, args,
-					       nullptr, expr.get_locus ());
+  return ctx->get_backend ()->call_expression (fn_expr, args, nullptr,
+					       expr.get_locus ());
 }
 
 tree
@@ -1289,10 +1284,8 @@ HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment,
     }
 
   // make the call
-  auto fncontext = ctx->peek_fn ();
-  return ctx->get_backend ()->call_expression (fncontext.fndecl, fn_address,
-					       {adjusted_argument}, nullptr,
-					       locus);
+  return ctx->get_backend ()->call_expression (fn_address, {adjusted_argument},
+					       nullptr, locus);
 }
 
 tree
diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h
index 17b7bae6e99..6d631a0365a 100644
--- a/gcc/rust/rust-backend.h
+++ b/gcc/rust/rust-backend.h
@@ -285,8 +285,7 @@ public:
 
   // Create an expression for a call to FN with ARGS, taking place within
   // caller CALLER.
-  virtual tree call_expression (tree caller, tree fn,
-				const std::vector<tree> &args,
+  virtual tree call_expression (tree fn, const std::vector<tree> &args,
 				tree static_chain, Location)
     = 0;
 
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 334e9e50489..445cb0da876 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -250,7 +250,7 @@ public:
 
   tree array_index_expression (tree array, tree index, Location);
 
-  tree call_expression (tree caller, tree fn, const std::vector<tree> &args,
+  tree call_expression (tree fn, const std::vector<tree> &args,
 			tree static_chain, Location);
 
   // Statements.
@@ -1794,8 +1794,7 @@ Gcc_backend::array_index_expression (tree array_tree, tree index_tree,
 
 // Create an expression for a call to FN_EXPR with FN_ARGS.
 tree
-Gcc_backend::call_expression (tree, // containing fcn for call
-			      tree fn, const std::vector<tree> &fn_args,
+Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
 			      tree chain_expr, Location location)
 {
   if (fn == error_mark_node || TREE_TYPE (fn) == error_mark_node)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 12:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:40 [gcc/devel/rust/master] Remove unused parameter caller from generating Call expressions Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).