On Mon, 10 Oct 2011, Håkon Løvdal wrote:

> On 7 October 2011 16:39, Julia Lawall <[email protected]> wrote:
> > How about trying:
> >
> > @@
> > identifier n;
> > expression E;
> > @@
> >
> > ... when != n = E
> > cartoon_random_generator(&n)
> >
> 
> The spml above looks perfect for what I wanted, but I think I
> have found a bug in coccinelle limiting possible use.
> If I have the following code:
> 
> void test1(void)
> {
>       {
>               int i;
>               i = 42;
>               printf("i = %d\n", i);
>       }
>       {
>               int i;
>               func(&i);
>       }
> }
> 
> void test2(void)
> {
>       {
>               int j;
>               j = 42;
>               printf("j = %d\n", j);
>       }
>       {
>               int i;
>               func(&i);
>       }
> }
> 
> and use the following script:
> 
> @@
> identifier n;
> expression E;
> @@
> 
> ... when != n = E
> * func(&n)
> 
> then coccinelle only prints func in test2.
> 
> Apparently it is not forgetting "i = 42" from the first block when
> processing the
> second block in func1, however from a semantic point of view that is wrong
> since the two i variables live in different scopes. So to me that
> seems like a bug.

OK, sorry.  Change identifier to idexpression.  Then it will be associated 
with a scope.  But I'm not 100% if it will still match the int i = 3; 
case.  Something to check on.

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

Reply via email to