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.



> > 	* 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.

Oops.

> > *** 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?

No particular reason.  The code that was added to allow unnamed s/u's
was small, a bit in c-parse.y, and that small bit called grokfield, so
that was the first opportunity gcc had to detect empty non-s/u's.

> > + 	  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.

Ok.

> 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.

I was not addressing that kind of problem with this patch.  I was
addressing the ability to do "int;" with this patch.

> What do the compilers this is for compatibility with do?

MSVC gives a redefinition error, but MSVC++ doesn't.  Go figure.


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