Hi,

I'm trying to do my first steps with Coccinelle but can't get the following to work: basically, for debugging, I want to implement a poor man's array bound check by doing something like

@@
expression E;
@@

- sprite[E]
+ sprite[{( int tmp=E; (tmp<0 ? (*(int*)123=234) : tmp) )}]

.
Since GCC's statement-exprs are probably unsupported, a second try is

+ sprite[tmp_global=(E), (tmp_global<0 ? (*(int*)123=234) : tmp_global)]

.
However, this also gives a parse error although it's valid C code. Is the comma operator unsupported or am I missing something? Since there be always cases where the user "knows better", is there a way to match syntactically, but replace in a textual fashion? So that in the above example, the "-" line would truly do a parse but the "+" line would only substitute the meta-variables but leave everything else as literal text.

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

Reply via email to