aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-11-20 13:35:22 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:32:59 +0100
commitdb17929375470a85584b8aab02ef68edf2616bf9 (patch)
treef4ff316c835baa299ab6db2f8c510ec3b21b6a75 /gcc/rust/backend
parent2d480fe8697463fda0c8ab5c5c363015c9f88aa0 (diff)
downloadgcc-db17929375470a85584b8aab02ef68edf2616bf9.zip
gcc-db17929375470a85584b8aab02ef68edf2616bf9.tar.gz
gcc-db17929375470a85584b8aab02ef68edf2616bf9.tar.bz2
gccrs: Use a reference wrapper to please GCC 4.8
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 <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc13
-rw-r--r--gcc/rust/backend/rust-compile-expr.h8
2 files changed, 11 insertions, 10 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 673acde..05c5226 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -31,6 +31,7 @@
#include "convert.h"
#include "print-tree.h"
#include "rust-system.h"
+#include <functional>
namespace Rust {
namespace Compile {
@@ -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;
}
@@ -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 (
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h
index 0178a93..b8c4220 100644
--- a/gcc/rust/backend/rust-compile-expr.h
+++ b/gcc/rust/backend/rust-compile-expr.h
@@ -96,10 +96,10 @@ protected:
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);