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]

Re: [patch] limit and document unnamed fields.


On Wed, 3 Oct 2001, DJ Delorie wrote:

> 	* c-decl.c (grokdeclarator): Make sure the only unnamed fields
> 	we're allowing are either structs or unions.

This doesn't match the patch, which makes the change in grokfield.

> *** c-decl.c	2001/10/02 07:19:43	1.248
> --- c-decl.c	2001/10/03 21:16:20
> *************** grokfield (filename, line, declarator, d

Why put this check in grokfield, rather than in finish_struct along with 
most of the other checks for problems with fields?

> + 	  error ("Unnamed fields of type other than struct or union are not allowed.");

Error messages begin with a lower-case letter (when as here they follow a
file name) and do not end with a period.  See the GNU Coding Standards.

> struct { int; int q; } a; /* { dg-error "Unnamed" } */
> struct { union {int x;}; int q; } b;
> struct { struct {int x;}; int q; } c;
> union { union {int x;}; int q; } d;
> union { struct {int x;}; int q; } e;

What about cases such as

struct s { int x; struct { int x; }; };

?  I think this should count as a duplicate member x, and be disallowed.
What do the compilers this is for compatibility with do?

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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