On Sun, 19 Dec 2010, L. Alberto Giménez wrote:
> On Sat, Dec 18, 2010 at 09:53:50PM +0100, Julia Lawall wrote:
> > On Sat, 18 Dec 2010, L. Alberto Giménez wrote:
> > > - if (E) {
> > > if (E)
> > > S1
> > > - } else {
> > > + else
> > > S2
> > > -}
> > > -------8<----------
> > >
> > > But it doesn't work, I get a lot of errors when parsing the .cocci file
> > > itself:
> > These are warnings not errors. They refer to the inability to apply
> > certain isomorphisms. For example, neg_if switches the branches of an if
> > and replaces the test by its negation. But adjusting the braces and the
> > else makes it unwilling to do this. You could try leaving the else
> > unmodified, since you want to both remove and add it. You can find the
> > various isomorphisms it would like to apply in the file standard.iso (I'm
> > not sure where this file ends up when you get coccinelle from Debian).
> >
> > julia
>
> Hi everyone,
>
> At last I could manage to write a semantic patch that seems to work:
>
> ------8<---------------
> @@
> expression E;
> statement S1,S2;
> @@
>
>
> if (E)
> -{
> S1
> -}
> else
> -{
> S2
> -}
> --------8<--------------
>
> I didn't realize (until I found an example) that I could break the
> construction,
> and that I can just delete the unneeded braces (instead of making a diff-like
> substitution pattern (that didn't work properly, it found a lot of syntax
> errors, don't know why).
As I mentioned previously, at least what you sent me were not errors, they
were just warnings. They really are warnings. That is, they are issues
you might be concerned about but might not. You have to decide yourself
whether you expect the isomorphism to apply.
But the above solution looks much better :)
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)