diff options
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 8 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 3 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 0aaf084..8007c2f 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -417,9 +417,13 @@ public: fields.push_back (std::move (f)); } - Btype *struct_type_record = ctx->get_backend ()->struct_type (fields); + Btype *type_record; + if (type.is_union ()) + type_record = ctx->get_backend ()->union_type (fields); + else + type_record = ctx->get_backend ()->struct_type (fields); Btype *named_struct - = ctx->get_backend ()->named_type (type.get_name (), struct_type_record, + = ctx->get_backend ()->named_type (type.get_name (), type_record, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 2a147ab..4658295 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -80,7 +80,7 @@ public: } translated - = ctx->get_backend ()->constructor_expression (tuple_type, vals, + = ctx->get_backend ()->constructor_expression (tuple_type, vals, -1, expr.get_locus ()); } @@ -595,6 +595,7 @@ public: translated = ctx->get_backend ()->constructor_expression (type, vals, + struct_expr.union_index, struct_expr.get_locus ()); } diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 5ffd11a..aa9aa2d 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -79,7 +79,7 @@ CompileExpr::visit (HIR::CallExpr &expr) }); translated - = ctx->get_backend ()->constructor_expression (type, vals, + = ctx->get_backend ()->constructor_expression (type, vals, -1, expr.get_locus ()); } else |