This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/42555 (aligned typedef in template)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 04 Jan 2010 12:49:37 -0500
- Subject: C++ PATCH for c++/42555 (aligned typedef in template)
When I changed the handling of typedefs in templates to just strip the
typedef and recreate it later, I failed to change the handling of
attributes accordingly, so we applying attributes directly to base types.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit cdb496b933fb0fdcbc6f8d2f1bf9137fb152ad83
Author: Jason Merrill <jason@redhat.com>
Date: Mon Jan 4 12:06:31 2010 -0500
PR c++/42555
* pt.c (tsubst_decl): Don't apply type attributes in place.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d5342a1..d2a1f9d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9400,7 +9400,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
TREE_CHAIN (r) = NULL_TREE;
apply_late_template_attributes (&r, DECL_ATTRIBUTES (r),
- (int) ATTR_FLAG_TYPE_IN_PLACE,
+ /*flags=*/0,
args, complain, in_decl);
/* Preserve a typedef that names a type. */
diff --git a/gcc/testsuite/g++.dg/ext/attrib35.C b/gcc/testsuite/g++.dg/ext/attrib35.C
new file mode 100644
index 0000000..60c4840
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/attrib35.C
@@ -0,0 +1,19 @@
+// { dg-do compile { target i*86-*-* x86_64-*-* } }
+// { dg-options "-O3 -msse2" }
+
+// You can make NON-template typedefs with a large alignment.
+typedef double AlignedDoubleType __attribute__((aligned(16)));
+
+template <typename RealType>
+RealType f(const RealType* p)
+{
+ // But if you use a template parameter it complains.
+ typedef RealType AlignedRealType __attribute__((aligned(16)));
+
+ return p[0];
+}
+
+double f2(const double* p)
+{
+ return f<double>(p);
+}