adlint 2.6.0 → 2.6.2
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 +122 -0
- data/MANIFEST +1 -0
- data/NEWS +23 -4
- data/README +1 -1
- data/Rakefile +1 -1
- data/etc/mesg.d/c_builtin/en_US/messages.yml +8 -8
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +8 -8
- 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/W0599.feature +71 -0
- data/lib/adlint/c/builtin.rb +1 -1
- data/lib/adlint/c/const.rb +60 -60
- data/lib/adlint/c/conv.rb +3 -3
- data/lib/adlint/c/ctrlexpr.rb +278 -357
- data/lib/adlint/c/expr.rb +1232 -1637
- data/lib/adlint/c/format.rb +26 -26
- data/lib/adlint/c/interp.rb +339 -391
- data/lib/adlint/c/mediator.rb +1 -2
- data/lib/adlint/c/object.rb +8 -9
- data/lib/adlint/c/seqp.rb +1 -1
- data/lib/adlint/c/syntax.rb +6 -6
- data/lib/adlint/c/type.rb +8 -8
- data/lib/adlint/cpp/eval.rb +1 -1
- data/lib/adlint/cpp/macro.rb +4 -4
- data/lib/adlint/cpp/util.rb +1 -1
- data/lib/adlint/exam/c_builtin/c_check.rb +93 -95
- data/lib/adlint/exam/c_builtin/ld_check.rb +4 -4
- data/lib/adlint/traits.rb +7 -16
- data/lib/adlint/util.rb +12 -0
- data/lib/adlint/version.rb +2 -2
- 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 +32 -32
- data/share/doc/users_guide_en.texi +30 -30
- data/share/doc/users_guide_ja.html +32 -32
- data/share/doc/users_guide_ja.texi +30 -30
- metadata +4 -3
data/lib/adlint/c/const.rb
CHANGED
@@ -43,7 +43,7 @@ module C #:nodoc:
|
|
43
43
|
|
44
44
|
private
|
45
45
|
def eval_as_integer_constant(value)
|
46
|
-
# NOTE: The ISO C99 standard
|
46
|
+
# NOTE: The ISO C99 standard says;
|
47
47
|
#
|
48
48
|
# 6.4.4.1 Integer constants
|
49
49
|
#
|
@@ -150,15 +150,15 @@ module C #:nodoc:
|
|
150
150
|
when /\A([0-9]*\.[0-9]*E[+-]?[0-9]+)\z/i,
|
151
151
|
/\A([0-9]+\.?E[+-]?[0-9]+)\z/i,
|
152
152
|
/\A([0-9]*\.[0-9]+|[0-9]+\.)\z/
|
153
|
-
return
|
153
|
+
return create_tempvar(double_type, ScalarValue.of($1.to_f))
|
154
154
|
when /\A([0-9]*\.[0-9]*E[+-]?[0-9]+)F\z/i,
|
155
155
|
/\A([0-9]+\.?E[+-]?[0-9]+)F\z/i,
|
156
156
|
/\A([0-9]*\.[0-9]+|[0-9]+\.)F\z/i
|
157
|
-
return
|
157
|
+
return create_tempvar(float_type, ScalarValue.of($1.to_f))
|
158
158
|
when /\A([0-9]*\.[0-9]*E[+-]?[0-9]+)L\z/i,
|
159
159
|
/\A([0-9]+\.?E[+-]?[0-9]+)L\z/i,
|
160
160
|
/\A([0-9]*\.[0-9]+|[0-9]+\.)L\z/i
|
161
|
-
return
|
161
|
+
return create_tempvar(long_double_type, ScalarValue.of($1.to_f))
|
162
162
|
end
|
163
163
|
nil
|
164
164
|
end
|
@@ -175,9 +175,9 @@ module C #:nodoc:
|
|
175
175
|
end
|
176
176
|
|
177
177
|
if $1 == "L"
|
178
|
-
|
178
|
+
create_tempvar(wchar_type, ScalarValue.of(char_code))
|
179
179
|
else
|
180
|
-
|
180
|
+
create_tempvar(int_type, ScalarValue.of(char_code))
|
181
181
|
end
|
182
182
|
else
|
183
183
|
nil
|
@@ -187,13 +187,13 @@ module C #:nodoc:
|
|
187
187
|
def eval_as_decimal_integer_constant_unsuffixed(value)
|
188
188
|
case
|
189
189
|
when int_value_range.include?(value)
|
190
|
-
|
190
|
+
create_tempvar(int_type, ScalarValue.of(value))
|
191
191
|
when long_int_value_range.include?(value)
|
192
|
-
|
192
|
+
create_tempvar(long_int_type, ScalarValue.of(value))
|
193
193
|
when long_long_int_value_range.include?(value)
|
194
|
-
|
194
|
+
create_tempvar(long_long_int_type, ScalarValue.of(value))
|
195
195
|
else
|
196
|
-
# NOTE: The ISO C99 standard
|
196
|
+
# NOTE: The ISO C99 standard says;
|
197
197
|
#
|
198
198
|
# 6.4.4.1 Integer constants
|
199
199
|
#
|
@@ -202,20 +202,20 @@ module C #:nodoc:
|
|
202
202
|
# has no type.
|
203
203
|
#
|
204
204
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
205
|
-
|
205
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
209
|
def eval_as_decimal_integer_constant_with_u(value)
|
210
210
|
case
|
211
211
|
when unsigned_int_value_range.include?(value)
|
212
|
-
|
212
|
+
create_tempvar(unsigned_int_type, ScalarValue.of(value))
|
213
213
|
when unsigned_long_int_value_range.include?(value)
|
214
|
-
|
214
|
+
create_tempvar(unsigned_long_int_type, ScalarValue.of(value))
|
215
215
|
when unsigned_long_long_int_value_range.include?(value)
|
216
|
-
|
216
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
217
217
|
else
|
218
|
-
# NOTE: The ISO C99 standard
|
218
|
+
# NOTE: The ISO C99 standard says;
|
219
219
|
#
|
220
220
|
# 6.4.4.1 Integer constants
|
221
221
|
#
|
@@ -224,18 +224,18 @@ module C #:nodoc:
|
|
224
224
|
# has no type.
|
225
225
|
#
|
226
226
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
227
|
-
|
227
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
231
231
|
def eval_as_decimal_integer_constant_with_l(value)
|
232
232
|
case
|
233
233
|
when long_int_value_range.include?(value)
|
234
|
-
|
234
|
+
create_tempvar(long_int_type, ScalarValue.of(value))
|
235
235
|
when long_long_int_value_range.include?(value)
|
236
|
-
|
236
|
+
create_tempvar(long_long_int_type, ScalarValue.of(value))
|
237
237
|
else
|
238
|
-
# NOTE: The ISO C99 standard
|
238
|
+
# NOTE: The ISO C99 standard says;
|
239
239
|
#
|
240
240
|
# 6.4.4.1 Integer constants
|
241
241
|
#
|
@@ -244,18 +244,18 @@ module C #:nodoc:
|
|
244
244
|
# has no type.
|
245
245
|
#
|
246
246
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
247
|
-
|
247
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
251
251
|
def eval_as_decimal_integer_constant_with_ul(value)
|
252
252
|
case
|
253
253
|
when unsigned_long_int_value_range.include?(value)
|
254
|
-
|
254
|
+
create_tempvar(unsigned_long_int_type, ScalarValue.of(value))
|
255
255
|
when unsigned_long_long_int_value_range.include?(value)
|
256
|
-
|
256
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
257
257
|
else
|
258
|
-
# NOTE: The ISO C99 standard
|
258
|
+
# NOTE: The ISO C99 standard says;
|
259
259
|
#
|
260
260
|
# 6.4.4.1 Integer constants
|
261
261
|
#
|
@@ -264,16 +264,16 @@ module C #:nodoc:
|
|
264
264
|
# has no type.
|
265
265
|
#
|
266
266
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
267
|
-
|
267
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
271
271
|
def eval_as_decimal_integer_constant_with_ll(value)
|
272
272
|
case
|
273
273
|
when long_long_int_value_range.include?(value)
|
274
|
-
|
274
|
+
create_tempvar(long_long_int_type, ScalarValue.of(value))
|
275
275
|
else
|
276
|
-
# NOTE: The ISO C99 standard
|
276
|
+
# NOTE: The ISO C99 standard says;
|
277
277
|
#
|
278
278
|
# 6.4.4.1 Integer constants
|
279
279
|
#
|
@@ -282,16 +282,16 @@ module C #:nodoc:
|
|
282
282
|
# has no type.
|
283
283
|
#
|
284
284
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
285
|
-
|
285
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|
289
289
|
def eval_as_decimal_integer_constant_with_ull(value)
|
290
290
|
case
|
291
291
|
when unsigned_long_long_int_value_range.include?(value)
|
292
|
-
|
292
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
293
293
|
else
|
294
|
-
# NOTE: The ISO C99 standard
|
294
|
+
# NOTE: The ISO C99 standard says;
|
295
295
|
#
|
296
296
|
# 6.4.4.1 Integer constants
|
297
297
|
#
|
@@ -300,26 +300,26 @@ module C #:nodoc:
|
|
300
300
|
# has no type.
|
301
301
|
#
|
302
302
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
303
|
-
|
303
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
307
|
def eval_as_non_decimal_integer_constant_unsuffixed(value)
|
308
308
|
case
|
309
309
|
when int_value_range.include?(value)
|
310
|
-
|
310
|
+
create_tempvar(int_type, ScalarValue.of(value))
|
311
311
|
when unsigned_int_value_range.include?(value)
|
312
|
-
|
312
|
+
create_tempvar(unsigned_int_type, ScalarValue.of(value))
|
313
313
|
when long_int_value_range.include?(value)
|
314
|
-
|
314
|
+
create_tempvar(long_int_type, ScalarValue.of(value))
|
315
315
|
when unsigned_long_int_value_range.include?(value)
|
316
|
-
|
316
|
+
create_tempvar(unsigned_long_int_type, ScalarValue.of(value))
|
317
317
|
when long_long_int_value_range.include?(value)
|
318
|
-
|
318
|
+
create_tempvar(long_long_int_type, ScalarValue.of(value))
|
319
319
|
when unsigned_long_long_int_value_range.include?(value)
|
320
|
-
|
320
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
321
321
|
else
|
322
|
-
# NOTE: The ISO C99 standard
|
322
|
+
# NOTE: The ISO C99 standard says;
|
323
323
|
#
|
324
324
|
# 6.4.4.1 Integer constants
|
325
325
|
#
|
@@ -328,20 +328,20 @@ module C #:nodoc:
|
|
328
328
|
# has no type.
|
329
329
|
#
|
330
330
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
331
|
-
|
331
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
335
335
|
def eval_as_non_decimal_integer_constant_with_u(value)
|
336
336
|
case
|
337
337
|
when unsigned_int_value_range.include?(value)
|
338
|
-
|
338
|
+
create_tempvar(unsigned_int_type, ScalarValue.of(value))
|
339
339
|
when unsigned_long_int_value_range.include?(value)
|
340
|
-
|
340
|
+
create_tempvar(unsigned_long_int_type, ScalarValue.of(value))
|
341
341
|
when unsigned_long_long_int_value_range.include?(value)
|
342
|
-
|
342
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
343
343
|
else
|
344
|
-
# NOTE: The ISO C99 standard
|
344
|
+
# NOTE: The ISO C99 standard says;
|
345
345
|
#
|
346
346
|
# 6.4.4.1 Integer constants
|
347
347
|
#
|
@@ -350,22 +350,22 @@ module C #:nodoc:
|
|
350
350
|
# has no type.
|
351
351
|
#
|
352
352
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
353
|
-
|
353
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
357
|
def eval_as_non_decimal_integer_constant_with_l(value)
|
358
358
|
case
|
359
359
|
when long_int_value_range.include?(value)
|
360
|
-
|
360
|
+
create_tempvar(long_int_type, ScalarValue.of(value))
|
361
361
|
when unsigned_long_int_value_range.include?(value)
|
362
|
-
|
362
|
+
create_tempvar(unsigned_long_int_type, ScalarValue.of(value))
|
363
363
|
when long_long_int_value_range.include?(value)
|
364
|
-
|
364
|
+
create_tempvar(long_long_int_type, ScalarValue.of(value))
|
365
365
|
when unsigned_long_long_int_value_range.include?(value)
|
366
|
-
|
366
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
367
367
|
else
|
368
|
-
# NOTE: The ISO C99 standard
|
368
|
+
# NOTE: The ISO C99 standard says;
|
369
369
|
#
|
370
370
|
# 6.4.4.1 Integer constants
|
371
371
|
#
|
@@ -374,18 +374,18 @@ module C #:nodoc:
|
|
374
374
|
# has no type.
|
375
375
|
#
|
376
376
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
377
|
-
|
377
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
378
378
|
end
|
379
379
|
end
|
380
380
|
|
381
381
|
def eval_as_non_decimal_integer_constant_with_ul(value)
|
382
382
|
case
|
383
383
|
when unsigned_long_int_value_range.include?(value)
|
384
|
-
|
384
|
+
create_tempvar(unsigned_long_int_type, ScalarValue.of(value))
|
385
385
|
when unsigned_long_long_int_value_range.include?(value)
|
386
|
-
|
386
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
387
387
|
else
|
388
|
-
# NOTE: The ISO C99 standard
|
388
|
+
# NOTE: The ISO C99 standard says;
|
389
389
|
#
|
390
390
|
# 6.4.4.1 Integer constants
|
391
391
|
#
|
@@ -394,18 +394,18 @@ module C #:nodoc:
|
|
394
394
|
# has no type.
|
395
395
|
#
|
396
396
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
397
|
-
|
397
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
398
398
|
end
|
399
399
|
end
|
400
400
|
|
401
401
|
def eval_as_non_decimal_integer_constant_with_ll(value)
|
402
402
|
case
|
403
403
|
when long_long_int_value_range.include?(value)
|
404
|
-
|
404
|
+
create_tempvar(long_long_int_type, ScalarValue.of(value))
|
405
405
|
when unsigned_long_long_int_value_range.include?(value)
|
406
|
-
|
406
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
407
407
|
else
|
408
|
-
# NOTE: The ISO C99 standard
|
408
|
+
# NOTE: The ISO C99 standard says;
|
409
409
|
#
|
410
410
|
# 6.4.4.1 Integer constants
|
411
411
|
#
|
@@ -414,16 +414,16 @@ module C #:nodoc:
|
|
414
414
|
# has no type.
|
415
415
|
#
|
416
416
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
417
|
-
|
417
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
418
418
|
end
|
419
419
|
end
|
420
420
|
|
421
421
|
def eval_as_non_decimal_integer_constant_with_ull(value)
|
422
422
|
case
|
423
423
|
when unsigned_long_long_int_value_range.include?(value)
|
424
|
-
|
424
|
+
create_tempvar(unsigned_long_long_int_type, ScalarValue.of(value))
|
425
425
|
else
|
426
|
-
# NOTE: The ISO C99 standard
|
426
|
+
# NOTE: The ISO C99 standard says;
|
427
427
|
#
|
428
428
|
# 6.4.4.1 Integer constants
|
429
429
|
#
|
@@ -432,7 +432,7 @@ module C #:nodoc:
|
|
432
432
|
# has no type.
|
433
433
|
#
|
434
434
|
# NOTE: Use ExtendedBigIntType for unrepresentable integer constants.
|
435
|
-
|
435
|
+
create_tempvar(extended_big_int_type, ScalarValue.of(value))
|
436
436
|
end
|
437
437
|
end
|
438
438
|
|
data/lib/adlint/c/conv.rb
CHANGED
@@ -37,8 +37,8 @@ module C #:nodoc:
|
|
37
37
|
def do_conversion(original, to_type)
|
38
38
|
if original.type.coercible?(to_type)
|
39
39
|
# NOTE: Value will be coerced into the destination type in
|
40
|
-
# VariableTableMediator#
|
41
|
-
|
40
|
+
# VariableTableMediator#create_tempvar.
|
41
|
+
create_tempvar(to_type, wrap_around_value(original, to_type))
|
42
42
|
else
|
43
43
|
nil
|
44
44
|
end
|
@@ -142,7 +142,7 @@ module C #:nodoc:
|
|
142
142
|
# Host class of this module must include StandardTypeCatalogAccessor.
|
143
143
|
module UsualArithmeticTypeConversion
|
144
144
|
def do_usual_arithmetic_type_conversion(lhs_type, rhs_type)
|
145
|
-
# NOTE: The ISO C99 standard
|
145
|
+
# NOTE: The ISO C99 standard says;
|
146
146
|
#
|
147
147
|
# 6.3.1.8 Usual arithmetic conversions
|
148
148
|
#
|