re PR c++/40751 (G++ never packs typedef'd enums)

PR c++/40751
	PR c++/64987
	* decl.c (copy_type_enum): Respect TYPE_USER_ALIGN.

From-SVN: r232702
This commit is contained in:
Jason Merrill 2016-01-21 15:26:09 -05:00 committed by Jason Merrill
parent 97ca3d0d59
commit 2f3932b910
3 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,9 @@
2016-01-21 Jason Merrill <jason@redhat.com>
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.

View File

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

View File

@ -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);