* [Cocci] Odd behaviour for ... and sub-expressions
@ 2016-04-29 17:36 Michael Stefaniuc
2016-04-29 19:00 ` Julia Lawall
0 siblings, 1 reply; 2+ messages in thread
From: Michael Stefaniuc @ 2016-04-29 17:36 UTC (permalink / raw)
To: cocci
Hello,
I'm observing an odd behaviour difference when using an ellipses
following a plain expression or a sub-expression in <+... ...+>
Following coccinelle rule does not behave as expected:
// Sanity check to not use a RECT field in the SetRect.
@@
expression rect;
identifier fld;
@@
SetRect(&rect, ...,
- <+... rect.fld ...+>
+ BADBADBAD
,...)
It does not matches cases where the bad subexpression is the last
argument of the function call. E.g. for
void foo(void)
{
RECT r;
SetRect(&r, 0, 0, r.left, 0);
SetRect(&r, 0, 0, 0, r.top);
SetRect(&r, 0, 0, r.left + 1, 0);
SetRect(&r, 0, 0, 0, r.top + 1);
}
it modifies just the 1st and 3rd SetRect() call while it should match
all 4 cases.
If I just use rect.fld without the <+... ...+> the rule will match
correctly both the 1st and 2nd SetRect() call aka it matches at the end
of the argument list too.
Is this a bug? I'm running coccinelle 1.0.4.
thanks
bye
michael
P.S.: As a workaround I have created a separate rule for the last
argument and that works.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Cocci] Odd behaviour for ... and sub-expressions
2016-04-29 17:36 [Cocci] Odd behaviour for ... and sub-expressions Michael Stefaniuc
@ 2016-04-29 19:00 ` Julia Lawall
0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2016-04-29 19:00 UTC (permalink / raw)
To: cocci
On Fri, 29 Apr 2016, Michael Stefaniuc wrote:
> Hello,
>
> I'm observing an odd behaviour difference when using an ellipses
> following a plain expression or a sub-expression in <+... ...+>
>
> Following coccinelle rule does not behave as expected:
>
> // Sanity check to not use a RECT field in the SetRect.
> @@
> expression rect;
> identifier fld;
> @@
> SetRect(&rect, ...,
> - <+... rect.fld ...+>
> + BADBADBAD
> ,...)
>
> It does not matches cases where the bad subexpression is the last
> argument of the function call. E.g. for
>
> void foo(void)
> {
> RECT r;
> SetRect(&r, 0, 0, r.left, 0);
> SetRect(&r, 0, 0, 0, r.top);
> SetRect(&r, 0, 0, r.left + 1, 0);
> SetRect(&r, 0, 0, 0, r.top + 1);
> }
>
> it modifies just the 1st and 3rd SetRect() call while it should match
> all 4 cases.
>
> If I just use rect.fld without the <+... ...+> the rule will match
> correctly both the 1st and 2nd SetRect() call aka it matches at the end
> of the argument list too.
>
> Is this a bug? I'm running coccinelle 1.0.4.
Surely a bug. Thanks for the report.
julia
>
> thanks
> bye
> michael
>
> P.S.: As a workaround I have created a separate rule for the last
> argument and that works.
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-29 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29 17:36 [Cocci] Odd behaviour for ... and sub-expressions Michael Stefaniuc
2016-04-29 19:00 ` Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.