Skip to content

Commit ae085ac

Browse files
committed
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
1 parent 1ada076 commit ae085ac

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

gcc/rust/backend/rust-compile-expr.cc

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,8 @@ CompileExpr::visit (HIR::CallExpr &expr)
497497

498498
// must be a call to a function
499499
auto fn_address = CompileExpr::Compile (expr.get_fnexpr (), ctx);
500-
auto fncontext = ctx->peek_fn ();
501-
translated
502-
= ctx->get_backend ()->call_expression (fncontext.fndecl, fn_address, args,
503-
nullptr, expr.get_locus ());
500+
translated = ctx->get_backend ()->call_expression (fn_address, args, nullptr,
501+
expr.get_locus ());
504502
}
505503

506504
void
@@ -610,10 +608,8 @@ CompileExpr::visit (HIR::MethodCallExpr &expr)
610608
args.push_back (rvalue);
611609
}
612610

613-
auto fncontext = ctx->peek_fn ();
614-
translated
615-
= ctx->get_backend ()->call_expression (fncontext.fndecl, fn_expr, args,
616-
nullptr, expr.get_locus ());
611+
translated = ctx->get_backend ()->call_expression (fn_expr, args, nullptr,
612+
expr.get_locus ());
617613
}
618614

619615
tree
@@ -696,8 +692,8 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn,
696692
tree fn_expr
697693
= ctx->get_backend ()->var_expression (fn_convert_expr_tmp, expr_locus);
698694

699-
return ctx->get_backend ()->call_expression (fnctx.fndecl, fn_expr, args,
700-
nullptr, expr_locus);
695+
return ctx->get_backend ()->call_expression (fn_expr, args, nullptr,
696+
expr_locus);
701697
}
702698

703699
tree
@@ -866,9 +862,8 @@ CompileExpr::resolve_operator_overload (
866862
if (rhs != nullptr) // can be null for negation_expr (unary ones)
867863
args.push_back (rhs);
868864

869-
auto fncontext = ctx->peek_fn ();
870-
return ctx->get_backend ()->call_expression (fncontext.fndecl, fn_expr, args,
871-
nullptr, expr.get_locus ());
865+
return ctx->get_backend ()->call_expression (fn_expr, args, nullptr,
866+
expr.get_locus ());
872867
}
873868

874869
tree
@@ -1289,10 +1284,8 @@ HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment,
12891284
}
12901285

12911286
// make the call
1292-
auto fncontext = ctx->peek_fn ();
1293-
return ctx->get_backend ()->call_expression (fncontext.fndecl, fn_address,
1294-
{adjusted_argument}, nullptr,
1295-
locus);
1287+
return ctx->get_backend ()->call_expression (fn_address, {adjusted_argument},
1288+
nullptr, locus);
12961289
}
12971290

12981291
tree

gcc/rust/rust-backend.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ class Backend
285285

286286
// Create an expression for a call to FN with ARGS, taking place within
287287
// caller CALLER.
288-
virtual tree call_expression (tree caller, tree fn,
289-
const std::vector<tree> &args,
288+
virtual tree call_expression (tree fn, const std::vector<tree> &args,
290289
tree static_chain, Location)
291290
= 0;
292291

gcc/rust/rust-gcc.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class Gcc_backend : public Backend
250250

251251
tree array_index_expression (tree array, tree index, Location);
252252

253-
tree call_expression (tree caller, tree fn, const std::vector<tree> &args,
253+
tree call_expression (tree fn, const std::vector<tree> &args,
254254
tree static_chain, Location);
255255

256256
// Statements.
@@ -1794,8 +1794,7 @@ Gcc_backend::array_index_expression (tree array_tree, tree index_tree,
17941794

17951795
// Create an expression for a call to FN_EXPR with FN_ARGS.
17961796
tree
1797-
Gcc_backend::call_expression (tree, // containing fcn for call
1798-
tree fn, const std::vector<tree> &fn_args,
1797+
Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
17991798
tree chain_expr, Location location)
18001799
{
18011800
if (fn == error_mark_node || TREE_TYPE (fn) == error_mark_node)

0 commit comments

Comments
 (0)