This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ error-recovery] Fix ICE in walk_subobject_offsets (PR c++/33841)


Hi!

Bitfield with a valid, but not appropriate for bitfields, type (but from
quick skimming a bunch of other errorneous fields as well) have
TREE_TYPE (field) == error_mark_node.  In walk_subobject_offsets we can
ICE on such fields when computing field_offset (which is ignored by
the recursive walk_subobject_offsets anyway, as it will return 0 for
type == error_mark_node as one of the first few statements in the function).

The following patch fixes that, ok for 4.2/trunk?

2007-10-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/33841
	* class.c (walk_subobject_offsets): Ignore fields with
	error_mark_node type.

	* g++.dg/other/bitfield3.C: New test.

--- gcc/cp/class.c.jj	2007-10-22 21:08:38.000000000 +0200
+++ gcc/cp/class.c	2007-10-27 18:43:26.000000000 +0200
@@ -3287,6 +3287,9 @@ walk_subobject_offsets (tree type,
 	  {
 	    tree field_offset;
 
+	    if (TREE_TYPE (field) == error_mark_node)
+	      continue;
+
 	    if (abi_version_at_least (2))
 	      field_offset = byte_position (field);
 	    else
--- gcc/testsuite/g++.dg/other/bitfield3.C.jj	2007-10-27 18:49:25.000000000 +0200
+++ gcc/testsuite/g++.dg/other/bitfield3.C	2007-10-27 18:48:33.000000000 +0200
@@ -0,0 +1,17 @@
+// PR c++/33841
+// { dg-do compile }
+
+template<int> struct A
+{
+  struct {} : 2;	// { dg-error "with non-integral type" }
+};
+
+template<int> struct B
+{
+  int a;
+  struct {} : 2;	// { dg-error "with non-integral type" }
+  int b;
+};
+
+struct C : A<0> {};
+struct D : B<0> {};

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]