diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-10-29 22:41:29 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-10-29 22:41:29 +0100 |
commit | e7df01809dbc84b6eebe815e87d51eb8e470b6b9 (patch) | |
tree | 15a3218c6d929010c60756849df159d3e24042b7 /gcc/cp/class.c | |
parent | 324d22176d781176c004d9ff77d7f9513b013cd7 (diff) | |
download | gcc-e7df01809dbc84b6eebe815e87d51eb8e470b6b9.zip gcc-e7df01809dbc84b6eebe815e87d51eb8e470b6b9.tar.gz gcc-e7df01809dbc84b6eebe815e87d51eb8e470b6b9.tar.bz2 |
re PR c++/33841 (ICE with non-integral bit-field)
PR c++/33841
* class.c (check_bitfield_decl): Don't set field's type to error_mark_node
for non-integral type bitfields. Return true if bitfield is correct, false
error has been diagnosed.
(check_field_decls): If check_bitfield_decl returned false, call also
check_field_decl.
* g++.dg/other/bitfield3.C: New test.
From-SVN: r129736
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 54dc14c..4453b34 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -139,7 +139,7 @@ static tree build_vtbl_ref_1 (tree, tree); static tree build_vtbl_initializer (tree, tree, tree, tree, int *); static int count_fields (tree); static int add_fields_to_record_type (tree, struct sorted_fields_type*, int); -static void check_bitfield_decl (tree); +static bool check_bitfield_decl (tree); static void check_field_decl (tree, tree, int *, int *, int *); static void check_field_decls (tree, tree *, int *, int *); static tree *build_base_field (record_layout_info, tree, splay_tree, tree *); @@ -2655,9 +2655,9 @@ add_fields_to_record_type (tree fields, struct sorted_fields_type *field_vec, in /* FIELD is a bit-field. We are finishing the processing for its enclosing type. Issue any appropriate messages and set appropriate - flags. */ + flags. Returns false if an error has been diagnosed. */ -static void +static bool check_bitfield_decl (tree field) { tree type = TREE_TYPE (field); @@ -2675,7 +2675,6 @@ check_bitfield_decl (tree field) if (!INTEGRAL_TYPE_P (type)) { error ("bit-field %q+#D with non-integral type", field); - TREE_TYPE (field) = error_mark_node; w = error_mark_node; } else @@ -2720,12 +2719,14 @@ check_bitfield_decl (tree field) { DECL_SIZE (field) = convert (bitsizetype, w); DECL_BIT_FIELD (field) = 1; + return true; } else { /* Non-bit-fields are aligned for their type. */ DECL_BIT_FIELD (field) = 0; CLEAR_DECL_C_BIT_FIELD (field); + return false; } } @@ -3037,9 +3038,7 @@ check_field_decls (tree t, tree *access_decls, /* We set DECL_C_BIT_FIELD in grokbitfield. If the type and width are valid, we'll also set DECL_BIT_FIELD. */ - if (DECL_C_BIT_FIELD (x)) - check_bitfield_decl (x); - else + if (! DECL_C_BIT_FIELD (x) || ! check_bitfield_decl (x)) check_field_decl (x, t, cant_have_const_ctor_p, no_const_asn_ref_p, |