adlint 2.4.10 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +209 -0
- data/MANIFEST +4 -0
- data/NEWS +19 -4
- data/etc/mesg.d/c_builtin/en_US/messages.yml +2 -2
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +2 -2
- data/etc/mesg.d/core/en_US/messages.yml +1 -1
- data/etc/mesg.d/core/ja_JP/messages.yml +1 -1
- data/features/code_check/W0088.feature +153 -0
- data/features/code_check/W0582.feature +72 -0
- data/features/code_check/W0583.feature +93 -0
- data/features/code_check/W0584.feature +139 -0
- data/features/code_check/W0635.feature +0 -2
- data/features/code_check/W0722.feature +68 -0
- data/features/code_check/W0723.feature +1 -1
- data/features/code_check/W0732.feature +0 -15
- data/features/code_check/W0733.feature +0 -15
- data/features/code_check/W0734.feature +0 -36
- data/features/code_check/W0735.feature +0 -40
- data/features/code_check/W0745.feature +1 -0
- data/features/code_check/W9003.feature +85 -0
- data/lib/adlint/c/conv.rb +32 -0
- data/lib/adlint/c/interp.rb +17 -1
- data/lib/adlint/c/mediator.rb +2 -0
- data/lib/adlint/c/syntax.rb +72 -0
- data/lib/adlint/c/type.rb +10 -3
- data/lib/adlint/exam/c_builtin/c_check.rb +164 -48
- data/lib/adlint/version.rb +3 -3
- data/share/doc/developers_guide_ja.html +3 -3
- data/share/doc/developers_guide_ja.texi +1 -1
- data/share/doc/users_guide_en.html +12 -12
- data/share/doc/users_guide_en.texi +10 -10
- data/share/doc/users_guide_ja.html +12 -12
- data/share/doc/users_guide_ja.texi +10 -10
- metadata +6 -2
@@ -30,15 +30,10 @@ Feature: W0734
|
|
30
30
|
| W0104 | 1 | 29 |
|
31
31
|
| W0104 | 1 | 36 |
|
32
32
|
| W0629 | 1 | 13 |
|
33
|
-
| W0088 | 5 | 17 |
|
34
33
|
| W0734 | 5 | 9 |
|
35
|
-
| W0088 | 6 | 17 |
|
36
34
|
| W0734 | 6 | 9 |
|
37
|
-
| W0088 | 7 | 17 |
|
38
35
|
| W0734 | 7 | 9 |
|
39
|
-
| W0088 | 8 | 17 |
|
40
36
|
| W0734 | 8 | 9 |
|
41
|
-
| W0088 | 9 | 17 |
|
42
37
|
| W0734 | 9 | 9 |
|
43
38
|
| W0628 | 1 | 13 |
|
44
39
|
|
@@ -69,15 +64,11 @@ Feature: W0734
|
|
69
64
|
| W0104 | 1 | 29 |
|
70
65
|
| W0104 | 1 | 43 |
|
71
66
|
| W0629 | 1 | 13 |
|
72
|
-
| W0088 | 5 | 17 |
|
73
67
|
| W0734 | 5 | 9 |
|
74
68
|
| W0508 | 6 | 17 |
|
75
69
|
| W0734 | 6 | 9 |
|
76
|
-
| W0088 | 7 | 17 |
|
77
70
|
| W0734 | 7 | 9 |
|
78
|
-
| W0088 | 8 | 17 |
|
79
71
|
| W0734 | 8 | 9 |
|
80
|
-
| W0088 | 9 | 17 |
|
81
72
|
| W0734 | 9 | 9 |
|
82
73
|
| W0108 | 6 | 23 |
|
83
74
|
| W0628 | 1 | 13 |
|
@@ -109,15 +100,10 @@ Feature: W0734
|
|
109
100
|
| W0104 | 1 | 29 |
|
110
101
|
| W0104 | 1 | 36 |
|
111
102
|
| W0629 | 1 | 13 |
|
112
|
-
| W0088 | 5 | 17 |
|
113
103
|
| W0734 | 5 | 9 |
|
114
|
-
| W0088 | 6 | 17 |
|
115
104
|
| W0734 | 6 | 9 |
|
116
|
-
| W0088 | 7 | 17 |
|
117
105
|
| W0734 | 7 | 9 |
|
118
|
-
| W0088 | 8 | 17 |
|
119
106
|
| W0734 | 8 | 9 |
|
120
|
-
| W0088 | 9 | 17 |
|
121
107
|
| W0734 | 9 | 9 |
|
122
108
|
| W0628 | 1 | 13 |
|
123
109
|
|
@@ -148,15 +134,11 @@ Feature: W0734
|
|
148
134
|
| W0104 | 1 | 29 |
|
149
135
|
| W0104 | 1 | 43 |
|
150
136
|
| W0629 | 1 | 13 |
|
151
|
-
| W0088 | 5 | 17 |
|
152
137
|
| W0734 | 5 | 9 |
|
153
138
|
| W0508 | 6 | 17 |
|
154
139
|
| W0734 | 6 | 9 |
|
155
|
-
| W0088 | 7 | 17 |
|
156
140
|
| W0734 | 7 | 9 |
|
157
|
-
| W0088 | 8 | 17 |
|
158
141
|
| W0734 | 8 | 9 |
|
159
|
-
| W0088 | 9 | 17 |
|
160
142
|
| W0734 | 9 | 9 |
|
161
143
|
| W0108 | 6 | 23 |
|
162
144
|
| W0628 | 1 | 13 |
|
@@ -191,15 +173,10 @@ Feature: W0734
|
|
191
173
|
| W0104 | 1 | 29 |
|
192
174
|
| W0104 | 1 | 36 |
|
193
175
|
| W0629 | 1 | 13 |
|
194
|
-
| W0088 | 5 | 18 |
|
195
176
|
| W0734 | 5 | 9 |
|
196
|
-
| W0088 | 6 | 18 |
|
197
177
|
| W0734 | 6 | 9 |
|
198
|
-
| W0088 | 7 | 17 |
|
199
178
|
| W0734 | 7 | 9 |
|
200
|
-
| W0088 | 8 | 17 |
|
201
179
|
| W0734 | 8 | 9 |
|
202
|
-
| W0088 | 9 | 17 |
|
203
180
|
| W0734 | 9 | 9 |
|
204
181
|
| W0628 | 1 | 13 |
|
205
182
|
|
@@ -233,15 +210,10 @@ Feature: W0734
|
|
233
210
|
| W0104 | 1 | 29 |
|
234
211
|
| W0104 | 1 | 36 |
|
235
212
|
| W0629 | 1 | 13 |
|
236
|
-
| W0088 | 5 | 18 |
|
237
213
|
| W0734 | 5 | 9 |
|
238
|
-
| W0088 | 6 | 18 |
|
239
214
|
| W0734 | 6 | 9 |
|
240
|
-
| W0088 | 7 | 17 |
|
241
215
|
| W0734 | 7 | 9 |
|
242
|
-
| W0088 | 8 | 17 |
|
243
216
|
| W0734 | 8 | 9 |
|
244
|
-
| W0088 | 9 | 17 |
|
245
217
|
| W0734 | 9 | 9 |
|
246
218
|
| W0628 | 1 | 13 |
|
247
219
|
|
@@ -275,15 +247,11 @@ Feature: W0734
|
|
275
247
|
| W0104 | 1 | 29 |
|
276
248
|
| W0104 | 1 | 43 |
|
277
249
|
| W0629 | 1 | 13 |
|
278
|
-
| W0088 | 5 | 18 |
|
279
250
|
| W0734 | 5 | 9 |
|
280
251
|
| W0508 | 6 | 18 |
|
281
252
|
| W0734 | 6 | 9 |
|
282
|
-
| W0088 | 7 | 17 |
|
283
253
|
| W0734 | 7 | 9 |
|
284
|
-
| W0088 | 8 | 17 |
|
285
254
|
| W0734 | 8 | 9 |
|
286
|
-
| W0088 | 9 | 17 |
|
287
255
|
| W0734 | 9 | 9 |
|
288
256
|
| W0108 | 6 | 24 |
|
289
257
|
| W0628 | 1 | 13 |
|
@@ -318,15 +286,11 @@ Feature: W0734
|
|
318
286
|
| W0104 | 1 | 29 |
|
319
287
|
| W0104 | 1 | 43 |
|
320
288
|
| W0629 | 1 | 13 |
|
321
|
-
| W0088 | 5 | 18 |
|
322
289
|
| W0734 | 5 | 9 |
|
323
290
|
| W0508 | 6 | 18 |
|
324
291
|
| W0734 | 6 | 9 |
|
325
|
-
| W0088 | 7 | 17 |
|
326
292
|
| W0734 | 7 | 9 |
|
327
|
-
| W0088 | 8 | 17 |
|
328
293
|
| W0734 | 8 | 9 |
|
329
|
-
| W0088 | 9 | 17 |
|
330
294
|
| W0734 | 9 | 9 |
|
331
295
|
| W0108 | 6 | 24 |
|
332
296
|
| W0628 | 1 | 13 |
|
@@ -30,15 +30,10 @@ Feature: W0735
|
|
30
30
|
| W0104 | 1 | 29 |
|
31
31
|
| W0104 | 1 | 36 |
|
32
32
|
| W0629 | 1 | 13 |
|
33
|
-
| W0088 | 5 | 11 |
|
34
33
|
| W0735 | 5 | 14 |
|
35
|
-
| W0088 | 6 | 11 |
|
36
34
|
| W0735 | 6 | 14 |
|
37
|
-
| W0088 | 7 | 11 |
|
38
35
|
| W0735 | 7 | 14 |
|
39
|
-
| W0088 | 8 | 11 |
|
40
36
|
| W0735 | 8 | 14 |
|
41
|
-
| W0088 | 9 | 11 |
|
42
37
|
| W0735 | 9 | 14 |
|
43
38
|
| W0628 | 1 | 13 |
|
44
39
|
|
@@ -69,15 +64,10 @@ Feature: W0735
|
|
69
64
|
| W0104 | 1 | 36 |
|
70
65
|
| W0104 | 1 | 43 |
|
71
66
|
| W0629 | 1 | 13 |
|
72
|
-
| W0088 | 5 | 18 |
|
73
67
|
| W0735 | 5 | 21 |
|
74
|
-
| W0088 | 6 | 17 |
|
75
68
|
| W0735 | 6 | 20 |
|
76
|
-
| W0088 | 7 | 18 |
|
77
69
|
| W0735 | 7 | 21 |
|
78
|
-
| W0088 | 8 | 17 |
|
79
70
|
| W0735 | 8 | 20 |
|
80
|
-
| W0088 | 9 | 18 |
|
81
71
|
| W0735 | 9 | 21 |
|
82
72
|
| W0108 | 6 | 12 |
|
83
73
|
| W0628 | 1 | 13 |
|
@@ -109,15 +99,10 @@ Feature: W0735
|
|
109
99
|
| W0104 | 1 | 29 |
|
110
100
|
| W0104 | 1 | 36 |
|
111
101
|
| W0629 | 1 | 13 |
|
112
|
-
| W0088 | 5 | 11 |
|
113
102
|
| W0735 | 5 | 14 |
|
114
|
-
| W0088 | 6 | 11 |
|
115
103
|
| W0735 | 6 | 14 |
|
116
|
-
| W0088 | 7 | 11 |
|
117
104
|
| W0735 | 7 | 14 |
|
118
|
-
| W0088 | 8 | 11 |
|
119
105
|
| W0735 | 8 | 14 |
|
120
|
-
| W0088 | 9 | 11 |
|
121
106
|
| W0735 | 9 | 14 |
|
122
107
|
| W0628 | 1 | 13 |
|
123
108
|
|
@@ -148,15 +133,10 @@ Feature: W0735
|
|
148
133
|
| W0104 | 1 | 36 |
|
149
134
|
| W0104 | 1 | 43 |
|
150
135
|
| W0629 | 1 | 13 |
|
151
|
-
| W0088 | 5 | 18 |
|
152
136
|
| W0735 | 5 | 21 |
|
153
|
-
| W0088 | 6 | 17 |
|
154
137
|
| W0735 | 6 | 20 |
|
155
|
-
| W0088 | 7 | 18 |
|
156
138
|
| W0735 | 7 | 21 |
|
157
|
-
| W0088 | 8 | 17 |
|
158
139
|
| W0735 | 8 | 20 |
|
159
|
-
| W0088 | 9 | 18 |
|
160
140
|
| W0735 | 9 | 21 |
|
161
141
|
| W0108 | 6 | 12 |
|
162
142
|
| W0628 | 1 | 13 |
|
@@ -191,15 +171,10 @@ Feature: W0735
|
|
191
171
|
| W0104 | 1 | 29 |
|
192
172
|
| W0104 | 1 | 36 |
|
193
173
|
| W0629 | 1 | 13 |
|
194
|
-
| W0088 | 5 | 11 |
|
195
174
|
| W0735 | 5 | 14 |
|
196
|
-
| W0088 | 6 | 11 |
|
197
175
|
| W0735 | 6 | 14 |
|
198
|
-
| W0088 | 7 | 11 |
|
199
176
|
| W0735 | 7 | 14 |
|
200
|
-
| W0088 | 8 | 11 |
|
201
177
|
| W0735 | 8 | 14 |
|
202
|
-
| W0088 | 9 | 11 |
|
203
178
|
| W0735 | 9 | 14 |
|
204
179
|
| W0628 | 1 | 13 |
|
205
180
|
|
@@ -233,15 +208,10 @@ Feature: W0735
|
|
233
208
|
| W0104 | 1 | 29 |
|
234
209
|
| W0104 | 1 | 36 |
|
235
210
|
| W0629 | 1 | 13 |
|
236
|
-
| W0088 | 5 | 11 |
|
237
211
|
| W0735 | 5 | 14 |
|
238
|
-
| W0088 | 6 | 11 |
|
239
212
|
| W0735 | 6 | 14 |
|
240
|
-
| W0088 | 7 | 11 |
|
241
213
|
| W0735 | 7 | 14 |
|
242
|
-
| W0088 | 8 | 11 |
|
243
214
|
| W0735 | 8 | 14 |
|
244
|
-
| W0088 | 9 | 11 |
|
245
215
|
| W0735 | 9 | 14 |
|
246
216
|
| W0628 | 1 | 13 |
|
247
217
|
|
@@ -275,15 +245,10 @@ Feature: W0735
|
|
275
245
|
| W0104 | 1 | 36 |
|
276
246
|
| W0104 | 1 | 43 |
|
277
247
|
| W0629 | 1 | 13 |
|
278
|
-
| W0088 | 5 | 18 |
|
279
248
|
| W0735 | 5 | 21 |
|
280
|
-
| W0088 | 6 | 17 |
|
281
249
|
| W0735 | 6 | 20 |
|
282
|
-
| W0088 | 7 | 18 |
|
283
250
|
| W0735 | 7 | 21 |
|
284
|
-
| W0088 | 8 | 17 |
|
285
251
|
| W0735 | 8 | 20 |
|
286
|
-
| W0088 | 9 | 18 |
|
287
252
|
| W0735 | 9 | 21 |
|
288
253
|
| W0108 | 6 | 12 |
|
289
254
|
| W0628 | 1 | 13 |
|
@@ -318,15 +283,10 @@ Feature: W0735
|
|
318
283
|
| W0104 | 1 | 36 |
|
319
284
|
| W0104 | 1 | 43 |
|
320
285
|
| W0629 | 1 | 13 |
|
321
|
-
| W0088 | 5 | 18 |
|
322
286
|
| W0735 | 5 | 21 |
|
323
|
-
| W0088 | 6 | 17 |
|
324
287
|
| W0735 | 6 | 20 |
|
325
|
-
| W0088 | 7 | 18 |
|
326
288
|
| W0735 | 7 | 21 |
|
327
|
-
| W0088 | 8 | 17 |
|
328
289
|
| W0735 | 8 | 20 |
|
329
|
-
| W0088 | 9 | 18 |
|
330
290
|
| W0735 | 9 | 21 |
|
331
291
|
| W0108 | 6 | 12 |
|
332
292
|
| W0628 | 1 | 13 |
|
@@ -182,3 +182,88 @@ Feature: W9003
|
|
182
182
|
| W0031 | 3 | 13 |
|
183
183
|
| W0104 | 3 | 13 |
|
184
184
|
| W0628 | 3 | 5 |
|
185
|
+
|
186
|
+
Scenario: implicit conversion to void pointer
|
187
|
+
Given a target source named "fixture.c" with:
|
188
|
+
"""
|
189
|
+
typedef struct foo { int i; } foo_t;
|
190
|
+
extern void foo(foo_t *);
|
191
|
+
|
192
|
+
typedef struct bar { int i; } bar_t;
|
193
|
+
extern void bar(bar_t *);
|
194
|
+
|
195
|
+
extern void baz(void *);
|
196
|
+
|
197
|
+
static void qux(foo_t *f, bar_t *b)
|
198
|
+
{
|
199
|
+
foo(b); /* W9003 */
|
200
|
+
bar(f); /* W9003 */
|
201
|
+
foo(f); /* OK */
|
202
|
+
baz(f); /* OK */
|
203
|
+
}
|
204
|
+
"""
|
205
|
+
When I successfully run `adlint fixture.c` on noarch
|
206
|
+
Then the output should exactly match with:
|
207
|
+
| mesg | line | column |
|
208
|
+
| W0118 | 2 | 13 |
|
209
|
+
| W0118 | 5 | 13 |
|
210
|
+
| W0118 | 7 | 13 |
|
211
|
+
| W1076 | 9 | 13 |
|
212
|
+
| W9003 | 11 | 9 |
|
213
|
+
| W9003 | 12 | 9 |
|
214
|
+
| W0104 | 9 | 24 |
|
215
|
+
| W0104 | 9 | 34 |
|
216
|
+
| W0105 | 9 | 24 |
|
217
|
+
| W0105 | 9 | 34 |
|
218
|
+
| W0629 | 9 | 13 |
|
219
|
+
| W0628 | 9 | 13 |
|
220
|
+
|
221
|
+
Scenario: implicit convertion from void pointer
|
222
|
+
Given a target source named "fixture.c" with:
|
223
|
+
"""
|
224
|
+
typedef struct foo { int i; } foo_t;
|
225
|
+
extern void *foo(foo_t *);
|
226
|
+
|
227
|
+
static void bar(void *p)
|
228
|
+
{
|
229
|
+
foo_t *f = foo(p); /* legal but W9003 */
|
230
|
+
}
|
231
|
+
"""
|
232
|
+
When I successfully run `adlint fixture.c` on noarch
|
233
|
+
Then the output should exactly match with:
|
234
|
+
| mesg | line | column |
|
235
|
+
| W0118 | 2 | 14 |
|
236
|
+
| W1076 | 4 | 13 |
|
237
|
+
| W9003 | 6 | 20 |
|
238
|
+
| W9003 | 6 | 19 |
|
239
|
+
| W0100 | 6 | 12 |
|
240
|
+
| W0104 | 4 | 23 |
|
241
|
+
| W0105 | 4 | 23 |
|
242
|
+
| W0629 | 4 | 13 |
|
243
|
+
| W0628 | 4 | 13 |
|
244
|
+
|
245
|
+
Scenario: implicit convertion of constant pointer
|
246
|
+
Given a target source named "fixture.c" with:
|
247
|
+
"""
|
248
|
+
static void foo(void *p)
|
249
|
+
{
|
250
|
+
int *p1 = NULL; /* OK */
|
251
|
+
int *p2 = 0; /* OK */
|
252
|
+
int *p3 = p; /* legal but W9003 */
|
253
|
+
int *p4 = 3; /* W9003 */
|
254
|
+
}
|
255
|
+
"""
|
256
|
+
When I successfully run `adlint fixture.c` on noarch
|
257
|
+
Then the output should exactly match with:
|
258
|
+
| mesg | line | column |
|
259
|
+
| W1076 | 1 | 13 |
|
260
|
+
| W9003 | 5 | 15 |
|
261
|
+
| W9003 | 6 | 15 |
|
262
|
+
| W0100 | 3 | 10 |
|
263
|
+
| W0100 | 4 | 10 |
|
264
|
+
| W0100 | 5 | 10 |
|
265
|
+
| W0100 | 6 | 10 |
|
266
|
+
| W0104 | 1 | 23 |
|
267
|
+
| W0105 | 1 | 23 |
|
268
|
+
| W0629 | 1 | 13 |
|
269
|
+
| W0628 | 1 | 13 |
|
data/lib/adlint/c/conv.rb
CHANGED
@@ -86,6 +86,33 @@ module C #:nodoc:
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
def untyped_pointer_conversion?(from_type, to_type, from_value)
|
90
|
+
return false unless to_type.pointer?
|
91
|
+
|
92
|
+
# NOTE: Untyped pointer conversion is defined as below;
|
93
|
+
#
|
94
|
+
# from_type | to_type | result
|
95
|
+
# ------------------+------------------+-----------------
|
96
|
+
# void pointer | void pointer | true
|
97
|
+
# void pointer | non-void pointer | true
|
98
|
+
# non-void pointer | void pointer | true
|
99
|
+
# non-void pointer | non-void pointer | false
|
100
|
+
# non-enum integer | void pointer | from_value == 0
|
101
|
+
# non-enum integer | non-void pointer | from_value == 0
|
102
|
+
# enum | void pointer | false
|
103
|
+
# enum | non-void pointer | false
|
104
|
+
# other | void pointer | true
|
105
|
+
# other | non-void pointer | false
|
106
|
+
case
|
107
|
+
when from_type.pointer?
|
108
|
+
void_pointer?(from_type) || void_pointer?(to_type)
|
109
|
+
when from_type.integer?
|
110
|
+
!from_type.enum? && from_value.must_be_equal_to?(ScalarValue.of(0))
|
111
|
+
else
|
112
|
+
void_pointer?(to_type)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
89
116
|
private
|
90
117
|
def wrap_around_value(original, to_type)
|
91
118
|
return original.value unless original.type.scalar? && to_type.scalar?
|
@@ -105,6 +132,11 @@ module C #:nodoc:
|
|
105
132
|
|
106
133
|
original.value
|
107
134
|
end
|
135
|
+
|
136
|
+
def void_pointer?(type)
|
137
|
+
unqualified_type = type.unqualify
|
138
|
+
unqualified_type.pointer? && unqualified_type.base_type.void?
|
139
|
+
end
|
108
140
|
end
|
109
141
|
|
110
142
|
# Host class of this module must include StandardTypeCatalogAccessor.
|
data/lib/adlint/c/interp.rb
CHANGED
@@ -314,6 +314,14 @@ module C #:nodoc:
|
|
314
314
|
:assignment_expression, :lhs_variable,
|
315
315
|
:rhs_variable
|
316
316
|
|
317
|
+
# NOTE: Notified when the interpreter starts execution of a
|
318
|
+
# expression-statement.
|
319
|
+
def_plugin_and_notifier :expression_stmt_started, :expression_statement
|
320
|
+
|
321
|
+
# NOTE: Notified when the interpreter ends execution of a
|
322
|
+
# expression-statement.
|
323
|
+
def_plugin_and_notifier :expression_stmt_ended, :expression_statement
|
324
|
+
|
317
325
|
# NOTE: Notified when the interpreter starts execution of a
|
318
326
|
# switch-statement.
|
319
327
|
def_plugin_and_notifier :switch_stmt_started, :switch_statement
|
@@ -1008,7 +1016,11 @@ module C #:nodoc:
|
|
1008
1016
|
checkpoint(node.location)
|
1009
1017
|
|
1010
1018
|
node.executed = true
|
1019
|
+
notify_expression_stmt_started(node)
|
1020
|
+
|
1011
1021
|
interpret(node.expression) if node.expression
|
1022
|
+
ensure
|
1023
|
+
notify_expression_stmt_ended(node)
|
1012
1024
|
end
|
1013
1025
|
|
1014
1026
|
def visit_if_statement(node)
|
@@ -1278,7 +1290,11 @@ module C #:nodoc:
|
|
1278
1290
|
# controlling variable is referred by the controlling
|
1279
1291
|
# expression at the last iteration.
|
1280
1292
|
# FIXME: This re-interpretation of the controlling expression may
|
1281
|
-
#
|
1293
|
+
# cause duplicative warning messages.
|
1294
|
+
# FIXME: This re-interpretation of the controlling expression always
|
1295
|
+
# causes "logical-expression must be false" warnings about a
|
1296
|
+
# one-time-for-loop. To avoid this, now, workarounds are in
|
1297
|
+
# builtin code checks W0609 and W0610.
|
1282
1298
|
interpret(explicit_ctrlexpr)
|
1283
1299
|
end
|
1284
1300
|
end
|
data/lib/adlint/c/mediator.rb
CHANGED
@@ -222,6 +222,8 @@ module C #:nodoc:
|
|
222
222
|
def_delegator :interpreter, :notify_prefix_decrement_expr_evaled
|
223
223
|
def_delegator :interpreter, :notify_postfix_decrement_expr_evaled
|
224
224
|
def_delegator :interpreter, :notify_assignment_expr_evaled
|
225
|
+
def_delegator :interpreter, :notify_expression_stmt_started
|
226
|
+
def_delegator :interpreter, :notify_expression_stmt_ended
|
225
227
|
def_delegator :interpreter, :notify_switch_stmt_started
|
226
228
|
def_delegator :interpreter, :notify_switch_stmt_ended
|
227
229
|
def_delegator :interpreter, :notify_while_stmt_started
|
data/lib/adlint/c/syntax.rb
CHANGED
@@ -325,6 +325,28 @@ module C #:nodoc:
|
|
325
325
|
end
|
326
326
|
module_function :collect_additive_expressions
|
327
327
|
|
328
|
+
def collect_relational_expressions(node)
|
329
|
+
if node
|
330
|
+
RelationalExpressionCollector.new.tap { |collector|
|
331
|
+
node.accept(collector)
|
332
|
+
}.relational_expressions
|
333
|
+
else
|
334
|
+
[]
|
335
|
+
end
|
336
|
+
end
|
337
|
+
module_function :collect_relational_expressions
|
338
|
+
|
339
|
+
def collect_equality_expressions(node)
|
340
|
+
if node
|
341
|
+
EqualityExpressionCollector.new.tap { |collector|
|
342
|
+
node.accept(collector)
|
343
|
+
}.equality_expressions
|
344
|
+
else
|
345
|
+
[]
|
346
|
+
end
|
347
|
+
end
|
348
|
+
module_function :collect_equality_expressions
|
349
|
+
|
328
350
|
def collect_logical_and_expressions(node)
|
329
351
|
if node
|
330
352
|
LogicalAndExpressionCollector.new.tap { |collector|
|
@@ -336,6 +358,17 @@ module C #:nodoc:
|
|
336
358
|
end
|
337
359
|
module_function :collect_logical_and_expressions
|
338
360
|
|
361
|
+
def collect_logical_or_expressions(node)
|
362
|
+
if node
|
363
|
+
LogicalOrExpressionCollector.new.tap { |collector|
|
364
|
+
node.accept(collector)
|
365
|
+
}.logical_or_expressions
|
366
|
+
else
|
367
|
+
[]
|
368
|
+
end
|
369
|
+
end
|
370
|
+
module_function :collect_logical_or_expressions
|
371
|
+
|
339
372
|
def collect_generic_labeled_statements(node)
|
340
373
|
if node
|
341
374
|
GenericLabeledStatementCollector.new.tap { |collector|
|
@@ -5611,6 +5644,32 @@ module C #:nodoc:
|
|
5611
5644
|
end
|
5612
5645
|
end
|
5613
5646
|
|
5647
|
+
class RelationalExpressionCollector < SyntaxTreeVisitor
|
5648
|
+
def initialize
|
5649
|
+
@relational_expressions = []
|
5650
|
+
end
|
5651
|
+
|
5652
|
+
attr_reader :relational_expressions
|
5653
|
+
|
5654
|
+
def visit_relational_expression(node)
|
5655
|
+
super
|
5656
|
+
@relational_expressions.push(node)
|
5657
|
+
end
|
5658
|
+
end
|
5659
|
+
|
5660
|
+
class EqualityExpressionCollector < SyntaxTreeVisitor
|
5661
|
+
def initialize
|
5662
|
+
@equality_expressions = []
|
5663
|
+
end
|
5664
|
+
|
5665
|
+
attr_reader :equality_expressions
|
5666
|
+
|
5667
|
+
def visit_equality_expression(node)
|
5668
|
+
super
|
5669
|
+
@equality_expressions.push(node)
|
5670
|
+
end
|
5671
|
+
end
|
5672
|
+
|
5614
5673
|
class LogicalAndExpressionCollector < SyntaxTreeVisitor
|
5615
5674
|
def initialize
|
5616
5675
|
@logical_and_expressions = []
|
@@ -5624,6 +5683,19 @@ module C #:nodoc:
|
|
5624
5683
|
end
|
5625
5684
|
end
|
5626
5685
|
|
5686
|
+
class LogicalOrExpressionCollector < SyntaxTreeVisitor
|
5687
|
+
def initialize
|
5688
|
+
@logical_or_expressions = []
|
5689
|
+
end
|
5690
|
+
|
5691
|
+
attr_reader :logical_or_expressions
|
5692
|
+
|
5693
|
+
def visit_logical_or_expression(node)
|
5694
|
+
super
|
5695
|
+
@logical_or_expressions.push(node)
|
5696
|
+
end
|
5697
|
+
end
|
5698
|
+
|
5627
5699
|
class GenericLabeledStatementCollector < SyntaxTreeVisitor
|
5628
5700
|
def initialize
|
5629
5701
|
@generic_labeled_statements = []
|