This is the mail archive of the gcc@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]

Using __extension__ in a struct with a GTY(()) mark


Geoff,

I'm trying to enable compiling the G++ frontend using any ISOC
compiler.  In effect, this means getting it to compile with gcc
-pedantic.  I've zapped all problems except one in which I'm running
into a problem with gengtype and a structure using GTY(()) when I try
to use the __extension__ keyword.

The last warnings I get are:
cp-tree.h:1045: warning: bit-field `has_type_conversion' type invalid in ISO C
cp-tree.h:1046: warning: bit-field `has_init_ref' type invalid in ISO C
cp-tree.h:1047: warning: bit-field `has_default_ctor' type invalid in ISO C
cp-tree.h:1048: warning: bit-field `uses_multiple_inheritance' type invalid in ISO C
cp-tree.h:1049: warning: bit-field `const_needs_init' type invalid in ISO C
cp-tree.h:1050: warning: bit-field `ref_needs_init' type invalid in ISO C
cp-tree.h:1051: warning: bit-field `has_const_assign_ref' type invalid in ISO C

These come from this struct in cp-tree.h:

struct lang_type_header GTY(())
{
  unsigned char is_lang_type_class : 1;

  unsigned char has_type_conversion : 1;
  unsigned char has_init_ref : 1;
  unsigned char has_default_ctor : 1;
  unsigned char uses_multiple_inheritance : 1;
  unsigned char const_needs_init : 1;
  unsigned char ref_needs_init : 1;
  unsigned char has_const_assign_ref : 1;
};

I added code in system.h to appropriately use int or char depending on
whether we're using GCC via a macro CHAR_BITFIELD.

The I replaced the above "unsigned char" with CHAR_BITFIELD.  I found
that gengtype chokes on this.  That I fixed by adding CHAR_BITFIELD to
IWORD in gengtype-lex.l.

The problem I'm having now is that I need to add the __extension__
keyword to the struct so that it doesn't get a complaint from GCC.
Not being very fluent in bison or flex, I can't seem to get gengtype
to accept it.

In the end, I'm trying to get this struct parsed by gengtype:

struct lang_type_header GTY(())  __extension__
{
  CHAR_BITFIELD is_lang_type_class : 1;

  CHAR_BITFIELD has_type_conversion : 1;
  CHAR_BITFIELD has_init_ref : 1;
  CHAR_BITFIELD has_default_ctor : 1;
  CHAR_BITFIELD uses_multiple_inheritance : 1;
  CHAR_BITFIELD const_needs_init : 1;
  CHAR_BITFIELD ref_needs_init : 1;
  CHAR_BITFIELD has_const_assign_ref : 1;
};

Please help?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			ghazi at caip dot rutgers dot edu


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