aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
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/backend
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/backend')
-rw-r--r--gcc/rust/backend/rust-compile-type.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc
index c6d249e..6c7bae6 100644
--- a/gcc/rust/backend/rust-compile-type.cc
+++ b/gcc/rust/backend/rust-compile-type.cc
@@ -22,6 +22,7 @@
#include "rust-gcc.h"
#include "tree.h"
+#include "stor-layout.h"
namespace Rust {
namespace Compile {
@@ -268,8 +269,8 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
fields.push_back (std::move (f));
}
- type_record = type.is_union () ? Backend::union_type (fields)
- : Backend::struct_type (fields);
+ type_record = type.is_union () ? Backend::union_type (fields, false)
+ : Backend::struct_type (fields, false);
}
else
{
@@ -359,7 +360,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
}
// finally make the union or the enum
- type_record = Backend::union_type (enum_fields);
+ type_record = Backend::union_type (enum_fields, false);
}
// Handle repr options
@@ -381,6 +382,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
SET_TYPE_ALIGN (type_record, repr.align * 8);
TYPE_USER_ALIGN (type_record) = 1;
}
+ layout_type (type_record);
std::string named_struct_str
= type.get_ident ().path.get () + type.subst_as_string ();