Add some functions to handle tracker lists.
[smatch.git] / validation / context-dynamic.c
blob5e172f0bebae8a7b11ddf53f235431bc0e4b312e
1 static void a(void) __attribute__ ((context(A, 0, 1)))
3 __context__(A, 1);
6 static void r(void) __attribute__ ((context(A, 1, 0)))
8 __context__(A, -1);
11 extern int condition, condition2;
13 static int tl(void) __attribute__ ((conditional_context(A, 0, 1, 0)))
15 if (condition) {
16 a();
17 return 1;
19 return 0;
22 static int tl2(void) __attribute__ ((conditional_context(A, 0, 0, 1)))
24 if (condition) {
25 a();
26 return 1;
28 return 0;
31 static int dummy(void)
33 return condition + condition2;
36 static int good_trylock1(void)
38 if (tl()) {
39 r();
43 static int good_trylock2(void)
45 if (tl()) {
46 r();
49 if (tl()) {
50 r();
53 static int good_trylock3(void)
55 a();
56 if (tl()) {
57 r();
59 r();
60 if (tl()) {
61 r();
65 static int good_trylock4(void)
67 a();
68 if (tl()) {
69 r();
71 if (tl()) {
72 r();
74 r();
77 static void bad_trylock1(void)
79 a();
80 if (dummy()) {
81 r();
83 r();
86 static int good_trylock5(void)
88 if (!tl2()) {
89 r();
93 static int good_trylock6(void)
95 if (!tl2()) {
96 r();
99 if (!tl2()) {
100 r();
103 static int good_trylock7(void)
105 a();
106 if (!tl2()) {
107 r();
109 r();
110 if (!tl2()) {
111 r();
115 static int good_trylock8(void)
117 a();
118 if (!tl2()) {
119 r();
121 if (!tl2()) {
122 r();
124 r();
127 static void bad_trylock2(void)
129 a();
130 if (!dummy()) {
131 r();
133 r();
136 static int good_switch(void)
138 switch (condition) {
139 case 1:
140 a();
141 break;
142 case 2:
143 a();
144 break;
145 case 3:
146 a();
147 break;
148 default:
149 a();
151 r();
154 static void bad_lock1(void)
156 r();
157 a();
161 * check-name: Check -Wcontext with lock trylocks
163 * check-error-start
164 context-dynamic.c:83:6: warning: context problem in 'bad_trylock1': 'r' expected different context
165 context-dynamic.c:83:6: context 'A': wanted >= 1, got 0
166 context-dynamic.c:133:6: warning: context problem in 'bad_trylock2': 'r' expected different context
167 context-dynamic.c:133:6: context 'A': wanted >= 1, got 0
168 context-dynamic.c:156:6: warning: context problem in 'bad_lock1': 'r' expected different context
169 context-dynamic.c:156:6: context 'A': wanted >= 1, got 0
170 * check-error-end