summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/class.c15
-rw-r--r--gcc/cp/decl2.c5
-rw-r--r--gcc/cp/pt.c9
4 files changed, 26 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 95110b87c3c..fe73935eea2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,15 @@
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.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 97e29c0604e..687ddaa5c8f 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3231,12 +3231,12 @@ check_bitfield_decl (tree field)
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))
@@ -3571,7 +3571,8 @@ check_field_decls (tree t, tree *access_decls,
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. */
;
@@ -5268,9 +5269,9 @@ remove_zero_width_bit_fields (tree t)
{
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
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 29d6c59f549..107ce7bc882 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1047,7 +1047,10 @@ grokbitfield (const cp_declarator *declarator,
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);
}
}
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0dae10e032b..70cfc9aac8a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12835,11 +12835,10 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
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))