+2017-09-29 Jakub Jelinek <jakub@redhat.com>
+
+ * c-attribs.c (handle_packed_attribute): Test DECL_C_BIT_FIELD
+ rather than DECL_INITIAL.
+ (common_handle_aligned_attribute): Likewise.
+
2017-09-20 Alexandre Oliva <aoliva@redhat.com>
* c.opt (gen-decls): Add RejectNegative.
{
if (TYPE_ALIGN (TREE_TYPE (*node)) <= BITS_PER_UNIT
/* Still pack bitfields. */
- && ! DECL_INITIAL (*node))
+ && ! DECL_C_BIT_FIELD (*node))
warning (OPT_Wattributes,
"%qE attribute ignored for field of type %qT",
name, TREE_TYPE (*node));
{
if (warn_if_not_aligned_p)
{
- if (TREE_CODE (decl) == FIELD_DECL && !DECL_INITIAL (decl))
+ if (TREE_CODE (decl) == FIELD_DECL && !DECL_C_BIT_FIELD (decl))
{
SET_DECL_WARN_IF_NOT_ALIGN (decl, (1U << i) * BITS_PER_UNIT);
warn_if_not_aligned_p = false;
2017-09-29 Jakub Jelinek <jakub@redhat.com>
+ * c-decl.c (grokfield): Use SET_DECL_C_BIT_FIELD here if
+ width is non-NULL.
+ (finish_struct): Test DECL_C_BIT_FIELD instead of DECL_INITIAL,
+ don't SET_DECL_C_BIT_FIELD here.
+
PR c/82340
* c-decl.c (build_compound_literal): Use c_apply_type_quals_to_decl
instead of trying to set just TREE_READONLY manually.
finish_decl (value, loc, NULL_TREE, NULL_TREE, NULL_TREE);
DECL_INITIAL (value) = width;
+ if (width)
+ SET_DECL_C_BIT_FIELD (value);
if (warn_cxx_compat && DECL_NAME (value) != NULL_TREE)
{
if (C_DECL_VARIABLE_SIZE (x))
C_TYPE_VARIABLE_SIZE (t) = 1;
- if (DECL_INITIAL (x))
+ if (DECL_C_BIT_FIELD (x))
{
unsigned HOST_WIDE_INT width = tree_to_uhwi (DECL_INITIAL (x));
DECL_SIZE (x) = bitsize_int (width);
DECL_BIT_FIELD (x) = 1;
- SET_DECL_C_BIT_FIELD (x);
}
if (TYPE_PACKED (t)
2017-09-29 Jakub Jelinek <jakub@redhat.com>
+ * class.c (check_bitfield_decl): Retrieve and clear width from
+ DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL.
+ (check_field_decls): Test DECL_BIT_FIELD_REPRESENTATIVE rather than
+ DECL_INITIAL.
+ (remove_zero_width_bit_fields): Adjust comment.
+ * decl2.c (grokbitfield): Stash width into
+ DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL.
+ * pt.c (tsubst_decl): For DECL_C_BIT_FIELD, tsubst_expr
+ DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL for width.
+
* parser.c (cp_parser_member_declaration): Parse attributes before
colon of a bitfield in addition to after colon.
tree w;
/* Extract the declared width of the bitfield, which has been
- temporarily stashed in DECL_INITIAL. */
- w = DECL_INITIAL (field);
+ temporarily stashed in DECL_BIT_FIELD_REPRESENTATIVE by grokbitfield. */
+ w = DECL_BIT_FIELD_REPRESENTATIVE (field);
gcc_assert (w != NULL_TREE);
/* Remove the bit-field width indicator so that the rest of the
- compiler does not treat that value as an initializer. */
- DECL_INITIAL (field) = NULL_TREE;
+ compiler does not treat that value as a qualifier. */
+ DECL_BIT_FIELD_REPRESENTATIVE (field) = NULL_TREE;
/* Detect invalid bit-field type. */
if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type))
DECL_PACKED (x) = 1;
}
- if (DECL_C_BIT_FIELD (x) && integer_zerop (DECL_INITIAL (x)))
+ if (DECL_C_BIT_FIELD (x)
+ && integer_zerop (DECL_BIT_FIELD_REPRESENTATIVE (x)))
/* We don't treat zero-width bitfields as making a class
non-empty. */
;
{
if (TREE_CODE (*fieldsp) == FIELD_DECL
&& DECL_C_BIT_FIELD (*fieldsp)
- /* We should not be confused by the fact that grokbitfield
+ /* We should not be confused by the fact that grokbitfield
temporarily sets the width of the bit field into
- DECL_INITIAL (*fieldsp).
+ DECL_BIT_FIELD_REPRESENTATIVE (*fieldsp).
check_bitfield_decl eventually sets DECL_SIZE (*fieldsp)
to that width. */
&& (DECL_SIZE (*fieldsp) == NULL_TREE
TREE_TYPE (width));
else
{
- DECL_INITIAL (value) = width;
+ /* Temporarily stash the width in DECL_BIT_FIELD_REPRESENTATIVE.
+ check_bitfield_decl picks it from there later and sets DECL_SIZE
+ accordingly. */
+ DECL_BIT_FIELD_REPRESENTATIVE (value) = width;
SET_DECL_C_BIT_FIELD (value);
}
}
cp_apply_type_quals_to_decl (cp_type_quals (type), r);
if (DECL_C_BIT_FIELD (r))
- /* For bit-fields, DECL_INITIAL gives the number of bits. For
- non-bit-fields DECL_INITIAL is a non-static data member
- initializer, which gets deferred instantiation. */
- DECL_INITIAL (r)
- = tsubst_expr (DECL_INITIAL (t), args,
+ /* For bit-fields, DECL_BIT_FIELD_REPRESENTATIVE gives the
+ number of bits. */
+ DECL_BIT_FIELD_REPRESENTATIVE (r)
+ = tsubst_expr (DECL_BIT_FIELD_REPRESENTATIVE (t), args,
complain, in_decl,
/*integral_constant_expression_p=*/true);
else if (DECL_INITIAL (t))
+2017-09-29 Jakub Jelinek <jakub@redhat.com>
+
+ * objc-act.c (check_ivars, gen_declaration): For OBJCPLUS look at
+ DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL.
+
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
t1 = TREE_TYPE (intdecls); t2 = TREE_TYPE (impdecls);
if (!comptypes (t1, t2)
+#ifdef OBJCPLUS
+ || !tree_int_cst_equal (DECL_BIT_FIELD_REPRESENTATIVE (intdecls),
+ DECL_BIT_FIELD_REPRESENTATIVE (impdecls))
+#else
|| !tree_int_cst_equal (DECL_INITIAL (intdecls),
- DECL_INITIAL (impdecls)))
+ DECL_INITIAL (impdecls))
+#endif
+ )
{
if (DECL_NAME (intdecls) == DECL_NAME (impdecls))
{
strcat (errbuf, IDENTIFIER_POINTER (DECL_NAME (decl)));
}
- if (DECL_INITIAL (decl)
- && TREE_CODE (DECL_INITIAL (decl)) == INTEGER_CST)
+#ifdef OBJCPLUS
+ tree w = DECL_BIT_FIELD_REPRESENTATIVE (decl);
+#else
+ tree w = DECL_INITIAL (decl);
+#endif
+ if (w && TREE_CODE (w) == INTEGER_CST)
sprintf (errbuf + strlen (errbuf), ": " HOST_WIDE_INT_PRINT_DEC,
- TREE_INT_CST_LOW (DECL_INITIAL (decl)));
+ TREE_INT_CST_LOW (w));
}
return errbuf;