Incorrect usage of DECL_C_BIT_FIELD

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Thu Sep 23 08:08:00 GMT 1999


According cp-tree.h, DECL_C_BIT_FIELD is applied only to FIELD_DECLs,
and it tells whether a field is a bitfield. However, the macro is
applied to TYPE_DECLs, as well.

For example, finish_struct_1 says

  /* Delete all zero-width bit-fields from the front of the fieldlist */
  while (fields && DECL_C_BIT_FIELD (fields)
	 && DECL_INITIAL (fields))

With the patch I just sent, this breaks for class std::exception: it
has no data fields, and fields points to the TYPE_DECL for exception
itself (with t being the RECORD_TYPE).

In other places, it is used correctly, like build_offset_ref:

  if (TREE_CODE (t) == FIELD_DECL && DECL_C_BIT_FIELD (t))
    {
      cp_error ("illegal pointer to bit field `%D'", t);
      return error_mark_node;
    }

So, my question is: Is DECL_C_BIT_FIELD supposed to work for all _DECL
nodes, or just for fields? How should this be corrected?

Regards,
Martin



More information about the Gcc-bugs mailing list