diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-07-23 16:12:08 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-07-26 14:13:35 +0100 |
commit | 6822e1b3e497703bd5a6691d44814198221d9584 (patch) | |
tree | bf44a7ef29bdaa802b1bdb2ffb92656fd4d9c345 /gcc/rust/backend/rust-compile-expr.h | |
parent | 75750d58cefe00aaf0a9512286cd47115940a469 (diff) | |
download | gcc-6822e1b3e497703bd5a6691d44814198221d9584.zip gcc-6822e1b3e497703bd5a6691d44814198221d9584.tar.gz gcc-6822e1b3e497703bd5a6691d44814198221d9584.tar.bz2 |
Add GENERIC support for TypeCastExpr to call fold_convert_loc
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index fa6a539..2a147ab 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -417,6 +417,24 @@ public: = ctx->get_backend ()->negation_expression (op, negated_expr, location); } + void visit (HIR::TypeCastExpr &expr) override + { + TyTy::BaseType *tyty_to_cast_to = nullptr; + if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), + &tyty_to_cast_to)) + { + translated = ctx->get_backend ()->error_expression (); + return; + } + + auto type_to_cast_to = TyTyResolveCompile::compile (ctx, tyty_to_cast_to); + auto casted_expr + = CompileExpr::Compile (expr.get_casted_expr ().get (), ctx); + translated + = ctx->get_backend ()->convert_expression (type_to_cast_to, casted_expr, + expr.get_locus ()); + } + void visit (HIR::IfExpr &expr) override { auto stmt = CompileConditionalBlocks::compile (&expr, ctx, nullptr); |