public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6710] d: Fix closure fields don't get same alignment as local variable [PR109144] Date: Thu, 16 Mar 2023 11:36:25 +0000 (GMT) [thread overview] Message-ID: <20230316113625.C90213858D35@sourceware.org> (raw) https://gcc.gnu.org/g:46c4be98d1e759a406069487e5dbaad0346e7e7d commit r13-6710-g46c4be98d1e759a406069487e5dbaad0346e7e7d Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Thu Mar 16 01:07:02 2023 +0100 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. Diff: --- gcc/d/d-codegen.cc | 5 +++++ gcc/testsuite/gdc.dg/torture/pr109144.d | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 5a041927ec9..5c6c300ecec 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)) { diff --git a/gcc/testsuite/gdc.dg/torture/pr109144.d b/gcc/testsuite/gdc.dg/torture/pr109144.d new file mode 100644 index 00000000000..32d3af7cd45 --- /dev/null +++ b/gcc/testsuite/gdc.dg/torture/pr109144.d @@ -0,0 +1,9 @@ +// { dg-do run } +// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } +void main() +{ + align(128) byte var; + assert((cast(size_t) &var) % 128 == 0); + var = 73; + assert((() => var)() == 73); +}
reply other threads:[~2023-03-16 11:36 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230316113625.C90213858D35@sourceware.org \ --to=ibuclaw@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).