[Cocci] Problem when using a macro for mangling function names
Yoann Padioleau
padator at wanadoo.fr
Fri Mar 20 00:20:32 CET 2009
Julia Lawall <julia at diku.dk> writes:
> It does seem to be a bug, derived from incorrect parsing of the C code.
> Unfortunately, Yoann, who knows most about the parser, is probably not
> able to look into it right now.
Apparently this is because in C, the following code is syntaxically correct:
void a(int)(int x);
but not semantically correct. gcc even returns this semantic error message:
xxx.c:1: error: 'a' declared as function returning a function
Our C parser didn't do this verification, and seeing your
void METH(foo)(int x)
our parser wrongly infered that 'foo' was a typedef and constructs
an invalid AST that get later our unparser confused.
I fixed the parser to return the same error that gcc, and print
a message to give a hint about how to fix the problem
(what Julia suggested below).
Thanks for the bug report. The new version of coccinelle that
we will soon release will contain this bugfix.
>
> Do you have a lot of macros like this? If this is the only one, you can
> add the following to your standard.h file:
>
> #define METH(x) x
>
> Note that the standard.h file that you use is in /usr/local/share. On the
> other hand, since you are not working on Linux code, the definitions in
> that file are perhaps not of much interest to you. You can thus also put
> this #define in a local file and include it using the -macro_file option
> to spatch, at least for initial testing.
>
> julia
> _______________________________________________
> Cocci mailing list
> Cocci at diku.dk
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
More information about the Cocci
mailing list