diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-08-05 10:09:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-05 10:09:20 +0000 |
commit | a39108dea1d091545982fefa88ce3be31b9eedf2 (patch) | |
tree | a6eee23553f90586ccc439bc35c44f3ecb3ee8ac /gcc/rust/backend | |
parent | e77bc10ba13af4e193bbda5f43006d11d9bccb45 (diff) | |
parent | 5d17a8b6b2c086d4df516de06ddacdf88728f6ba (diff) | |
download | gcc-a39108dea1d091545982fefa88ce3be31b9eedf2.zip gcc-a39108dea1d091545982fefa88ce3be31b9eedf2.tar.gz gcc-a39108dea1d091545982fefa88ce3be31b9eedf2.tar.bz2 |
Merge #1431
1431: Incremental refactor for better coercion site support r=philberty a=philberty
This is the major refactor to get our coercion site code closer to Rustc.
It introduced several new pieces most notably a refactor to the autoderef
cycle so this can be reused in method resolution and in coercion sites which
allows us to handle deref coercions. It will eventually allow us to get rid
of our bad implementation in rust-tyty-coercion.h which is just messy now.
Fixes #1198
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-base.cc | 14 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-base.h | 9 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 103 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 28 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-extern.h | 9 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.cc | 10 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-item.cc | 9 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 6 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-stmt.h | 3 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 55 |
10 files changed, 93 insertions, 153 deletions
diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index 28f3941..a640a48 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -411,7 +411,7 @@ HIRCompileBase::mark_addressable (tree exp, Location locus) } tree -HIRCompileBase::address_expression (tree expr, tree ptrtype, Location location) +HIRCompileBase::address_expression (tree expr, Location location) { if (expr == error_mark_node) return error_mark_node; @@ -419,8 +419,16 @@ HIRCompileBase::address_expression (tree expr, tree ptrtype, Location location) if (!mark_addressable (expr, location)) return error_mark_node; - return build_fold_addr_expr_with_type_loc (location.gcc_location (), expr, - ptrtype); + return build_fold_addr_expr_loc (location.gcc_location (), expr); +} + +tree +HIRCompileBase::indirect_expression (tree expr, Location locus) +{ + if (expr == error_mark_node) + return error_mark_node; + + return build_fold_indirect_ref_loc (locus.gcc_location (), expr); } std::vector<Bvariable *> diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h index f993d06..5a0ac8f 100644 --- a/gcc/rust/backend/rust-compile-base.h +++ b/gcc/rust/backend/rust-compile-base.h @@ -40,9 +40,12 @@ protected: protected: Context *get_context () { return ctx; } - tree coercion_site (tree rvalue, const TyTy::BaseType *actual, + tree coercion_site (HirId id, tree rvalue, const TyTy::BaseType *actual, const TyTy::BaseType *expected, Location lvalue_locus, Location rvalue_locus); + tree coercion_site1 (tree rvalue, const TyTy::BaseType *actual, + const TyTy::BaseType *expected, Location lvalue_locus, + Location rvalue_locus); tree coerce_to_dyn_object (tree compiled_ref, const TyTy::BaseType *actual, const TyTy::BaseType *expected, @@ -101,7 +104,9 @@ protected: static void setup_abi_options (tree fndecl, ABI abi); - static tree address_expression (tree expr, tree ptrtype, Location locus); + static tree address_expression (tree expr, Location locus); + + static tree indirect_expression (tree expr, Location locus); static bool mark_addressable (tree, Location); diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 7aa691e..38d10d2 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -134,8 +134,7 @@ CompileExpr::visit (HIR::BorrowExpr &expr) &tyty)) return; - tree ptrtype = TyTyResolveCompile::compile (ctx, tyty); - translated = address_expression (main_expr, ptrtype, expr.get_locus ()); + translated = address_expression (main_expr, expr.get_locus ()); } void @@ -175,10 +174,7 @@ CompileExpr::visit (HIR::DereferenceExpr &expr) return; } - bool known_valid = true; - translated - = ctx->get_backend ()->indirect_expression (expected_type, main_expr, - known_valid, expr.get_locus ()); + translated = indirect_expression (main_expr, expr.get_locus ()); } // Helper for sort_tuple_patterns. @@ -857,8 +853,9 @@ CompileExpr::visit (HIR::CallExpr &expr) Location lvalue_locus = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); Location rvalue_locus = argument->get_locus (); - rvalue = coercion_site (rvalue, actual, expected, lvalue_locus, - rvalue_locus); + rvalue + = coercion_site (argument->get_mappings ().get_hirid (), rvalue, + actual, expected, lvalue_locus, rvalue_locus); // add it to the list arguments.push_back (rvalue); @@ -955,8 +952,8 @@ CompileExpr::visit (HIR::CallExpr &expr) Location lvalue_locus = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); Location rvalue_locus = argument->get_locus (); - rvalue - = coercion_site (rvalue, actual, expected, lvalue_locus, rvalue_locus); + rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue, + actual, expected, lvalue_locus, rvalue_locus); // add it to the list args.push_back (rvalue); @@ -1039,9 +1036,11 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) } // lookup the autoderef mappings + HirId autoderef_mappings_id + = expr.get_receiver ()->get_mappings ().get_hirid (); std::vector<Resolver::Adjustment> *adjustments = nullptr; - ok = ctx->get_tyctx ()->lookup_autoderef_mappings ( - expr.get_mappings ().get_hirid (), &adjustments); + ok = ctx->get_tyctx ()->lookup_autoderef_mappings (autoderef_mappings_id, + &adjustments); rust_assert (ok); // apply adjustments for the fn call @@ -1071,8 +1070,8 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) Location lvalue_locus = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); Location rvalue_locus = argument->get_locus (); - rvalue - = coercion_site (rvalue, actual, expected, lvalue_locus, rvalue_locus); + rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue, + actual, expected, lvalue_locus, rvalue_locus); // add it to the list args.push_back (rvalue); @@ -1111,15 +1110,7 @@ CompileExpr::get_fn_addr_from_dyn (const TyTy::DynamicObjectType *dyn, // get any indirection sorted out if (receiver->get_kind () == TyTy::TypeKind::REF) { - TyTy::ReferenceType *r = static_cast<TyTy::ReferenceType *> (receiver); - auto indirect_ty = r->get_base (); - tree indrect_compiled_tyty - = TyTyResolveCompile::compile (ctx, indirect_ty); - - tree indirect - = ctx->get_backend ()->indirect_expression (indrect_compiled_tyty, - receiver_ref, true, - expr_locus); + tree indirect = indirect_expression (receiver_ref, expr_locus); receiver_ref = indirect; } @@ -1149,17 +1140,8 @@ CompileExpr::get_receiver_from_dyn (const TyTy::DynamicObjectType *dyn, { // get any indirection sorted out if (receiver->get_kind () == TyTy::TypeKind::REF) - { - TyTy::ReferenceType *r = static_cast<TyTy::ReferenceType *> (receiver); - auto indirect_ty = r->get_base (); - tree indrect_compiled_tyty - = TyTyResolveCompile::compile (ctx, indirect_ty); - - tree indirect - = ctx->get_backend ()->indirect_expression (indrect_compiled_tyty, - receiver_ref, true, - expr_locus); + tree indirect = indirect_expression (receiver_ref, expr_locus); receiver_ref = indirect; } @@ -1179,8 +1161,7 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref, tree fn = NULL_TREE; if (ctx->lookup_function_decl (fntype->get_ty_ref (), &fn)) { - return address_expression (fn, build_pointer_type (TREE_TYPE (fn)), - expr_locus); + return address_expression (fn, expr_locus); } // Now we can try and resolve the address since this might be a forward @@ -1307,7 +1288,7 @@ CompileExpr::resolve_operator_overload ( // lookup the autoderef mappings std::vector<Resolver::Adjustment> *adjustments = nullptr; ok = ctx->get_tyctx ()->lookup_autoderef_mappings ( - expr.get_mappings ().get_hirid (), &adjustments); + expr.get_lvalue_mappings ().get_hirid (), &adjustments); rust_assert (ok); // apply adjustments for the fn call @@ -1440,8 +1421,7 @@ CompileExpr::compile_string_literal (const HIR::LiteralExpr &expr, auto base = ctx->get_backend ()->string_constant_expression ( literal_value.as_string ()); - tree data = address_expression (base, build_pointer_type (TREE_TYPE (base)), - expr.get_locus ()); + tree data = address_expression (base, expr.get_locus ()); TyTy::BaseType *usize = nullptr; bool ok = ctx->get_tyctx ()->lookup_builtin ("usize", &usize); @@ -1487,8 +1467,7 @@ CompileExpr::compile_byte_string_literal (const HIR::LiteralExpr &expr, vals, expr.get_locus ()); - return address_expression (constructed, build_pointer_type (array_type), - expr.get_locus ()); + return address_expression (constructed, expr.get_locus ()); } tree @@ -1734,10 +1713,7 @@ HIRCompileBase::resolve_adjustements ( case Resolver::Adjustment::AdjustmentType::MUT_REF: { if (!SLICE_TYPE_P (TREE_TYPE (e))) { - tree ptrtype - = TyTyResolveCompile::compile (ctx, - adjustment.get_expected ()); - e = address_expression (e, ptrtype, locus); + e = address_expression (e, locus); } } break; @@ -1785,10 +1761,7 @@ HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment, != Resolver::Adjustment::AdjustmentType::ERROR; if (needs_borrow) { - adjusted_argument - = address_expression (expression, - build_reference_type (TREE_TYPE (expression)), - locus); + adjusted_argument = address_expression (expression, locus); } // make the call @@ -1800,12 +1773,7 @@ tree HIRCompileBase::resolve_indirection_adjustment ( Resolver::Adjustment &adjustment, tree expression, Location locus) { - tree expected_type - = TyTyResolveCompile::compile (ctx, adjustment.get_expected ()); - - return ctx->get_backend ()->indirect_expression (expected_type, expression, - true, /* known_valid*/ - locus); + return indirect_expression (expression, locus); } tree @@ -1824,9 +1792,7 @@ HIRCompileBase::resolve_unsized_adjustment (Resolver::Adjustment &adjustment, = TyTyResolveCompile::compile (ctx, adjustment.get_expected ()); // make a constructor for this - tree data - = address_expression (expression, - build_reference_type (TREE_TYPE (expression)), locus); + tree data = address_expression (expression, locus); // fetch the size from the domain tree domain = TYPE_DOMAIN (expr_type); @@ -1919,8 +1885,7 @@ CompileExpr::visit (HIR::IdentifierExpr &expr) else if (ctx->lookup_function_decl (ref, &fn)) { TREE_USED (fn) = 1; - translated = address_expression (fn, build_pointer_type (TREE_TYPE (fn)), - expr.get_locus ()); + translated = address_expression (fn, expr.get_locus ()); } else if (ctx->lookup_var_decl (ref, &var)) { @@ -2091,20 +2056,10 @@ CompileExpr::visit (HIR::ArrayIndexExpr &expr) return; } - // lookup the expected type for this expression - TyTy::BaseType *tyty = nullptr; - bool ok - = ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), - &tyty); - rust_assert (ok); - tree expected_type = TyTyResolveCompile::compile (ctx, tyty); - // rust deref always returns a reference from this overload then we can // actually do the indirection translated - = ctx->get_backend ()->indirect_expression (expected_type, - operator_overload_call, - true, expr.get_locus ()); + = indirect_expression (operator_overload_call, expr.get_locus ()); return; } @@ -2118,14 +2073,8 @@ CompileExpr::visit (HIR::ArrayIndexExpr &expr) // do we need to add an indirect reference if (array_expr_ty->get_kind () == TyTy::TypeKind::REF) { - TyTy::ReferenceType *r - = static_cast<TyTy::ReferenceType *> (array_expr_ty); - TyTy::BaseType *tuple_type = r->get_base (); - tree array_tyty = TyTyResolveCompile::compile (ctx, tuple_type); - array_reference - = ctx->get_backend ()->indirect_expression (array_tyty, array_reference, - true, expr.get_locus ()); + = indirect_expression (array_reference, expr.get_locus ()); } translated diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 48a516a..9b8976d 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -53,14 +53,7 @@ public: // do we need to add an indirect reference if (tuple_expr_ty->get_kind () == TyTy::TypeKind::REF) { - TyTy::ReferenceType *r - = static_cast<TyTy::ReferenceType *> (tuple_expr_ty); - TyTy::BaseType *tuple_type = r->get_base (); - tree tuple_tyty = TyTyResolveCompile::compile (ctx, tuple_type); - - tree indirect - = ctx->get_backend ()->indirect_expression (tuple_tyty, receiver_ref, - true, expr.get_locus ()); + tree indirect = indirect_expression (receiver_ref, expr.get_locus ()); receiver_ref = indirect; } @@ -184,9 +177,9 @@ public: expr.get_rhs ()->get_mappings ().get_hirid (), &actual); rust_assert (ok); - rvalue - = coercion_site (rvalue, actual, expected, expr.get_lhs ()->get_locus (), - expr.get_rhs ()->get_locus ()); + rvalue = coercion_site (expr.get_mappings ().get_hirid (), rvalue, actual, + expected, expr.get_lhs ()->get_locus (), + expr.get_rhs ()->get_locus ()); tree assignment = ctx->get_backend ()->assignment_statement (lvalue, rvalue, @@ -442,8 +435,9 @@ public: if (ok) { - rvalue = coercion_site (rvalue, actual, expected, lvalue_locus, - rvalue_locus); + rvalue + = coercion_site (argument->get_mappings ().get_hirid (), rvalue, + actual, expected, lvalue_locus, rvalue_locus); } // add it to the list @@ -476,7 +470,8 @@ public: // compile/torture/struct_base_init_1.rs if (ok) { - rvalue = coercion_site (rvalue, actual, expected, lvalue_locus, + rvalue = coercion_site (argument->get_mappings ().get_hirid (), + rvalue, actual, expected, lvalue_locus, rvalue_locus); } @@ -552,10 +547,7 @@ public: &field_index); rust_assert (ok); - tree adt_tyty = TyTyResolveCompile::compile (ctx, adt); - tree indirect - = ctx->get_backend ()->indirect_expression (adt_tyty, receiver_ref, - true, expr.get_locus ()); + tree indirect = indirect_expression (receiver_ref, expr.get_locus ()); receiver_ref = indirect; } diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h index 4355e4a..45a507e 100644 --- a/gcc/rust/backend/rust-compile-extern.h +++ b/gcc/rust/backend/rust-compile-extern.h @@ -110,10 +110,7 @@ public: if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup, fntype->get_id (), fntype)) { - reference - = address_expression (lookup, build_pointer_type (TREE_TYPE (lookup)), - ref_locus); - + reference = address_expression (lookup, ref_locus); return; } @@ -155,9 +152,7 @@ public: ctx->insert_function_decl (fntype, fndecl); - reference - = address_expression (fndecl, build_pointer_type (TREE_TYPE (fndecl)), - ref_locus); + reference = address_expression (fndecl, ref_locus); } private: diff --git a/gcc/rust/backend/rust-compile-implitem.cc b/gcc/rust/backend/rust-compile-implitem.cc index 735dede..d0f70a7 100644 --- a/gcc/rust/backend/rust-compile-implitem.cc +++ b/gcc/rust/backend/rust-compile-implitem.cc @@ -67,10 +67,8 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func) { ctx->insert_function_decl (fntype, lookup); } - reference - = address_expression (lookup, - build_pointer_type (TREE_TYPE (lookup)), - ref_locus); + + reference = address_expression (lookup, ref_locus); return; } } @@ -96,9 +94,7 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func) func.get_outer_attrs (), func.get_locus (), func.get_block_expr ().get (), canonical_path, fntype, function.has_return_type ()); - reference - = address_expression (fndecl, build_pointer_type (TREE_TYPE (fndecl)), - ref_locus); + reference = address_expression (fndecl, ref_locus); } } // namespace Compile diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc index 1f2e479..ceba51c 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -144,10 +144,7 @@ CompileItem::visit (HIR::Function &function) ctx->insert_function_decl (fntype, lookup); } - reference - = address_expression (lookup, - build_pointer_type (TREE_TYPE (lookup)), - ref_locus); + reference = address_expression (lookup, ref_locus); return; } } @@ -171,9 +168,7 @@ CompileItem::visit (HIR::Function &function) function.get_outer_attrs (), function.get_locus (), function.get_definition ().get (), canonical_path, fntype, function.has_function_return_type ()); - reference - = address_expression (fndecl, build_pointer_type (TREE_TYPE (fndecl)), - ref_locus); + reference = address_expression (fndecl, ref_locus); } void diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index b5bfa3c..8c1b7ef 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -129,16 +129,14 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment, if (ctx->lookup_function_decl (fntype->get_ty_ref (), &fn)) { TREE_USED (fn) = 1; - return address_expression (fn, build_pointer_type (TREE_TYPE (fn)), - expr_locus); + return address_expression (fn, expr_locus); } else if (fntype->get_abi () == ABI::INTRINSIC) { Intrinsics compile (ctx); fn = compile.compile (fntype); TREE_USED (fn) = 1; - return address_expression (fn, build_pointer_type (TREE_TYPE (fn)), - expr_locus); + return address_expression (fn, expr_locus); } } diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index aa17a4a..9bb4b7b 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -87,7 +87,8 @@ public: Location lvalue_locus = stmt.get_pattern ()->get_locus (); Location rvalue_locus = stmt.get_init_expr ()->get_locus (); TyTy::BaseType *expected = ty; - init = coercion_site (init, actual, expected, lvalue_locus, rvalue_locus); + init = coercion_site (stmt.get_mappings ().get_hirid (), init, actual, + expected, lvalue_locus, rvalue_locus); auto fnctx = ctx->peek_fn (); if (ty->is_unit ()) diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 9bcd01c..8a614f2 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -198,10 +198,26 @@ CompileStructExprField::visit (HIR::StructExprFieldIdentifier &field) // Shared methods in compilation tree -HIRCompileBase::coercion_site (tree rvalue, const TyTy::BaseType *rval, +HIRCompileBase::coercion_site (HirId id, tree rvalue, + const TyTy::BaseType *rval, const TyTy::BaseType *lval, Location lvalue_locus, Location rvalue_locus) { + std::vector<Resolver::Adjustment> *adjustments = nullptr; + bool ok = ctx->get_tyctx ()->lookup_autoderef_mappings (id, &adjustments); + if (ok) + { + rvalue = resolve_adjustements (*adjustments, rvalue, rvalue_locus); + } + + return coercion_site1 (rvalue, rval, lval, lvalue_locus, rvalue_locus); +} + +tree +HIRCompileBase::coercion_site1 (tree rvalue, const TyTy::BaseType *rval, + const TyTy::BaseType *lval, + Location lvalue_locus, Location rvalue_locus) +{ if (rvalue == error_mark_node) return error_mark_node; @@ -225,20 +241,14 @@ HIRCompileBase::coercion_site (tree rvalue, const TyTy::BaseType *rval, const TyTy::ReferenceType *act = static_cast<const TyTy::ReferenceType *> (actual); - tree expected_type = TyTyResolveCompile::compile (ctx, act->get_base ()); - tree deref_rvalue - = ctx->get_backend ()->indirect_expression (expected_type, rvalue, - false /*known_valid*/, - rvalue_locus); + tree deref_rvalue = indirect_expression (rvalue, rvalue_locus); tree coerced - = coercion_site (deref_rvalue, act->get_base (), exp->get_base (), - lvalue_locus, rvalue_locus); + = coercion_site1 (deref_rvalue, act->get_base (), exp->get_base (), + lvalue_locus, rvalue_locus); if (exp->is_dyn_object () && SLICE_TYPE_P (TREE_TYPE (coerced))) return coerced; - return address_expression (coerced, - build_reference_type (TREE_TYPE (coerced)), - rvalue_locus); + return address_expression (coerced, rvalue_locus); } else if (expected->get_kind () == TyTy::TypeKind::POINTER) { @@ -258,14 +268,12 @@ HIRCompileBase::coercion_site (tree rvalue, const TyTy::BaseType *rval, = static_cast<const TyTy::ReferenceType *> (expected); TyTy::BaseType *actual_base = nullptr; - tree expected_type = error_mark_node; if (actual->get_kind () == TyTy::TypeKind::REF) { const TyTy::ReferenceType *act = static_cast<const TyTy::ReferenceType *> (actual); actual_base = act->get_base (); - expected_type = TyTyResolveCompile::compile (ctx, act->get_base ()); } else if (actual->get_kind () == TyTy::TypeKind::POINTER) { @@ -273,22 +281,18 @@ HIRCompileBase::coercion_site (tree rvalue, const TyTy::BaseType *rval, = static_cast<const TyTy::PointerType *> (actual); actual_base = act->get_base (); - expected_type = TyTyResolveCompile::compile (ctx, act->get_base ()); } rust_assert (actual_base != nullptr); - tree deref_rvalue - = ctx->get_backend ()->indirect_expression (expected_type, rvalue, - false /*known_valid*/, - rvalue_locus); - tree coerced = coercion_site (deref_rvalue, actual_base, exp->get_base (), - lvalue_locus, rvalue_locus); + tree deref_rvalue = indirect_expression (rvalue, rvalue_locus); + tree coerced + = coercion_site1 (deref_rvalue, actual_base, exp->get_base (), + lvalue_locus, rvalue_locus); + if (exp->is_dyn_object () && SLICE_TYPE_P (TREE_TYPE (coerced))) return coerced; - return address_expression (coerced, - build_pointer_type (TREE_TYPE (coerced)), - rvalue_locus); + return address_expression (coerced, rvalue_locus); } else if (expected->get_kind () == TyTy::TypeKind::ARRAY) { @@ -350,10 +354,7 @@ HIRCompileBase::coerce_to_dyn_object (tree compiled_ref, tree address_of_compiled_ref = null_pointer_node; if (!actual->is_unit ()) - address_of_compiled_ref - = address_expression (compiled_ref, - build_pointer_type (TREE_TYPE (compiled_ref)), - locus); + address_of_compiled_ref = address_expression (compiled_ref, locus); std::vector<tree> vtable_ctor_elems; std::vector<unsigned long> vtable_ctor_idx; |