On Sat, 22 May 2010, Wolfram Sang wrote:

> On Fri, May 21, 2010 at 05:18:40PM +0200, Julia Lawall wrote:
> > On Fri, 21 May 2010, Arnaud Lacombe wrote:
> > 
> > > Hi,
> > > 
> > > On Fri, May 21, 2010 at 10:48 AM, Julia Lawall <[email protected]> wrote:
> > > > I don't think I am going to be very successful with fixing this.  The
> > > > problem is that a function prototype initially looks like a K&R function
> > > > definition, eg
> > > >
> > > > int f(foo,bar,xyz)
> > > >
> > > > If it is a prototype, then foo, bar, and xyz are typedefs (presumably
> > > > defined in some header file we don't have access too).  If it is a K&R
> > > > definition, then they are variables.
> > > >
> > > > Unfortunately, trying to make the parser aware of which it is seems to
> > > > introduce conflicts.
> > > >
> > > Shouldn't a function prototype be always terminated by a ';' which
> > > would allow the parser to differentiate between prototype, K&R
> > > function declaration and standard function.
> > 
> > Yes, but the parser just isn't organized in that way.  It has a rule for 
> > the type-name-parameter list that is shared by prototypes, standard 
> > functions, and K&R functions.  The ; is dealt with somewhere else.
> > 
> > > > Since K&R C is not very well supported anyway, due to the need for the
> > > > declarations not to appear in the leftmost column, and due to the 
> > > > general
> > > > complexity of the parser, I think the risk of breaking something is 
> > > > higher
> > > > than the benefit of fixing the problem.
> > > >
> > > he, I guess that's another argument is favor of getting rid of such 
> > > declaration.
> > 
> > Yes, I think that would be best...
> 
> It would be nice to have it documented that K&R C might cause problems.

I have added something to the wiki in the C syntax errors section, and to 
the introduction of the manual.

Thanks for the suggestion.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to