On Thu, Apr 09, 2015 at 10:51:12AM -0400, Jason Merrill wrote: > On 04/09/2015 05:38 AM, Jakub Jelinek wrote: > >Or supposedly no change at all, as the attributes would be either in > >TYPE_ATTRIBUTES, or on TYPE_DECL, but then it would be covered by > >the TYPE_NAME comparison. > > Interesting point. So maybe all we need to do here is copy > TYPE_ALIGN/TYPE_USER_ALIGN, not change any of the tests.
The following is actually enough to fix this. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2015-04-09 Jakub Jelinek <ja...@redhat.com> PR c++/65715 * tree.c (cp_build_qualified_type_real): Also copy TYPE_ALIGN and TYPE_USER_ALIGN. * c-c++-common/attr-aligned-2.c: New test. --- gcc/cp/tree.c.jj 2015-04-09 17:05:02.331837692 +0200 +++ gcc/cp/tree.c 2015-04-09 17:15:25.216896052 +0200 @@ -1079,6 +1079,8 @@ cp_build_qualified_type_real (tree type, { t = build_variant_type_copy (t); TYPE_NAME (t) = TYPE_NAME (type); + TYPE_ALIGN (t) = TYPE_ALIGN (type); + TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (type); } } --- gcc/testsuite/c-c++-common/attr-aligned-2.c.jj 2015-04-09 17:13:26.327792252 +0200 +++ gcc/testsuite/c-c++-common/attr-aligned-2.c 2015-04-09 17:13:57.054300285 +0200 @@ -0,0 +1,18 @@ +/* PR c++/65715 */ +/* { dg-do run } */ + +typedef double T[4][4] __attribute__((aligned (2 * __alignof__ (double)))); +void foo (const T); +struct S { T s; }; + +int +main () +{ + if (__alignof__ (const T) != 2 * __alignof__ (double)) + __builtin_abort (); + return 0; +} + +#if defined(__cplusplus) && __cplusplus >= 201103L +static_assert (alignof (const T) == 2 * alignof (double), "alignment of const T"); +#endif Jakub