The problem is that there is an isomorphism that removes casts that no one
seems to care about, ie where the casted type is not used otherwise.  But
in this case, it means that the rule can match in two ways.  The solution
it to disable the isomorphism.  Make the very first line be

@disable drop_cast@

julia

On Thu, 14 Jun 2012, Joe Perches wrote:

> spatch seems to have a problem with
> this input script.
>
> $ cat recast_2.cocci
> @@
> type T;
> T p;
> @@
>
> -       (T)p
> +       p
>
> $ cat t.c
> #include <stdio.h>
> #include <stdlib.h>
>
> #define macro(x)   ((x) & 1)
>
> int main(int argc, char** argv)
> {
>       int i = 1;
>       int j;
>
>       j = (int)macro(i);
>
>       return 0;
> }
>
> $ spatch -sp-file recast_2.cocci t.c
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: t.c
>
> previous modification:
> MINUS
> According to environment 2:
>    rule starting on line 1.T -> int
>    rule starting on line 1.p -> ((x) &
> 1)
>
> current modification:
> MINUS
> According to environment 2:
>    rule starting on line 1.T -> int
>    rule starting on line 1.p -> (x) &
> 1
>
> Fatal error: exception Failure("rule starting on line 1: already tagged token:
> C code context
> File "t.c", line 4, column 26,  charpos = 66
>     around = '1', whole content = #define macro(x)   ((x) & 1)")
>
>
>
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to