On the grammer manual of cococinelle, #define could follow with a
function declaration.
#define id (PARAMSEQ(id, ε)) [top]
top :: = .... | funcdecl
fundecl ::= [fn_ctype] funinfo ∗ funid ([PARAMSEQ(param, ε)]) { [stmt_seq] }
I try to write the following code to match a function declaration with a marco:
The code try to match:
#define MY_FUNC(name) \
static void show##name() \
{ \
print("name = %s\n", name); \
}\
MY_FUNC("amy");
My cocci script:
@ print @
identifier fn, MARCO;
@@
#define MARCO(name) fn(...) {...}
This fits the grammar above:
id - MARCO
PARAMSEQ - name
top - funcdecl
funid - fn
But when I run command:
spatch --parse-cocci my.cocci
errors happen:
minus: parse error
File "my.cocci", line 4, column 20, charpos = 55
around 'fn',
whole content = #define MACRO(name) fn(...) {...}
My coccinelle version is 1.0.7
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci