On Mon, 6 Aug 2012, ron minnich wrote:

> it's great for the used/unused labels.
>
> It won't work for this:
>
> void a(int i){
> if (i) got out;
> printf("hi\n");
> out:
> }
>
> the out:
> }
>
> is not legal, for reasons I don't agree with, but ...
> a.c:4:1: error: label at end of compound statement
>
> one way to fix it:
> out:
> return;
> }
>
> but it's not really right:
>
> void a(int i){
> if (i) {goto out; bad:}
> printf("hi\n");
> out:
> return;
> }
> line 2 will get an error.

OK, sorry I misinterpreted your problem.  Did Coccinelle create this code
for you in the first place?  In the rule that created it could you have
anticipated the problem?

What do you want to do in the if case?

Spatch does accept eg

@@
identifier l;
@@

if (...) { ...
- l:
}

But it doesn't seem to have any impact on eg:

int main () {
  if (x) {
    l: }}

I will have to look into why, because the above code doesn't give any
parse errors.  I remember explicitly changing it not to do that.

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

Reply via email to