On 02/12/2011 07:49 AM, Julia Lawall wrote:
On Fri, 11 Feb 2011, Håkon Løvdal wrote:

> From the main_grammar.pdf there is an example of adding static
in front of a function. However trying to add something other than
the phrase "static" does not work. Is this by design?

$ cat main.c

int main(int argc, char *argv[]) {
         return 0;
}

$ cat add_before_function_001.cocci
@@
type T;
identifier func;
@@

+ static
T func(...) { ... }

$ cat add_before_function_002.cocci
@@
type T;
identifier func;
@@

+ STATIC
T func(...) { ... }

Coccinelle parses the before and after code, so there is no way it can
parse that.

Would a --force or similar option be easy to implement? In effect it would not try to parse the after code, and allow transforming the code in way it is not guaranteed to be standard C anymore but which would help with yet unimplemented compiler extensions or other 3rd party tools that use unusual annotations.

Jani

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

Reply via email to