Hi,
On Thu, May 20, 2010 at 3:14 PM, Julia Lawall <[email protected]> wrote:
> On Thu, 20 May 2010, Arnaud Lacombe wrote:
>
>> Hi,
>>
>> I'm running into some [old] code using K&R C function definition:
>>
>> void
>> rtalloc(ro)
>> register struct route *ro;
>> {
>> ... function body ...
>> }
>>
>> Which is making spatch fails with:
>>
>> bad: void
>> BAD:!!!!! rtalloc(ro)
>> ERROR-RECOV: found sync '}' at line 56
>> parsing pass2: try again
>> ERROR-RECOV: found sync '}' at line 56
>> parse error
>> = File "rt.c", line 27, column 0, charpos = 501
>> around = '{', whole content = {
>> badcount: 30
>> bad: register struct route *ro;
>> BAD:!!!!! {
>> [...]
>> SEMANTIC:parameter name omitted, but I continue
>> TYPEDEF CONFLICT:prt
>> TODO:typedef now used as an identifier
>>
>>
>> While the Graal would be to have spatch be capable to convert K&R to
>> ANSI C, would it be feasible to teach it not to fail on such
>> declaration ?
>
> There seems to be a bit more to triggering the error than the bit of code
> shown above.
you're right, I reduced the failure to the following:
void
f0(a)
register struct s0 *a;
{
}
void
f1(b)
register struct s1 *b;
{
struct s2 *a;
f(a->xdst);
}
which returns:
init_defs_builtins: /data/opt/coccinelle/share/coccinelle/standard.h
PARSING: route.c
(ONCE) CPP-MACRO: found toplevel macro noptvirg: f0
ERROR-RECOV: found sync col 0 at line 3
parsing pass2: try again
ERROR-RECOV: found sync col 0 at line 3
parse error
= File "route.c", line 2, column 3, charpos = 8
around = 'a', whole content = f0(a)
badcount: 1
bad: void
BAD:!!!!! f0(a)
ERROR-RECOV: found sync '}' at line 5
parsing pass2: try again
ERROR-RECOV: found sync '}' at line 5
parse error
= File "route.c", line 4, column 0, charpos = 34
around = '{', whole content = {
badcount: 2
bad: register struct s0 *a;
BAD:!!!!! {
bad: }
(ONCE) CPP-TYPEDEF: promoting: b
f1() is still parsed correctly.
- Arnaud
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)