> > The important point is the rule three, that ignores &&s where the left
> > argument is another &&.
> 
> I think that case does not work exactly because of this rule :-\.

No, three is concerned with the left argument of &&, and the problem is in 
the right argument.  I think that the problem comes from the semantics of 
( | ).  It finds a match for E1 && (E2) (ie the first branch of the or), 
and so it doesn't look for matches of the second branch.  It would only do 
that if the need for looking at the second branch were apparent from the 
specific rule, but that is not the case.

The semantic patch below works better.  It add a rule two that is 
superficially similar two two, but not really.  The purpose of two is to 
allow the E1 && E2 to match everywhere, and avoid the problem with 
disjunction.

julia

// ----------------------------------------------------------------------
// Part 1: right arguments of &&
@two disable paren@
position p;
expression E1,E2;
@@

E1 &&@p (E2)

@r disable paren@
position p1 != two.p;
position p;
expression E1,E2;
@@

E1 &&@p1 e...@p

@@
position r.p;
expression E;
@@

+(
 e...@p
+)

// ----------------------------------------------------------------------
// Part 2: left arguments of &&

@three@
position p;
expression E1,E2,E3;
@@

E1 && E2 &&@p E3

@s disable paren@
position p1!=three.p;
position p;
expression E1,E2;
@@

(
 (E1) && E2
|
e...@p &&@p1 E2
)

@a@
position s.p;
expression E;
@@

+(
 e...@p
+)

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

Reply via email to