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]

RE: typeof and bitfields


> -----Original Message-----
> From: Paul Schlie 
> Sent: 18 January 2005 18:06

> >> Paul Schlie writes:
> >> Understand that it's not formally supported in C's syntax 
> specification, but
> >> curiously nor is the definition of struct { :3; }, 
> although the text seems
> >> to implies it defines a struct containing an 3-bit unnamed 
> (and unspecified)
> >> integer type?

> > From: Andreas Schwab 
> > There is nothing in the semantics section that allows such a syntax.

> From: Paul Schlie 
> ???
> 
> 6.5.2  Type specifiers
> 6.5.2.1  Structure and union specifiers
> ...
>  Semantics
>  ...
>        [#10] A bit-field declaration with no declarator, but only a
>        colon and a width, indicates an unnamed bit-field.92   As  a
>        special  case  of  this, a bit-field structure member with a
>        width of 0 indicates that no  further  bit-field  is  to  be
>        packed  into  the  unit  in which the previous bit-field, if
>        any, was placed.
> 
> (or do you mean there's nothing implying it's acceptable to 
> be typedef'ed?

  No, he means that it may not have a name but it still has to have a type: the
type specifier is not part of the declarator.  Check the grammar:

-----------------<snip!>-----------------
struct-or-union-specifier:
struct-or-union identifier opt { struct-declaration-list }
struct-or-union identifier

struct-or-union:
struct
union

struct-declaration-list:
struct-declaration
struct-declaration-list struct-declaration

struct-declaration:
specifier-qualifier-list struct-declarator-list ;

specifier-qualifier-list:
type-specifier specifier-qualifier-list opt
type-qualifier specifier-qualifier-list opt

struct-declarator-list:
struct-declarator
struct-declarator-list , struct-declarator

struct-declarator:
declarator
declarator opt : constant-expression
-----------------<snip!>-----------------

  Notice how the declarator is marked optional in the struct-declarator variant
with the bitfield format, but that struct-declarator can only appear as part of
the (optional) struct-declarator-list that follows a type-specifier in the
specifier-qualifier-list.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


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