diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-02-10 17:08:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-10 17:08:15 +0000 |
commit | e2823b6747b36362387e5b26e8792f06185d7de8 (patch) | |
tree | a1c1a61fd3031416ca3bc600212cd13e51f727b8 /gcc/rust/backend/rust-compile-expr.cc | |
parent | f6ba472caf42db1f5f2f98b73afccf448b36c322 (diff) | |
parent | 1b487d72cd2ba46671f5a1bcc20970f2dad1b759 (diff) | |
download | gcc-e2823b6747b36362387e5b26e8792f06185d7de8.zip gcc-e2823b6747b36362387e5b26e8792f06185d7de8.tar.gz gcc-e2823b6747b36362387e5b26e8792f06185d7de8.tar.bz2 |
Merge #917
917: remove tree addressable context during type checking r=philberty a=philberty
We can reuse more C front-end code c_mark_addressable can be used instead
of trying to track TREE_ADDRESSABLE as part of type-checking. This also
pulls the GCC::Backend::address_expression to be part of the HIRCompileBase
class during code-generation.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index d49a6dc..f65e1fd 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -124,6 +124,13 @@ CompileExpr::visit (HIR::NegationExpr &expr) } void +CompileExpr::visit (HIR::BorrowExpr &expr) +{ + tree main_expr = CompileExpr::Compile (expr.get_expr ().get (), ctx); + translated = address_expression (main_expr, expr.get_locus ()); +} + +void CompileExpr::visit (HIR::DereferenceExpr &expr) { TyTy::BaseType *tyty = nullptr; @@ -973,7 +980,7 @@ CompileExpr::compile_string_literal (const HIR::LiteralExpr &expr, auto base = ctx->get_backend ()->string_constant_expression ( literal_value.as_string ()); - return ctx->get_backend ()->address_expression (base, expr.get_locus ()); + return address_expression (base, expr.get_locus ()); } tree @@ -1006,8 +1013,7 @@ CompileExpr::compile_byte_string_literal (const HIR::LiteralExpr &expr, vals, expr.get_locus ()); - return ctx->get_backend ()->address_expression (constructed, - expr.get_locus ()); + return address_expression (constructed, expr.get_locus ()); } tree @@ -1190,7 +1196,7 @@ HIRCompileBase::resolve_adjustements ( case Resolver::Adjustment::AdjustmentType::IMM_REF: case Resolver::Adjustment::AdjustmentType::MUT_REF: - e = ctx->get_backend ()->address_expression (e, locus); + e = address_expression (e, locus); break; case Resolver::Adjustment::AdjustmentType::DEREF_REF: @@ -1235,8 +1241,7 @@ HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment, != Resolver::Adjustment::AdjustmentType::ERROR; if (needs_borrow) { - adjusted_argument - = ctx->get_backend ()->address_expression (expression, locus); + adjusted_argument = address_expression (expression, locus); } // make the call |