aboutsummaryrefslogtreecommitdiff
path: root/gcc/d
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2023-03-16 01:07:02 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2023-03-16 12:06:11 +0100
commit46c4be98d1e759a406069487e5dbaad0346e7e7d (patch)
tree9e524f4c20331799b404f8c1707e5263c271aebe /gcc/d
parent63b25b8012400bed0c35d6e39549168ae131aefc (diff)
downloadgcc-46c4be98d1e759a406069487e5dbaad0346e7e7d.zip
gcc-46c4be98d1e759a406069487e5dbaad0346e7e7d.tar.gz
gcc-46c4be98d1e759a406069487e5dbaad0346e7e7d.tar.bz2
d: Fix closure fields don't get same alignment as local variable [PR109144]
Local variables with both non-local references and explicit alignment did not propagate their alignment to either the closure field or closure frame type, resulting in the closure being misaligned. This is now correctly set-up when building the frame type. PR d/109144 gcc/d/ChangeLog: * d-codegen.cc (build_frame_type): Set frame field and type alignment. gcc/testsuite/ChangeLog: * gdc.dg/torture/pr109144.d: New test.
Diffstat (limited to 'gcc/d')
-rw-r--r--gcc/d/d-codegen.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 5a04192..5c6c300 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -2706,6 +2706,11 @@ build_frame_type (tree ffi, FuncDeclaration *fd)
TREE_ADDRESSABLE (field) = TREE_ADDRESSABLE (vsym);
DECL_NONADDRESSABLE_P (field) = !TREE_ADDRESSABLE (vsym);
TREE_THIS_VOLATILE (field) = TREE_THIS_VOLATILE (vsym);
+ SET_DECL_ALIGN (field, DECL_ALIGN (vsym));
+
+ /* Update alignment for frame record type. */
+ if (TYPE_ALIGN (frame_rec_type) < DECL_ALIGN (field))
+ SET_TYPE_ALIGN (frame_rec_type, DECL_ALIGN (field));
if (DECL_LANG_NRVO (vsym))
{