[Cocci] Problem when using a macro for mangling function names
Julia Lawall
julia at diku.dk
Fri Mar 20 18:18:24 CET 2009
On Fri, 20 Mar 2009, Ali-Erdem OZCAN wrote:
> Hi Julia and Yoann,
>
> Thanks for your reactivity.
>
> Indeed I already tried to add my macro using the macro_file option before I
> sent you my e-mail yesterday. This works well with the example that I sent you
> yesterday (I did not check it before sending, sorry), but unfortunately
> doesn't work with my real use-case. For that reason, I send you now the files
> on which I am working without trying to minimize them.
>
> The output that I have from spatch for these files is
> ''spatch -macro_file macros.h -sp_file mind.cocci.bug mind.c.bug"
> --------------------------------------
> HANDLING: mind.c.bug
> warning: line 30: should c1 be a metavariable?
> Fatal error: exception Assert_failure("unparse_c.ml", 281, 8)
> --------------------------------------
> This error doesn't appear if I replace 'METH(foo)' by 'foo'.
>
> If I remove the last patch statement that uses 'c1' (the case which seems to
> be the source of the problem regarding the error message) the output that I
> have is:
> ---------------------------------------
> HANDLING: mind.c
> Fatal error: exception Assert_failure("unparse_c.ml", 281, 8)
> ---------------------------------------
The problem is that it is not allowed to bind a metavariable to the result
of expanding a macro. The error message is indeed not very graceful. The
problem though is that the metavariable is bound to foo, not METH(foo),
and would thus match the wrong thing in your later rules, so just getting
rid of the assert would not really solve the problem.
I will try to find a way to solve the problem. Is this pattern very
common in the code you are working with?
julia
More information about the Cocci
mailing list