aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-gcc.cc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2024-11-26 18:05:25 +0000
committerPhilip Herron <philip.herron@embecosm.com>2024-11-27 22:41:32 +0000
commit7bdbcb7564221efc8856b7ce152fe4bd3a0f1f8c (patch)
tree999bc9acb6d3c5beae65d3410a1a42ccd8181dd0 /gcc/rust/rust-gcc.cc
parent2aff74974ec2400dbccc103d8f05d9e14def87b3 (diff)
downloadgcc-7bdbcb7564221efc8856b7ce152fe4bd3a0f1f8c.zip
gcc-7bdbcb7564221efc8856b7ce152fe4bd3a0f1f8c.tar.gz
gcc-7bdbcb7564221efc8856b7ce152fe4bd3a0f1f8c.tar.bz2
gccrs: ensure packed and aligned is applied properly
We cannot apply aligned or packed after layout_type is called you need to set this up first then call it. Fixes Rust-GCC#3260 gcc/rust/ChangeLog: * backend/rust-compile-type.cc (TyTyResolveCompile::visit): call lauout type directly * rust-backend.h (struct_type): add optional layout parameter (union_type): likewise (fill_in_fields): likewise * rust-gcc.cc (struct_type): likewise (union_type): likewise (fill_in_fields): only layout if we required Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r--gcc/rust/rust-gcc.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 6f547ee..0313102 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -592,23 +592,24 @@ function_ptr_type (tree result_type, const std::vector<tree> &parameters,
// Make a struct type.
tree
-struct_type (const std::vector<typed_identifier> &fields)
+struct_type (const std::vector<typed_identifier> &fields, bool layout)
{
- return fill_in_fields (make_node (RECORD_TYPE), fields);
+ return fill_in_fields (make_node (RECORD_TYPE), fields, layout);
}
// Make a union type.
tree
-union_type (const std::vector<typed_identifier> &fields)
+union_type (const std::vector<typed_identifier> &fields, bool layout)
{
- return fill_in_fields (make_node (UNION_TYPE), fields);
+ return fill_in_fields (make_node (UNION_TYPE), fields, layout);
}
// Fill in the fields of a struct or union type.
tree
-fill_in_fields (tree fill, const std::vector<typed_identifier> &fields)
+fill_in_fields (tree fill, const std::vector<typed_identifier> &fields,
+ bool layout)
{
tree field_trees = NULL_TREE;
tree *pp = &field_trees;
@@ -625,7 +626,9 @@ fill_in_fields (tree fill, const std::vector<typed_identifier> &fields)
pp = &DECL_CHAIN (field);
}
TYPE_FIELDS (fill) = field_trees;
- layout_type (fill);
+
+ if (layout)
+ layout_type (fill);
// Because Rust permits converting between named struct types and
// equivalent struct types, for which we use VIEW_CONVERT_EXPR, and