On Mon, Aug 8, 2011 at 12:09 PM, Julia Lawall <[email protected]> wrote: > On Mon, 8 Aug 2011, Lucas De Marchi wrote: > >> Hi Julia >> >> On Mon, Aug 8, 2011 at 11:55 AM, Julia Lawall <[email protected]> wrote: >> > On Mon, 8 Aug 2011, Lucas De Marchi wrote: >> > >> >> Is there a cocci script to find the use of VLAs? >> > >> > What is a VLA? >> >> Variable length array. I used the following script, but it doesn't >> detect all the cases. What I need is to detect whether the size of the >> array is discovered by the compiler at compile time or at run time. >> >> >> @r1@ >> constant c1, c2, c3, c4; >> expression e; >> type x; >> identifier x1; >> @@ >> ( >> x x1[c1]; >> | >> x x1[c1 + c2]; >> | >> x x1[c1 + c2 + c3]; >> | >> x x1[c1 + c2 + c3 + c4]; >> | >> * x x1[e]; >> ) > > Maybe the following:
Yeah, this seems to work, but see the comment below. > @r@ > type t; > identifier x,i; > position p; > @@ > > t x[<+...i@p...+>] Coccinelle complains here. If I put a semicolon here then all is fine. > > @s@ > position r.p; > constant c; > type t; > identifier x; > @@ > > t x[<+...c@p...+>] and here > > @depends on !s@ > position r.p; > type t; > identifier x,i; > @@ > > *t x[<+...i@p...+>] here too thanks Lucas De Marchi _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
