Julia Lawall <[email protected]> writes:
> On Sun, 29 Apr 2018, Robert Larice wrote:
>
>> Julia Lawall <[email protected]> writes:
>>
>> > On Sun, 29 Apr 2018, Robert Larice wrote:
>> >
>> >> Hello,
>> >>
>> >> attached is a small example which does something strange
>> >> to a "int i, j;" within a "#ifdef..."
>> >> Perhaps this points to a bug in coccinelle,
>> >> Would you please check ?
>> >
>> > Thanks for the report. It looks like a bug. But everything is fine if
>> > you removed the --defined BOO.
>> >
>> > julia
>>
>> Yes, in this example it works without this --defined announcement.
>>
>> I stumbled on this with something more complex, which for some
>> reason I don't understand yet ignores a wanted transformation
>> in a #ifdef..#endif, except if I add such a --defined.
>> Only then it honours my transformation, but fails with this bug.
>
> I don't think the --defined option has been tested much. Perhaps without
> the --defined there is a parse error on the function.
>
> julia
Hello Julia,
I've attached a ripped down example to show the behaviour
with regard to the #ifdef
Without the --defined, nothing gets tranformed.
I don't see a parsing problem so far.
Perhaps you can have a look and get an idea why
here the --defined is important.
I've seen other transformations where this was not necessairy.
Best Regards,
Robert
// (compile "spatch --sp-file ex3.cocci ex3.c")
// (compile "spatch --sp-file ex3.cocci ex3.c --defined BOO")
// (compile "gcc -c -Wall ex3.c")
#define BOO
struct model;
struct model *next(struct model *);
void
foo(struct model *model)
{
#ifdef BOO
int i, j;
#endif
for (; model; model = next(model)) {
#ifdef BOO
i = 0;
#endif
j += 3;
}
}
// (compile "spatch --sp-file ex3.cocci ex3.c")
// (compile "spatch --sp-file ex3.cocci ex3.c --defined BOO")
@r0@
symbol model, i;
@@
- int i;
...
for(; model; model = ...) {
...
- i = 0;
...
}
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci