for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
{
tree next;
+ tree type;
if (!DECL_NAME (field) && DECL_C_BIT_FIELD (field))
{
if (TREE_CODE (field) != FIELD_DECL || DECL_ARTIFICIAL (field))
continue;
+ /* If this is a bitfield, first convert to the declared type. */
+ type = TREE_TYPE (field);
+ if (DECL_BIT_FIELD_TYPE (field))
+ type = DECL_BIT_FIELD_TYPE (field);
+
if (idx < VEC_length (constructor_elt, CONSTRUCTOR_ELTS (init)))
{
constructor_elt *ce = VEC_index (constructor_elt,
}
gcc_assert (ce->value);
- next = digest_init (TREE_TYPE (field), ce->value);
+ next = digest_init (type, ce->value);
++idx;
}
else if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (field)))
continue;
}
+ /* If this is a bitfield, now convert to the lowered type. */
+ if (type != TREE_TYPE (field))
+ next = convert_and_check (TREE_TYPE (field), next);
flags |= picflag_from_initializer (next);
CONSTRUCTOR_APPEND_ELT (v, field, next);
}
--- /dev/null
+// Make sure that digest_init converts to the declared type of the
+// bitfield, not just the lowered type.
+
+enum E { EA, EB };
+
+struct A { E e: 8; };
+
+A a = { 0 }; // { dg-error "invalid conversion" }