>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(...) { ... }

$ spatch -sp_file add_before_function_001.cocci main.c
init_defs_builtins: /tmp/coccinelle/share/coccinelle/standard.h
HANDLING: main.c
diff =
--- main.c      2011-02-11 22:03:36.432804765 +0100
+++ /tmp/cocci-output-22806-3a1944-main.c       2011-02-11
23:04:00.782328621 +0100
@@ -1,5 +1,5 @@

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

$ spatch -sp_file add_before_function_002.cocci main.c
init_defs_builtins: /tmp/coccinelle/share/coccinelle/standard.h
41 42
Fatal error: exception Failure("plus: parse error:
 = File "add_before_function_002.cocci", line 7, column 0,  charpos = 41
    around = 'T', whole content = T func(...) { ... }
")
$


BR Håkon Løvdal
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to