adlint 2.4.0 → 2.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +63 -0
- data/MANIFEST +1 -0
- data/NEWS +12 -4
- data/etc/mesg.d/c_builtin/en_US/messages.yml +1 -1
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +1 -1
- 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/W0635.feature +57 -0
- data/features/code_check/W0644.feature +4 -0
- data/features/code_check/W1071.feature +1 -1
- data/features/code_check/W1074.feature +5 -5
- data/lib/adlint/c/branch.rb +1 -1
- data/lib/adlint/c/builtin.rb +1 -1
- data/lib/adlint/c/ctrlexpr.rb +4 -2
- data/lib/adlint/c/format.rb +12 -11
- data/lib/adlint/c/interp.rb +114 -114
- data/lib/adlint/c/object.rb +6 -22
- data/lib/adlint/c/operator.rb +4 -0
- data/lib/adlint/c/option.rb +1 -1
- data/lib/adlint/c/parser.rb +1 -1
- data/lib/adlint/c/parser.y +1 -1
- data/lib/adlint/c/syntax.rb +566 -31
- data/lib/adlint/c/type.rb +21 -1
- data/lib/adlint/c/value.rb +0 -68
- data/lib/adlint/cpp/eval.rb +2 -2
- 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 +10 -10
- data/share/doc/users_guide_en.texi +8 -8
- data/share/doc/users_guide_ja.html +10 -10
- data/share/doc/users_guide_ja.texi +8 -8
- data/spec/adlint/c/type_spec.rb +104 -5
- metadata +3 -2
data/ChangeLog
CHANGED
@@ -1,3 +1,66 @@
|
|
1
|
+
Tue Oct 9 10:49:00 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
2
|
+
|
3
|
+
* release.ga : 2.4.6
|
4
|
+
- Fix bad controlling statement evaluation in order to manage value
|
5
|
+
domain of the controlling variable correctly.
|
6
|
+
- Fix bad argument type specification of `%s', `%p' and `%n'
|
7
|
+
conversion-specifiers of *printf standard functions in order to
|
8
|
+
detect W0635 correctly.
|
9
|
+
|
10
|
+
Fri Oct 5 16:54:09 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
11
|
+
|
12
|
+
* release.rc : 2.4.5
|
13
|
+
- Fix bad argument type specification of `%s', `%p' and `%n'
|
14
|
+
conversion-specifiers of *printf standard functions in order to
|
15
|
+
detect W0635 correctly.
|
16
|
+
|
17
|
+
Fri Oct 5 15:07:03 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
18
|
+
|
19
|
+
* features/code_check/W0635.feature : Add W0635 specification.
|
20
|
+
* MANIFEST : Ditto.
|
21
|
+
|
22
|
+
* lib/adlint/c/format.rb : Fix bad argument type specification of `%s',
|
23
|
+
`%p' and `%n' conversion-specifiers of *printf standard functions in
|
24
|
+
order to detect W0635 correctly.
|
25
|
+
|
26
|
+
Fri Oct 5 15:01:55 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
27
|
+
|
28
|
+
* spec/adlint/c/type_spec.rb : Add `==' and `convertible?' unit
|
29
|
+
specifications of QualifiedType.
|
30
|
+
|
31
|
+
* lib/adlint/c/type.rb : Fix bad type convertibility check of
|
32
|
+
cv-qualified types.
|
33
|
+
|
34
|
+
Fri Oct 5 11:11:56 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
35
|
+
|
36
|
+
* release.rc : 2.4.3
|
37
|
+
- Fix abend problem of iteration-statement evaluation.
|
38
|
+
|
39
|
+
Fri Oct 5 11:02:33 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
40
|
+
|
41
|
+
* lib/adlint/c/interp.rb : Fix abend problem of iteration-statement
|
42
|
+
evaluation.
|
43
|
+
* lib/adlint/c/branch.rb : Ditto.
|
44
|
+
* lib/adlint/c/option.rb : Ditto.
|
45
|
+
|
46
|
+
Thu Oct 4 18:11:13 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
47
|
+
|
48
|
+
* release.rc : 2.4.1
|
49
|
+
- Fix bad controlling statement evaluation in order to manage value
|
50
|
+
domain of the controlling variable correctly.
|
51
|
+
|
52
|
+
Thu Oct 4 17:56:03 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
53
|
+
|
54
|
+
* lib/adlint/c/syntax.rb : Add expression transformation in order to
|
55
|
+
correctly deduct controlling expression of an iteration-statement.
|
56
|
+
* lib/adlint/c/operator.rb : Ditto.
|
57
|
+
|
58
|
+
* lib/adlint/c/object.rb : Remove FrozenValue value wrapper.
|
59
|
+
* lib/adlint/c/ctrlexpr.rb : Ditto.
|
60
|
+
|
61
|
+
* lib/adlint/c/interp.rb : Fix bad controlling statement evaluation to
|
62
|
+
manage value domain of the controlling variable correctly.
|
63
|
+
|
1
64
|
Fri Sep 21 15:00:34 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
|
2
65
|
|
3
66
|
* release.ga : 2.4.0
|
data/MANIFEST
CHANGED
@@ -197,6 +197,7 @@ features/code_check/W0483.feature
|
|
197
197
|
features/code_check/W0573.feature
|
198
198
|
features/code_check/W0583.feature
|
199
199
|
features/code_check/W0606.feature
|
200
|
+
features/code_check/W0635.feature
|
200
201
|
features/code_check/W0641.feature
|
201
202
|
features/code_check/W0643.feature
|
202
203
|
features/code_check/W0644.feature
|
data/NEWS
CHANGED
@@ -21,6 +21,18 @@
|
|
21
21
|
|
22
22
|
++
|
23
23
|
|
24
|
+
=== \AdLint 2.4.6 is released (2012-10-09)
|
25
|
+
|
26
|
+
* Fix bad controlling statement evaluation in order to manage value domain of
|
27
|
+
the controlling variable correctly
|
28
|
+
* Fix bad argument type specification of `%s', `%p' and `%n'
|
29
|
+
conversion-specifiers of *printf standard functions in order to detect W0635
|
30
|
+
correctly
|
31
|
+
|
32
|
+
See the file
|
33
|
+
{ChangeLog}[http://adlint.sourceforge.net/pmwiki/upload.d/Main/ChangeLog]
|
34
|
+
for more details.
|
35
|
+
|
24
36
|
=== \AdLint 2.4.0 is released (2012-09-21)
|
25
37
|
|
26
38
|
==== Changes since the 2.2.0 release
|
@@ -44,10 +56,6 @@
|
|
44
56
|
* Fix #include directive evaluation in order to correctly read header file with
|
45
57
|
an absolute path when any include_path items are not specified
|
46
58
|
|
47
|
-
See the file
|
48
|
-
{ChangeLog}[http://adlint.sourceforge.net/pmwiki/upload.d/Main/ChangeLog]
|
49
|
-
for more details.
|
50
|
-
|
51
59
|
=== \AdLint 2.2.0 is released (2012-09-12)
|
52
60
|
|
53
61
|
==== Changes since the 2.0.10 release
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Feature: W0635
|
2
|
+
|
3
|
+
W0635 detects that the argument type is not suitable for the corresponding
|
4
|
+
conversion-specifier.
|
5
|
+
|
6
|
+
Scenario: `%s' conversion-specifiers with various arguments
|
7
|
+
Given a target source named "fixture.c" with:
|
8
|
+
"""
|
9
|
+
#include <stdio.h>
|
10
|
+
|
11
|
+
int main(void)
|
12
|
+
{
|
13
|
+
const char * const foo = "foo";
|
14
|
+
const unsigned char * const bar = "bar";
|
15
|
+
signed char *baz = "baz";
|
16
|
+
char * const qux = "qux";
|
17
|
+
|
18
|
+
return printf("%s %s %s %s", foo, bar, baz, qux); /* OK */
|
19
|
+
}
|
20
|
+
"""
|
21
|
+
When I successfully run `adlint fixture.c` on noarch
|
22
|
+
Then the output should exactly match with:
|
23
|
+
| mesg | line | column |
|
24
|
+
| W9003 | 7 | 24 |
|
25
|
+
| W0100 | 7 | 18 |
|
26
|
+
| W0947 | 5 | 30 |
|
27
|
+
| W0947 | 6 | 39 |
|
28
|
+
| W0947 | 7 | 24 |
|
29
|
+
| W0947 | 8 | 24 |
|
30
|
+
| W0947 | 10 | 19 |
|
31
|
+
|
32
|
+
|
33
|
+
Scenario: `%s' conversion-specifiers with bad arguments
|
34
|
+
Given a target source named "fixture.c" with:
|
35
|
+
"""
|
36
|
+
#include <stdio.h>
|
37
|
+
|
38
|
+
int main(void)
|
39
|
+
{
|
40
|
+
int foo = 0;
|
41
|
+
const int bar = 0;
|
42
|
+
const int * const baz = 0;
|
43
|
+
|
44
|
+
return printf("%s %s %s", foo, bar, baz); /* W0635 */
|
45
|
+
}
|
46
|
+
"""
|
47
|
+
When I successfully run `adlint fixture.c` on noarch
|
48
|
+
Then the output should exactly match with:
|
49
|
+
| mesg | line | column |
|
50
|
+
| W9003 | 7 | 29 |
|
51
|
+
| W0635 | 9 | 19 |
|
52
|
+
| W0635 | 9 | 19 |
|
53
|
+
| W0635 | 9 | 19 |
|
54
|
+
| W0100 | 5 | 9 |
|
55
|
+
| W0947 | 9 | 19 |
|
56
|
+
|
57
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -389,6 +389,7 @@ Feature: W0644
|
|
389
389
|
| W0118 | 1 | 13 |
|
390
390
|
| W0117 | 3 | 5 |
|
391
391
|
| W0644 | 5 | 11 |
|
392
|
+
| W0035 | 5 | 11 |
|
392
393
|
| W0644 | 9 | 14 |
|
393
394
|
| W0035 | 9 | 14 |
|
394
395
|
| W0104 | 3 | 13 |
|
@@ -420,6 +421,7 @@ Feature: W0644
|
|
420
421
|
| W0118 | 1 | 13 |
|
421
422
|
| W0117 | 3 | 5 |
|
422
423
|
| W0644 | 5 | 15 |
|
424
|
+
| W0035 | 5 | 15 |
|
423
425
|
| W0644 | 9 | 18 |
|
424
426
|
| W0035 | 9 | 18 |
|
425
427
|
| W1071 | 3 | 5 |
|
@@ -449,6 +451,7 @@ Feature: W0644
|
|
449
451
|
| W0118 | 1 | 13 |
|
450
452
|
| W0117 | 3 | 5 |
|
451
453
|
| W0644 | 5 | 11 |
|
454
|
+
| W0035 | 5 | 11 |
|
452
455
|
| W0644 | 9 | 14 |
|
453
456
|
| W0035 | 9 | 14 |
|
454
457
|
| W0104 | 3 | 13 |
|
@@ -480,6 +483,7 @@ Feature: W0644
|
|
480
483
|
| W0118 | 1 | 13 |
|
481
484
|
| W0117 | 3 | 5 |
|
482
485
|
| W0644 | 5 | 15 |
|
486
|
+
| W0035 | 5 | 15 |
|
483
487
|
| W0644 | 9 | 18 |
|
484
488
|
| W0035 | 9 | 18 |
|
485
489
|
| W1071 | 3 | 5 |
|
@@ -22,9 +22,9 @@ Feature: W1074
|
|
22
22
|
Then the output should exactly match with:
|
23
23
|
| mesg | line | column |
|
24
24
|
| W1076 | 1 | 12 |
|
25
|
-
| W0612 | 5 | 21 |
|
26
25
|
| W0168 | 5 | 24 |
|
27
26
|
| W0609 | 5 | 21 |
|
27
|
+
| W0612 | 5 | 21 |
|
28
28
|
| W0629 | 1 | 12 |
|
29
29
|
| W1074 | 5 | 15 |
|
30
30
|
| W9001 | 9 | 9 |
|
@@ -49,10 +49,10 @@ Feature: W1074
|
|
49
49
|
Then the output should exactly match with:
|
50
50
|
| mesg | line | column |
|
51
51
|
| W1076 | 1 | 12 |
|
52
|
-
| W0613 | 5 | 33 |
|
53
52
|
| W0168 | 5 | 16 |
|
54
53
|
| W0168 | 5 | 36 |
|
55
54
|
| W0610 | 5 | 33 |
|
55
|
+
| W0613 | 5 | 33 |
|
56
56
|
| W0629 | 1 | 12 |
|
57
57
|
| W1074 | 5 | 26 |
|
58
58
|
| W9001 | 6 | 9 |
|
@@ -77,9 +77,9 @@ Feature: W1074
|
|
77
77
|
Then the output should exactly match with:
|
78
78
|
| mesg | line | column |
|
79
79
|
| W1076 | 1 | 12 |
|
80
|
-
| W0612 | 5 | 20 |
|
81
80
|
| W0168 | 5 | 23 |
|
82
81
|
| W0609 | 5 | 20 |
|
82
|
+
| W0612 | 5 | 20 |
|
83
83
|
| W0629 | 1 | 12 |
|
84
84
|
| W1074 | 5 | 17 |
|
85
85
|
| W9001 | 9 | 9 |
|
@@ -105,9 +105,9 @@ Feature: W1074
|
|
105
105
|
| mesg | line | column |
|
106
106
|
| W0118 | 1 | 12 |
|
107
107
|
| W1076 | 3 | 12 |
|
108
|
-
| W0612 | 5 | 23 |
|
109
108
|
| W0168 | 5 | 26 |
|
110
109
|
| W0609 | 5 | 23 |
|
110
|
+
| W0612 | 5 | 23 |
|
111
111
|
| W1073 | 5 | 19 |
|
112
112
|
| W0629 | 3 | 12 |
|
113
113
|
| W1074 | 5 | 15 |
|
@@ -135,9 +135,9 @@ Feature: W1074
|
|
135
135
|
| W0118 | 1 | 12 |
|
136
136
|
| W1077 | 1 | 12 |
|
137
137
|
| W1076 | 3 | 12 |
|
138
|
-
| W0612 | 5 | 22 |
|
139
138
|
| W0168 | 5 | 25 |
|
140
139
|
| W0609 | 5 | 22 |
|
140
|
+
| W0612 | 5 | 22 |
|
141
141
|
| W0629 | 3 | 12 |
|
142
142
|
| W9001 | 9 | 9 |
|
143
143
|
| W0628 | 3 | 12 |
|
data/lib/adlint/c/branch.rb
CHANGED
data/lib/adlint/c/builtin.rb
CHANGED
@@ -74,7 +74,7 @@ module C #:nodoc:
|
|
74
74
|
def call(interpreter, funcall_expr, args)
|
75
75
|
puts "__adlint__eval"
|
76
76
|
char_array = interpreter.pointee_of(args.first.first)
|
77
|
-
if char_array.type.array?
|
77
|
+
if char_array && char_array.type.array?
|
78
78
|
without_nil = char_array.value.to_single_value.values[0..-2]
|
79
79
|
program_text = without_nil.map { |char| char.unique_sample.chr }.join
|
80
80
|
if program_text.empty?
|
data/lib/adlint/c/ctrlexpr.rb
CHANGED
@@ -47,6 +47,8 @@ module C #:nodoc:
|
|
47
47
|
# +-> ValueDomainManipulator
|
48
48
|
# | <-- ValueDomainNarrower
|
49
49
|
# | <-- ValueDomainWidener
|
50
|
+
# | <-- WithoutExpressionValueDomainNarrower
|
51
|
+
# | <-- WithoutExpressionValueDomainWidener
|
50
52
|
# |
|
51
53
|
# +-> ValueDomainNarrowing
|
52
54
|
# <-- ValueComparison
|
@@ -973,8 +975,8 @@ module C #:nodoc:
|
|
973
975
|
super(named_variable)
|
974
976
|
|
975
977
|
@base_variable = named_variable
|
976
|
-
@phantom_value =
|
977
|
-
phantom_value : named_variable.memory.
|
978
|
+
@phantom_value =
|
979
|
+
phantom_value ? phantom_value : named_variable.memory.read.dup
|
978
980
|
end
|
979
981
|
|
980
982
|
def value
|
data/lib/adlint/c/format.rb
CHANGED
@@ -1371,9 +1371,10 @@ module C #:nodoc:
|
|
1371
1371
|
# or G conversion specifier.
|
1372
1372
|
case length_modifier
|
1373
1373
|
when "l"
|
1374
|
-
[pointer_type(wchar_type)]
|
1374
|
+
[pointer_type(qualified_type(wchar_type, :const))]
|
1375
1375
|
else
|
1376
|
-
[pointer_type(signed_char_type
|
1376
|
+
[pointer_type(qualified_type(signed_char_type, :const)),
|
1377
|
+
pointer_type(qualified_type(unsigned_char_type, :const))]
|
1377
1378
|
end
|
1378
1379
|
end
|
1379
1380
|
|
@@ -1410,7 +1411,7 @@ module C #:nodoc:
|
|
1410
1411
|
if conversion_argument && conversion_argument.type.pointer?
|
1411
1412
|
[conversion_argument.type.unqualify]
|
1412
1413
|
else
|
1413
|
-
[pointer_type(void_type)]
|
1414
|
+
[pointer_type(qualified_type(void_type, :const))]
|
1414
1415
|
end
|
1415
1416
|
end
|
1416
1417
|
|
@@ -1502,24 +1503,24 @@ module C #:nodoc:
|
|
1502
1503
|
# specifier applies to a pointer to a ptrdiff_t argument.
|
1503
1504
|
case length_modifier
|
1504
1505
|
when "hh"
|
1505
|
-
[pointer_type(signed_char_type)]
|
1506
|
+
[pointer_type(qualified_type(signed_char_type, :const))]
|
1506
1507
|
when "h"
|
1507
|
-
[pointer_type(signed_short_type)]
|
1508
|
+
[pointer_type(qualified_type(signed_short_type, :const))]
|
1508
1509
|
when "l"
|
1509
|
-
[pointer_type(signed_long_type)]
|
1510
|
+
[pointer_type(qualified_type(signed_long_type, :const))]
|
1510
1511
|
when "ll"
|
1511
|
-
[pointer_type(signed_long_long_type)]
|
1512
|
+
[pointer_type(qualified_type(signed_long_long_type, :const))]
|
1512
1513
|
when "j"
|
1513
1514
|
# FIXME: `intmax_t' is not supported yet.
|
1514
|
-
[pointer_type(signed_long_long_type)]
|
1515
|
+
[pointer_type(qualified_type(signed_long_long_type, :const))]
|
1515
1516
|
when "z"
|
1516
1517
|
# FIXME: `size_t' is not supported yet.
|
1517
|
-
[pointer_type(signed_long_type)]
|
1518
|
+
[pointer_type(qualified_type(signed_long_type, :const))]
|
1518
1519
|
when "t"
|
1519
1520
|
# FIXME: `ptrdiff_t' is not supported yet.
|
1520
|
-
[pointer_type(signed_int_type)]
|
1521
|
+
[pointer_type(qualified_type(signed_int_type, :const))]
|
1521
1522
|
else
|
1522
|
-
[pointer_type(signed_int_type)]
|
1523
|
+
[pointer_type(qualified_type(signed_int_type, :const))]
|
1523
1524
|
end
|
1524
1525
|
end
|
1525
1526
|
|