Skip to content

Commit

Permalink
Use a reference wrapper to please GCC 4.8
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* backend/rust-compile-expr.cc (CompileExpr::visit): Change call.
	(CompileExpr::resolve_operator_overload): Update function arguments.
	* backend/rust-compile-expr.h: Change the function's prototype to use
	a reference wrapper instead of a reference within the optional.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P committed Nov 20, 2024
1 parent bd257b0 commit b41ffb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions gcc/rust/backend/rust-compile-expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "convert.h"
#include "print-tree.h"
#include "rust-system.h"
#include <functional>

namespace Rust {
namespace Compile {
Expand Down Expand Up @@ -152,8 +153,9 @@ CompileExpr::visit (HIR::ArithmeticOrLogicalExpr &expr)
{
auto lang_item_type
= LangItem::OperatorToLangItem (expr.get_expr_type ());
translated = resolve_operator_overload (lang_item_type, expr, lhs, rhs,
expr.get_lhs (), expr.get_rhs ());
translated = resolve_operator_overload (
lang_item_type, expr, lhs, rhs, expr.get_lhs (),
tl::optional<std::reference_wrapper<HIR::Expr>> (expr.get_rhs ()));
return;
}

Expand Down Expand Up @@ -1476,10 +1478,9 @@ CompileExpr::get_receiver_from_dyn (const TyTy::DynamicObjectType *dyn,
}

tree
CompileExpr::resolve_operator_overload (LangItem::Kind lang_item_type,
HIR::OperatorExprMeta expr, tree lhs,
tree rhs, HIR::Expr &lhs_expr,
tl::optional<HIR::Expr &> rhs_expr)
CompileExpr::resolve_operator_overload (
LangItem::Kind lang_item_type, HIR::OperatorExprMeta expr, tree lhs, tree rhs,
HIR::Expr &lhs_expr, tl::optional<std::reference_wrapper<HIR::Expr>> rhs_expr)
{
TyTy::FnType *fntype;
bool is_op_overload = ctx->get_tyctx ()->lookup_operator_overload (
Expand Down
8 changes: 4 additions & 4 deletions gcc/rust/backend/rust-compile-expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ class CompileExpr : private HIRCompileBase, protected HIR::HIRExpressionVisitor
TyTy::BaseType *receiver, TyTy::FnType *fntype,
tree receiver_ref, location_t expr_locus);

tree resolve_operator_overload (LangItem::Kind lang_item_type,
HIR::OperatorExprMeta expr, tree lhs,
tree rhs, HIR::Expr &lhs_expr,
tl::optional<HIR::Expr &> rhs_expr);
tree resolve_operator_overload (
LangItem::Kind lang_item_type, HIR::OperatorExprMeta expr, tree lhs,
tree rhs, HIR::Expr &lhs_expr,
tl::optional<std::reference_wrapper<HIR::Expr>> rhs_expr);

tree compile_bool_literal (const HIR::LiteralExpr &expr,
const TyTy::BaseType *tyty);
Expand Down

0 comments on commit b41ffb2

Please sign in to comment.