From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 914393857350; Thu, 14 Apr 2022 02:56:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 914393857350 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-8153] c++: alignment of local typedef in template [PR65211] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: 1824da60663b4532199ecd051d8ba6da8995821d X-Git-Newrev: 8369b4e4c6433535981d377edc1d4abb799c9225 Message-Id: <20220414025638.914393857350@sourceware.org> Date: Thu, 14 Apr 2022 02:56:38 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2022 02:56:38 -0000 https://gcc.gnu.org/g:8369b4e4c6433535981d377edc1d4abb799c9225 commit r12-8153-g8369b4e4c6433535981d377edc1d4abb799c9225 Author: Jason Merrill 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.cc (tsubst_decl) [TYPE_DECL]: Copy TYPE_ALIGN. gcc/testsuite/ChangeLog: * g++.target/i386/vec-tmpl1.C: New test. Diff: --- gcc/cp/pt.cc | 6 ++++++ gcc/testsuite/g++.target/i386/vec-tmpl1.C | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index adc863de702..dde62ee052d 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -15084,6 +15084,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..d512072a2a2 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/vec-tmpl1.C @@ -0,0 +1,16 @@ +// PR c++/65211 +// { dg-final { scan-assembler-not "movdqa" } } + +typedef unsigned v4ui __attribute__ ((vector_size(16), aligned (16))); + +template +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); +}