diff options
author | Jakub Jelinek <jakub@redhat.com> | 2015-04-09 22:11:44 +0200 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-04-09 16:11:44 -0400 |
commit | 0212e31edbd4603853f3cbc9c9397aa8a9ae6bc3 (patch) | |
tree | f4d4ebb64111b8119134ff3942ac33bbb15441bb | |
parent | 51c5c6b5d82999d8cec629e8aabf26d5d890146a (diff) | |
download | gcc-0212e31edbd4603853f3cbc9c9397aa8a9ae6bc3.zip gcc-0212e31edbd4603853f3cbc9c9397aa8a9ae6bc3.tar.gz gcc-0212e31edbd4603853f3cbc9c9397aa8a9ae6bc3.tar.bz2 |
re PR c++/65690 (typedef alignment lost since r219705)
PR c++/65690
* tree.c (cp_build_qualified_type_real): Copy TYPE_ALIGN and
TYPE_USER_ALIGN.
From-SVN: r221960
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/tree.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/attr-aligned-1.c | 24 |
3 files changed, 30 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 065cd75..91ddee0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,10 @@ 2015-04-09 Jakub Jelinek <jakub@redhat.com> PR c++/65690 + * tree.c (cp_build_qualified_type_real): Copy TYPE_ALIGN and + TYPE_USER_ALIGN. + + PR c++/65690 * tree.c (build_cplus_array_type): Layout type before variants are set, but copy over TYPE_SIZE and TYPE_SIZE_UNIT from the main variant. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 6802909..71c84ae 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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); } } diff --git a/gcc/testsuite/c-c++-common/attr-aligned-1.c b/gcc/testsuite/c-c++-common/attr-aligned-1.c new file mode 100644 index 0000000..671e86b --- /dev/null +++ b/gcc/testsuite/c-c++-common/attr-aligned-1.c @@ -0,0 +1,24 @@ +/* PR c++/65690 */ +/* { 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__ (struct S) != 2 * __alignof__ (double) + || __alignof__ (T) != 2 * __alignof__ (double) + || __alignof__ (const struct S) != 2 * __alignof__ (double) + || __alignof__ (const T) != 2 * __alignof__ (double)) + __builtin_abort (); + return 0; +} + +#if defined(__cplusplus) && __cplusplus >= 201103L +static_assert (alignof (S) == 2 * alignof (double), "alignment of S"); +static_assert (alignof (T) == 2 * alignof (double), "alignment of T"); +static_assert (alignof (const S) == 2 * alignof (double), "alignment of const S"); +static_assert (alignof (const T) == 2 * alignof (double), "alignment of const T"); +#endif |