Coccinelle Archive on
 help / color / Atom feed
From: Lukas Straub <>
To: Julia Lawall <>
Subject: [Cocci] Matching attributes
Date: Sat, 9 Jan 2021 00:48:41 +0100
Message-ID: <> (raw)

[-- Attachment #1.1: Type: text/plain, Size: 729 bytes --]

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 ...;


 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 #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

Cocci mailing list

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 23:48 Lukas Straub [this message]
2021-01-09  7:34 ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Coccinelle Archive on

Archives are clonable:
	git clone --mirror cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ \
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone