Release coccinelle-0.1.9-rc1
[bpt/coccinelle.git] / tests / posnpb.cocci
1 // problem with positions. in check_unprotected, we start with a set of
2 // positions, but the binding that is deduced is only relevant to one of them
3 // but since it was deduced from both of them, both of them are printed out
4 // at the end
5
6 @unprotected exists@
7 expression x;
8 identifier fld;
9 position p,p1;
10 statement S;
11 expression E;
12 @@
13
14 x@p1 = FN(...);
15 ... when != x = E
16 (
17 if (x == NULL) { ... return ...; } else S
18 |
19 x@p->fld
20 )
21
22 @check_unprotected exists@ // ensure both are present
23 position unprotected.p, unprotected.p1;
24 expression x;
25 identifier fld;
26 @@
27
28 x@p1 = FN(...);
29 ...
30 x@p->fld
31
32 @ script:python depends on check_unprotected @
33 p << unprotected.p; // position of ref
34 p1 << unprotected.p1; // position of call
35 fld << check_unprotected.fld; // identifier
36 @@
37
38 c = cocci.combine(fld,p1)
39 print " call to FN on line %s column %s" % (c.location.line,c.location.column)
40 c1 = cocci.combine(fld,p)
41 print " ref to field %s on line %s column %s" % (fld,c1.location.line,c1.location.column)