class.c (layout_class_type): Restructure overlong-bitfield tpe search.
* class.c (layout_class_type): Restructure overlong-bitfield tpe search. From-SVN: r248971
This commit is contained in:
parent
2f8d29a497
commit
a6d31e8499
@ -1,3 +1,8 @@
|
|||||||
|
2017-06-07 Nathan Sidwell <nathan@acm.org>
|
||||||
|
|
||||||
|
* class.c (layout_class_type): Restructure overlong-bitfield tpe
|
||||||
|
search.
|
||||||
|
|
||||||
2017-06-07 Jonathan Wakely <jwakely@redhat.com>
|
2017-06-07 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
PR c++/80990
|
PR c++/80990
|
||||||
|
@ -6426,41 +6426,39 @@ layout_class_type (tree t, tree *virtuals_p)
|
|||||||
if (DECL_C_BIT_FIELD (field)
|
if (DECL_C_BIT_FIELD (field)
|
||||||
&& tree_int_cst_lt (TYPE_SIZE (type), DECL_SIZE (field)))
|
&& tree_int_cst_lt (TYPE_SIZE (type), DECL_SIZE (field)))
|
||||||
{
|
{
|
||||||
unsigned int itk;
|
|
||||||
tree integer_type;
|
|
||||||
bool was_unnamed_p = false;
|
bool was_unnamed_p = false;
|
||||||
/* We must allocate the bits as if suitably aligned for the
|
/* We must allocate the bits as if suitably aligned for the
|
||||||
longest integer type that fits in this many bits. type
|
longest integer type that fits in this many bits. Then,
|
||||||
of the field. Then, we are supposed to use the left over
|
we are supposed to use the left over bits as additional
|
||||||
bits as additional padding. */
|
padding. */
|
||||||
for (itk = itk_char; itk != itk_none; ++itk)
|
|
||||||
if (integer_types[itk] != NULL_TREE
|
|
||||||
&& (tree_int_cst_lt (size_int (MAX_FIXED_MODE_SIZE),
|
|
||||||
TYPE_SIZE (integer_types[itk]))
|
|
||||||
|| tree_int_cst_lt (DECL_SIZE (field),
|
|
||||||
TYPE_SIZE (integer_types[itk]))))
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* ITK now indicates a type that is too large for the
|
/* Do not pick a type bigger than MAX_FIXED_MODE_SIZE. */
|
||||||
field. We have to back up by one to find the largest
|
tree limit = size_int (MAX_FIXED_MODE_SIZE);
|
||||||
type that fits. */
|
if (tree_int_cst_lt (DECL_SIZE (field), limit))
|
||||||
do
|
limit = DECL_SIZE (field);
|
||||||
{
|
|
||||||
--itk;
|
tree integer_type = integer_types[itk_char];
|
||||||
integer_type = integer_types[itk];
|
for (unsigned itk = itk_char; itk != itk_none; itk++)
|
||||||
} while (itk > 0 && integer_type == NULL_TREE);
|
if (tree next = integer_types[itk])
|
||||||
|
{
|
||||||
|
if (tree_int_cst_lt (limit, TYPE_SIZE (next)))
|
||||||
|
/* Too big, so our current guess is what we want. */
|
||||||
|
break;
|
||||||
|
/* Not bigger than limit, ok */
|
||||||
|
integer_type = next;
|
||||||
|
}
|
||||||
|
|
||||||
/* Figure out how much additional padding is required. */
|
/* Figure out how much additional padding is required. */
|
||||||
if (tree_int_cst_lt (TYPE_SIZE (integer_type), DECL_SIZE (field)))
|
if (TREE_CODE (t) == UNION_TYPE)
|
||||||
{
|
/* In a union, the padding field must have the full width
|
||||||
if (TREE_CODE (t) == UNION_TYPE)
|
of the bit-field; all fields start at offset zero. */
|
||||||
/* In a union, the padding field must have the full width
|
padding = DECL_SIZE (field);
|
||||||
of the bit-field; all fields start at offset zero. */
|
else
|
||||||
padding = DECL_SIZE (field);
|
padding = size_binop (MINUS_EXPR, DECL_SIZE (field),
|
||||||
else
|
TYPE_SIZE (integer_type));
|
||||||
padding = size_binop (MINUS_EXPR, DECL_SIZE (field),
|
|
||||||
TYPE_SIZE (integer_type));
|
if (integer_zerop (padding))
|
||||||
}
|
padding = NULL_TREE;
|
||||||
|
|
||||||
/* An unnamed bitfield does not normally affect the
|
/* An unnamed bitfield does not normally affect the
|
||||||
alignment of the containing class on a target where
|
alignment of the containing class on a target where
|
||||||
|
Loading…
Reference in New Issue
Block a user