This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ error-recovery] Fix ICE in walk_subobject_offsets (PR c++/33841)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 29 Oct 2007 17:18:09 -0400
- Subject: Re: [C++ error-recovery] Fix ICE in walk_subobject_offsets (PR c++/33841)
- References: <20071027172621.GZ5451@devserv.devel.redhat.com> <47251329.3050109@codesourcery.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sun, Oct 28, 2007 at 03:54:33PM -0700, Mark Mitchell wrote:
> That might be overly exciting, though, in that there might already be
> references to the FIELD_DECL around (in function bodies), and those
> might get confused if the FIELD_DECL is excised from its class. So,
> another approach would be just to give it type "int", rather than a type
> of "error_mark_node". That's a reasonable error-recovery type for a
> bit-field with a non-integral type. I think that would just be a change
> to the error handling code in check_bitfield_decl. Patch approved, if
> that works.
I have noticed we already clear the bit-fieldness of the field in case
of error, so rather than changing the type to int or error_mark_node
we can just keep it as is.
Bootstrapped/regtested on x86_64-linux.
2007-10-29 Jakub Jelinek <jakub@redhat.com>
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.
--- gcc/cp/class.c.jj 2007-10-28 19:34:10.000000000 +0100
+++ gcc/cp/class.c 2007-10-29 12:06:05.000000000 +0100
@@ -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,
/* 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_
/* 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,
Jakub