Release coccinelle-0.1.11rc1
[bpt/coccinelle.git] / scripts / coccicheck / cocci / unused.cocci
1 // A variable is only initialized to a constant and is never used otherwise
2 //
3 // Confidence: High
4 // Copyright: (C) Gilles Muller, Julia Lawall, EMN, DIKU. GPLv2.
5 // URL: http://www.emn.fr/x-info/coccinelle/rules/unused.html
6 // Options:
7
8 virtual org,diff
9
10 @e@
11 identifier i;
12 position p;
13 type T;
14 @@
15
16 extern T i@p;
17
18 @v forall@
19 type T;
20 identifier i;
21 constant C;
22 position p1 != e.p;
23 position p2;
24 @@
25
26 T i@p1;
27 <+... when != i
28 i@p2 = C;
29 ...+>
30
31 @script:python depends on org@
32 p1 << v.p1;
33 p2 << v.p2;
34 @@
35
36 cocci.print_main("",p1)
37 cocci.print_secs("",p2)
38
39 @depends on diff exists@
40 identifier i;
41 position v.p1, v.p2;
42 @@
43
44 *i@p1
45 ...
46 *i@p2