diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f516216ab6f..c592cbf4f72 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-01-21 Jason Merrill + PR c++/40751 + PR c++/64987 + * decl.c (copy_type_enum): Respect TYPE_USER_ALIGN. + PR c++/43407 * decl.c (start_enum): Add attributes parameter. * parser.c (cp_parser_enum_specifier): Pass it. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d995654a3d8..020e9bd2510 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13030,8 +13030,12 @@ copy_type_enum (tree dst, tree src) TYPE_SIZE_UNIT (t) = TYPE_SIZE_UNIT (src); SET_TYPE_MODE (dst, TYPE_MODE (src)); TYPE_PRECISION (t) = TYPE_PRECISION (src); - TYPE_ALIGN (t) = TYPE_ALIGN (src); - TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (src); + unsigned valign = TYPE_ALIGN (src); + if (TYPE_USER_ALIGN (t)) + valign = MAX (valign, TYPE_ALIGN (t)); + else + TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (src); + TYPE_ALIGN (t) = valign; TYPE_UNSIGNED (t) = TYPE_UNSIGNED (src); } } diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas5.C b/gcc/testsuite/g++.dg/cpp0x/alignas5.C new file mode 100644 index 00000000000..2820ca716f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignas5.C @@ -0,0 +1,6 @@ +// { dg-do compile { target c++11 } } + +#define SA(X) static_assert(X,#X) + +enum alignas(16) E {}; +SA(alignof(E) == 16);