Hello Everyone,
I am toying with coccinelle to assist in writing c code. My first try is to
automatically free/cleanup local variables when they go out of scope.

This works very well already:

 @@
 type T;
 identifier var;
 attribute name autofree;
 @@
 
    T var
 -  autofree
    = NULL;
    ...
 ++ free(var);
    return ...;

But this fails:

 @@
 type T;
 identifier var;
 attribute name autofree;
 @@
 
    T var autofree;
    ...
 ++ free(var);
    return ...;

with

 minus: parse error: 
   File "autofree.cocci", line 7, column 17, charpos = 73
   around = ';',
   whole content =    T var autofree;

What am I doing wrong here?
I tried both with v1.0.8 and latest git.
-- 

Attachment: pgp5VNydxKSYJ.pgp
Description: OpenPGP digital signature

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to