The question is not really why is y = mo.add(3, 4); not marked, but more why is
anything marked at all.
I'm sorry. - But I am still not pleased with an analysis result like the
following.
elfring@Sonne:~/Projekte/Coccinelle/Probe> SRC=f-ptr-test2.c && cat $SRC && echo
'-----' && PAT=assignment_pattern5.cocci && cat $PAT && echo '-----' && spatch
-sp_file $PAT $SRC
int my_addition(char a, char b)
{
return a + b;
}
int main(void)
{
struct my_operations
{
int (*add)(char a, char b);
} mo = {my_addition}, * mop = &mo;
int y = mop->add(8, 9);
y = mop->add(1, 2);
y = mo.add(3, 4);
y = mo.add(5, 6);
y = mop->add(7, 8);
}
-----
@is_assigned@
position p;
expression u, v, w, x, y;
expression f != {strcpy, strcat, fread, fclose};
identifier g != {my_strcpy, my_strcat, my_fread, my_fclose, log, add};
identifier mf;
statement S1, S2, S3, S4;
type t;
@@
(
y@p = (t) (x)(...)
|
y@p = (t) (u)->mf(...)
|
y@p = (t) (u).mf(...)
)
... when != if (<+...y...+>) S1 else S2
when != (f)(...,<+...y...+>,...)
when != (v)->g(...,<+...y...+>,...)
when != (w).g(...,<+...y...+>,...)
when != for (...;<+...y...+>;...) S3
when != while (<+...y...+>) S4
when != switch (<+...y...+>) { case ... : ... }
when != (<+...y...+>) ? ... : ...
@is_assigned_without_when_filters@
position p != is_assigned.p;
expression x, y;
type t;
@@
*y@p = (t) (x)(...)
-----
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: f-ptr-test2.c
diff =
--- f-ptr-test2.c
+++ /tmp/cocci-output-7183-fb753e-f-ptr-test2.c
@@ -10,9 +10,5 @@ int main(void)
int (*add)(char a, char b);
} mo = {my_addition}, * mop = &mo;
- int y = mop->add(8, 9);
- y = mop->add(1, 2);
- y = mo.add(3, 4);
- y = mo.add(5, 6);
y = mop->add(7, 8);
}
It seems that the last member function call won't get marked from the shown
expression variants.
If you are trying to find cases where variables are assigned but are not used,
then you are not at all doing that. Indeed you are doing the opposite.
Would you like to suggest another filter approach?
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)