public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] c++: alignment of local typedef in template [PR65211]
@ 2022-04-14  2:56 Jason Merrill
  2022-04-26  7:56 ` [committed] testsuite: Fix up g++.target/i386/vec-tmpl1.C testcase [PR65211] Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Merrill @ 2022-04-14  2:56 UTC (permalink / raw)
  To: gcc-patches

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.

Tested x86_64-pc-linux-gnu, applying to trunk.

	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.
---
 gcc/cp/pt.cc                              |  6 ++++++
 gcc/testsuite/g++.target/i386/vec-tmpl1.C | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 gcc/testsuite/g++.target/i386/vec-tmpl1.C

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<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);
+}

base-commit: 1824da60663b4532199ecd051d8ba6da8995821d
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [committed] testsuite: Fix up g++.target/i386/vec-tmpl1.C testcase [PR65211]
  2022-04-14  2:56 [pushed] c++: alignment of local typedef in template [PR65211] Jason Merrill
@ 2022-04-26  7:56 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2022-04-26  7:56 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

Hi!

This test fails on i686-linux:
Excess errors:
.../gcc/testsuite/g++.target/i386/vec-tmpl1.C:13:27: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]

Fixed thusly, tested on x86_64-linux with
make check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64,-m32/-mno-sse\} i386.exp=vec-tmpl*'
and committed to trunk as obvious.

2022-04-26  Jakub Jelinek  <jakub@redhat.com>

	PR c++/65211
	* g++.target/i386/vec-tmpl1.C: Add -Wno-psabi as
	dg-additional-options.

--- gcc/testsuite/g++.target/i386/vec-tmpl1.C.jj	2022-04-14 13:46:59.621141017 +0200
+++ gcc/testsuite/g++.target/i386/vec-tmpl1.C	2022-04-26 09:51:10.336944403 +0200
@@ -1,4 +1,5 @@
 // PR c++/65211
+// { dg-additional-options "-Wno-psabi" }
 // { dg-final { scan-assembler-not "movdqa" } }
 
 typedef unsigned v4ui __attribute__ ((vector_size(16), aligned (16)));

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-26  7:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14  2:56 [pushed] c++: alignment of local typedef in template [PR65211] Jason Merrill
2022-04-26  7:56 ` [committed] testsuite: Fix up g++.target/i386/vec-tmpl1.C testcase [PR65211] Jakub Jelinek

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).