diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-03-04 13:46:30 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-03-07 12:06:20 +0000 |
commit | be94ef6e2d7ce29896c3e2861a8506479dfd55b5 (patch) | |
tree | 5aa8c4d1d8f934ec7ecbd39e6d1443dbb0dfc741 /gcc/rust/backend/rust-compile-stmt.h | |
parent | 7a3c935c0f220835c001307944587a84c5af0192 (diff) | |
download | gcc-be94ef6e2d7ce29896c3e2861a8506479dfd55b5.zip gcc-be94ef6e2d7ce29896c3e2861a8506479dfd55b5.tar.gz gcc-be94ef6e2d7ce29896c3e2861a8506479dfd55b5.tar.bz2 |
Change unit-type to be an empty struct so that we do not disregard the
initilizer of variables
Diffstat (limited to 'gcc/rust/backend/rust-compile-stmt.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-stmt.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index 0f69fb0..ad34253 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -81,6 +81,7 @@ public: bool ok = ctx->get_tyctx ()->lookup_type ( stmt.get_init_expr ()->get_mappings ().get_hirid (), &actual); rust_assert (ok); + tree stmt_type = TyTyResolveCompile::compile (ctx, ty); Location lvalue_locus = stmt.get_pattern ()->get_locus (); Location rvalue_locus = stmt.get_init_expr ()->get_locus (); @@ -90,8 +91,14 @@ public: auto fnctx = ctx->peek_fn (); if (ty->is_unit ()) { - // FIXME this feels wrong ctx->add_statement (init); + + auto unit_type_init_expr + = ctx->get_backend ()->constructor_expression (stmt_type, false, {}, + -1, rvalue_locus); + auto s = ctx->get_backend ()->init_statement (fnctx.fndecl, var, + unit_type_init_expr); + ctx->add_statement (s); } else { |