public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9993] c++: alignment of local typedef in template [PR65211] Date: Fri, 13 May 2022 16:28:14 +0000 (GMT) [thread overview] Message-ID: <20220513162814.27BEF3857023@sourceware.org> (raw) https://gcc.gnu.org/g:e60f7127b3282e0201a1bba8ff550dc3c3fdbe61 commit r11-9993-ge60f7127b3282e0201a1bba8ff550dc3c3fdbe61 Author: Jason Merrill <jason@redhat.com> Date: Wed Apr 13 21:56:03 2022 -0400 c++: alignment of local typedef in template [PR65211] Because common_handle_aligned_attribute only applies the alignment to the TREE_TYPE of a typedef, not the DECL_ORIGINAL_TYPE, we need to copy it explicitly in tsubst. PR c++/65211 gcc/cp/ChangeLog: * pt.c (tsubst_decl) [TYPE_DECL]: Copy TYPE_ALIGN. gcc/testsuite/ChangeLog: * g++.target/i386/vec-tmpl1.C: New test. Diff: --- gcc/cp/pt.c | 6 ++++++ gcc/testsuite/g++.target/i386/vec-tmpl1.C | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ba505820c6a..f5154418594 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15117,6 +15117,12 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) { DECL_ORIGINAL_TYPE (r) = NULL_TREE; set_underlying_type (r); + + /* common_handle_aligned_attribute doesn't apply the alignment + to DECL_ORIGINAL_TYPE. */ + if (TYPE_USER_ALIGN (TREE_TYPE (t))) + TREE_TYPE (r) = build_aligned_type (TREE_TYPE (r), + TYPE_ALIGN (TREE_TYPE (t))); } layout_decl (r, 0); diff --git a/gcc/testsuite/g++.target/i386/vec-tmpl1.C b/gcc/testsuite/g++.target/i386/vec-tmpl1.C new file mode 100644 index 00000000000..e0865e3515b --- /dev/null +++ b/gcc/testsuite/g++.target/i386/vec-tmpl1.C @@ -0,0 +1,17 @@ +// PR c++/65211 +// { dg-additional-options "-Wno-psabi" } +// { dg-final { scan-assembler-not "movdqa" } } + +typedef unsigned v4ui __attribute__ ((vector_size(16), aligned (16))); + +template<int I> +static v4ui t1(unsigned *dest_data) +{ + typedef unsigned v4ui_1 __attribute__ ((vector_size (16), aligned (4))); + return ((const v4ui_1*)dest_data)[0]; +} + +v4ui f(unsigned int *array) +{ + return t1<1>(array+7); +}
reply other threads:[~2022-05-13 16:28 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=20220513162814.27BEF3857023@sourceware.org \ --to=jason@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).