adlint 2.4.6 → 2.4.10
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +163 -0
- data/MANIFEST +12 -0
- data/NEWS +20 -4
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +2 -2
- 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/E0013.feature +0 -2
- data/features/code_check/W0001.feature +0 -2
- data/features/code_check/W0002.feature +0 -2
- data/features/code_check/W0003.feature +0 -2
- data/features/code_check/W0007.feature +0 -2
- data/features/code_check/W0010.feature +1 -3
- data/features/code_check/W0013.feature +0 -2
- data/features/code_check/W0016.feature +0 -2
- data/features/code_check/W0017.feature +0 -2
- data/features/code_check/W0025.feature +0 -2
- data/features/code_check/W0026.feature +0 -2
- data/features/code_check/W0070.feature +0 -2
- data/features/code_check/W0071.feature +0 -2
- data/features/code_check/W0093.feature +0 -2
- data/features/code_check/W0104.feature +0 -2
- data/features/code_check/W0109.feature +0 -2
- data/features/code_check/W0119.feature +0 -2
- data/features/code_check/W0120.feature +0 -2
- data/features/code_check/W0121.feature +0 -2
- data/features/code_check/W0122.feature +0 -2
- data/features/code_check/W0123.feature +0 -2
- data/features/code_check/W0124.feature +0 -2
- data/features/code_check/W0125.feature +0 -2
- data/features/code_check/W0126.feature +0 -2
- data/features/code_check/W0127.feature +0 -2
- data/features/code_check/W0128.feature +0 -2
- data/features/code_check/W0129.feature +0 -2
- data/features/code_check/W0130.feature +0 -2
- data/features/code_check/W0131.feature +0 -2
- data/features/code_check/W0132.feature +0 -2
- data/features/code_check/W0133.feature +0 -2
- data/features/code_check/W0134.feature +0 -2
- data/features/code_check/W0135.feature +0 -2
- data/features/code_check/W0136.feature +0 -2
- data/features/code_check/W0137.feature +0 -2
- data/features/code_check/W0138.feature +0 -2
- data/features/code_check/W0139.feature +0 -2
- data/features/code_check/W0140.feature +0 -2
- data/features/code_check/W0141.feature +0 -2
- data/features/code_check/W0142.feature +0 -2
- data/features/code_check/W0143.feature +0 -2
- data/features/code_check/W0144.feature +0 -2
- data/features/code_check/W0145.feature +0 -2
- data/features/code_check/W0146.feature +0 -2
- data/features/code_check/W0147.feature +0 -2
- data/features/code_check/W0148.feature +0 -2
- data/features/code_check/W0149.feature +0 -2
- data/features/code_check/W0150.feature +0 -2
- data/features/code_check/W0151.feature +0 -2
- data/features/code_check/W0152.feature +0 -2
- data/features/code_check/W0153.feature +0 -2
- data/features/code_check/W0154.feature +0 -2
- data/features/code_check/W0155.feature +0 -2
- data/features/code_check/W0156.feature +0 -2
- data/features/code_check/W0157.feature +0 -2
- data/features/code_check/W0158.feature +0 -2
- data/features/code_check/W0159.feature +0 -2
- data/features/code_check/W0160.feature +0 -2
- data/features/code_check/W0161.feature +0 -2
- data/features/code_check/W0162.feature +0 -2
- data/features/code_check/W0163.feature +0 -2
- data/features/code_check/W0164.feature +0 -2
- data/features/code_check/W0165.feature +0 -2
- data/features/code_check/W0166.feature +0 -2
- data/features/code_check/W0167.feature +0 -2
- data/features/code_check/W0168.feature +0 -2
- data/features/code_check/W0169.feature +0 -2
- data/features/code_check/W0170.feature +0 -2
- data/features/code_check/W0171.feature +0 -2
- data/features/code_check/W0172.feature +0 -2
- data/features/code_check/W0173.feature +0 -2
- data/features/code_check/W0174.feature +0 -2
- data/features/code_check/W0175.feature +0 -2
- data/features/code_check/W0176.feature +0 -2
- data/features/code_check/W0177.feature +0 -2
- data/features/code_check/W0178.feature +0 -2
- data/features/code_check/W0179.feature +0 -2
- data/features/code_check/W0180.feature +0 -2
- data/features/code_check/W0181.feature +0 -2
- data/features/code_check/W0182.feature +0 -2
- data/features/code_check/W0183.feature +0 -2
- data/features/code_check/W0184.feature +0 -2
- data/features/code_check/W0185.feature +0 -2
- data/features/code_check/W0186.feature +0 -2
- data/features/code_check/W0187.feature +0 -2
- data/features/code_check/W0188.feature +0 -2
- data/features/code_check/W0189.feature +0 -2
- data/features/code_check/W0190.feature +0 -2
- data/features/code_check/W0191.feature +0 -2
- data/features/code_check/W0192.feature +0 -2
- data/features/code_check/W0193.feature +0 -2
- data/features/code_check/W0194.feature +0 -2
- data/features/code_check/W0195.feature +0 -2
- data/features/code_check/W0196.feature +0 -2
- data/features/code_check/W0197.feature +0 -2
- data/features/code_check/W0198.feature +0 -2
- data/features/code_check/W0199.feature +0 -2
- data/features/code_check/W0200.feature +0 -2
- data/features/code_check/W0201.feature +0 -2
- data/features/code_check/W0202.feature +0 -2
- data/features/code_check/W0203.feature +0 -2
- data/features/code_check/W0204.feature +0 -2
- data/features/code_check/W0205.feature +0 -2
- data/features/code_check/W0206.feature +0 -2
- data/features/code_check/W0207.feature +0 -2
- data/features/code_check/W0208.feature +0 -2
- data/features/code_check/W0209.feature +0 -2
- data/features/code_check/W0210.feature +0 -2
- data/features/code_check/W0211.feature +0 -2
- data/features/code_check/W0212.feature +0 -2
- data/features/code_check/W0213.feature +0 -2
- data/features/code_check/W0214.feature +0 -2
- data/features/code_check/W0215.feature +0 -2
- data/features/code_check/W0216.feature +0 -2
- data/features/code_check/W0217.feature +0 -2
- data/features/code_check/W0218.feature +0 -2
- data/features/code_check/W0219.feature +0 -2
- data/features/code_check/W0220.feature +0 -2
- data/features/code_check/W0221.feature +0 -2
- data/features/code_check/W0222.feature +0 -2
- data/features/code_check/W0223.feature +0 -2
- data/features/code_check/W0224.feature +0 -2
- data/features/code_check/W0225.feature +0 -2
- data/features/code_check/W0226.feature +0 -2
- data/features/code_check/W0227.feature +0 -2
- data/features/code_check/W0228.feature +0 -2
- data/features/code_check/W0229.feature +0 -2
- data/features/code_check/W0230.feature +0 -2
- data/features/code_check/W0231.feature +0 -2
- data/features/code_check/W0232.feature +0 -2
- data/features/code_check/W0233.feature +0 -2
- data/features/code_check/W0234.feature +0 -2
- data/features/code_check/W0235.feature +0 -2
- data/features/code_check/W0236.feature +0 -2
- data/features/code_check/W0237.feature +0 -2
- data/features/code_check/W0238.feature +0 -2
- data/features/code_check/W0239.feature +0 -2
- data/features/code_check/W0240.feature +0 -2
- data/features/code_check/W0241.feature +0 -2
- data/features/code_check/W0242.feature +0 -2
- data/features/code_check/W0243.feature +0 -2
- data/features/code_check/W0244.feature +0 -2
- data/features/code_check/W0245.feature +0 -2
- data/features/code_check/W0246.feature +0 -2
- data/features/code_check/W0247.feature +0 -2
- data/features/code_check/W0248.feature +0 -2
- data/features/code_check/W0249.feature +0 -2
- data/features/code_check/W0250.feature +0 -2
- data/features/code_check/W0251.feature +0 -2
- data/features/code_check/W0252.feature +0 -2
- data/features/code_check/W0253.feature +0 -2
- data/features/code_check/W0254.feature +0 -2
- data/features/code_check/W0425.feature +0 -2
- data/features/code_check/W0431.feature +0 -2
- data/features/code_check/W0432.feature +0 -2
- data/features/code_check/W0477.feature +0 -2
- data/features/code_check/W0478.feature +0 -2
- data/features/code_check/W0479.feature +0 -2
- data/features/code_check/W0480.feature +0 -2
- data/features/code_check/W0481.feature +0 -2
- data/features/code_check/W0482.feature +0 -2
- data/features/code_check/W0483.feature +0 -2
- data/features/code_check/W0488.feature +132 -0
- data/features/code_check/W0489.feature +78 -0
- data/features/code_check/W0490.feature +83 -0
- data/features/code_check/W0495.feature +60 -0
- data/features/code_check/W0496.feature +63 -0
- data/features/code_check/W0497.feature +65 -0
- data/features/code_check/W0498.feature +120 -0
- data/features/code_check/W0499.feature +63 -0
- data/features/code_check/W0500.feature +66 -0
- data/features/code_check/W0501.feature +69 -0
- data/features/code_check/W0502.feature +64 -0
- data/features/code_check/W0573.feature +0 -2
- data/features/code_check/W0583.feature +0 -2
- data/features/code_check/W0606.feature +0 -2
- data/features/code_check/W0635.feature +0 -2
- data/features/code_check/W0641.feature +0 -2
- data/features/code_check/W0643.feature +0 -2
- data/features/code_check/W0644.feature +0 -2
- data/features/code_check/W0645.feature +0 -2
- data/features/code_check/W0646.feature +0 -2
- data/features/code_check/W0649.feature +0 -2
- data/features/code_check/W0650.feature +0 -2
- data/features/code_check/W0655.feature +43 -0
- data/features/code_check/W0685.feature +0 -2
- data/features/code_check/W0686.feature +0 -2
- data/features/code_check/W0687.feature +0 -2
- data/features/code_check/W0688.feature +0 -2
- data/features/code_check/W0689.feature +0 -2
- data/features/code_check/W0690.feature +0 -2
- data/features/code_check/W0691.feature +0 -2
- data/features/code_check/W0692.feature +0 -2
- data/features/code_check/W0694.feature +0 -2
- data/features/code_check/W0695.feature +0 -2
- data/features/code_check/W0697.feature +0 -2
- data/features/code_check/W0698.feature +0 -2
- data/features/code_check/W0699.feature +0 -2
- data/features/code_check/W0700.feature +0 -2
- data/features/code_check/W0703.feature +0 -2
- data/features/code_check/W0705.feature +6 -2
- data/features/code_check/W0707.feature +4 -2
- data/features/code_check/W0711.feature +0 -2
- data/features/code_check/W0712.feature +0 -2
- data/features/code_check/W0713.feature +0 -2
- data/features/code_check/W0714.feature +0 -2
- data/features/code_check/W0715.feature +0 -2
- data/features/code_check/W0716.feature +0 -2
- data/features/code_check/W0717.feature +0 -2
- data/features/code_check/W0718.feature +0 -2
- data/features/code_check/W0719.feature +0 -2
- data/features/code_check/W0723.feature +0 -2
- data/features/code_check/W0726.feature +0 -2
- data/features/code_check/W0732.feature +0 -2
- data/features/code_check/W0733.feature +0 -2
- data/features/code_check/W0734.feature +0 -2
- data/features/code_check/W0735.feature +0 -2
- data/features/code_check/W0745.feature +1 -2
- data/features/code_check/W0747.feature +0 -2
- data/features/code_check/W0748.feature +0 -2
- data/features/code_check/W0749.feature +0 -2
- data/features/code_check/W0750.feature +0 -2
- data/features/code_check/W0751.feature +0 -2
- data/features/code_check/W0752.feature +0 -2
- data/features/code_check/W0753.feature +0 -2
- data/features/code_check/W0754.feature +0 -2
- data/features/code_check/W0755.feature +0 -2
- data/features/code_check/W0756.feature +0 -2
- data/features/code_check/W0757.feature +0 -2
- data/features/code_check/W0758.feature +0 -2
- data/features/code_check/W0759.feature +0 -2
- data/features/code_check/W0760.feature +0 -2
- data/features/code_check/W0761.feature +0 -2
- data/features/code_check/W0762.feature +0 -2
- data/features/code_check/W0763.feature +0 -2
- data/features/code_check/W0764.feature +0 -2
- data/features/code_check/W0765.feature +0 -2
- data/features/code_check/W0766.feature +0 -2
- data/features/code_check/W0767.feature +0 -2
- data/features/code_check/W0768.feature +0 -2
- data/features/code_check/W0769.feature +0 -2
- data/features/code_check/W0780.feature +0 -2
- data/features/code_check/W0781.feature +0 -2
- data/features/code_check/W0783.feature +0 -2
- data/features/code_check/W0787.feature +0 -2
- data/features/code_check/W0792.feature +0 -2
- data/features/code_check/W0793.feature +0 -2
- data/features/code_check/W0794.feature +0 -2
- data/features/code_check/W0801.feature +0 -2
- data/features/code_check/W0805.feature +0 -2
- data/features/code_check/W0806.feature +0 -2
- data/features/code_check/W0807.feature +0 -2
- data/features/code_check/W0808.feature +0 -2
- data/features/code_check/W0809.feature +0 -2
- data/features/code_check/W0811.feature +0 -2
- data/features/code_check/W0830.feature +0 -2
- data/features/code_check/W0833.feature +0 -2
- data/features/code_check/W0834.feature +1 -3
- data/features/code_check/W1026.feature +0 -2
- data/features/code_check/W1030.feature +0 -2
- data/features/code_check/W1031.feature +0 -2
- data/features/code_check/W1039.feature +0 -2
- data/features/code_check/W1040.feature +0 -2
- data/features/code_check/W1041.feature +0 -2
- data/features/code_check/W1046.feature +0 -2
- data/features/code_check/W1047.feature +0 -2
- data/features/code_check/W1052.feature +0 -2
- data/features/code_check/W1066.feature +0 -2
- data/features/code_check/W1067.feature +0 -2
- data/features/code_check/W1068.feature +0 -2
- data/features/code_check/W1069.feature +0 -2
- data/features/code_check/W1070.feature +0 -2
- data/features/code_check/W1071.feature +0 -2
- data/features/code_check/W1072.feature +0 -2
- data/features/code_check/W1073.feature +1 -3
- data/features/code_check/W1074.feature +3 -4
- data/features/code_check/W1075.feature +0 -2
- data/features/code_check/W1076.feature +0 -2
- data/features/code_check/W1077.feature +0 -2
- data/features/code_check/W9001.feature +0 -2
- data/features/code_check/W9003.feature +3 -3
- data/lib/adlint/c/branch.rb +2 -2
- data/lib/adlint/c/environ.rb +3 -3
- data/lib/adlint/c/expr.rb +67 -39
- data/lib/adlint/c/interp.rb +10 -1
- data/lib/adlint/c/object.rb +6 -4
- data/lib/adlint/c/parser.rb +1 -1
- data/lib/adlint/c/value.rb +27 -10
- data/lib/adlint/cpp/constexpr.rb +1 -1
- data/lib/adlint/exam/c_builtin/c_check.rb +502 -420
- 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
- metadata +15 -3
@@ -0,0 +1,132 @@
|
|
1
|
+
Feature: W0488
|
2
|
+
|
3
|
+
W0488 detects that multiple function-call-expressions or
|
4
|
+
member-access-expressions or array-subscript-expressions appear in a
|
5
|
+
logical-and-expression or a logical-or-expression without appropriate
|
6
|
+
grouping.
|
7
|
+
|
8
|
+
Scenario: member-access-expression and array-subscript-expression and
|
9
|
+
function-call-expression as an operand of logical-and-expression
|
10
|
+
Given a target source named "fixture.c" with:
|
11
|
+
"""
|
12
|
+
struct foo { int (*a[3])(void); };
|
13
|
+
|
14
|
+
static void foo(struct foo *p)
|
15
|
+
{
|
16
|
+
if (p) {
|
17
|
+
if (p->a[0]() && p->a[1]()) { /* W0488 */
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
"""
|
23
|
+
When I successfully run `adlint fixture.c` on noarch
|
24
|
+
Then the output should exactly match with:
|
25
|
+
| mesg | line | column |
|
26
|
+
| W1076 | 3 | 13 |
|
27
|
+
| W0104 | 3 | 29 |
|
28
|
+
| W0105 | 3 | 29 |
|
29
|
+
| W1071 | 3 | 13 |
|
30
|
+
| W0629 | 3 | 13 |
|
31
|
+
| W0488 | 6 | 13 |
|
32
|
+
| W0508 | 6 | 23 |
|
33
|
+
| W0114 | 5 | 5 |
|
34
|
+
| W0628 | 3 | 13 |
|
35
|
+
|
36
|
+
Scenario: member-access-expression and array-subscript-expression and
|
37
|
+
function-call-expression as an operand of logical-and-expression
|
38
|
+
with grouping
|
39
|
+
Given a target source named "fixture.c" with:
|
40
|
+
"""
|
41
|
+
struct foo { int (*a[3])(void); };
|
42
|
+
|
43
|
+
static void foo(struct foo *p)
|
44
|
+
{
|
45
|
+
if (p) {
|
46
|
+
if (((p->a[0])()) && ((p->a[1])())) { /* OK */
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
"""
|
52
|
+
When I successfully run `adlint fixture.c` on noarch
|
53
|
+
Then the output should exactly match with:
|
54
|
+
| mesg | line | column |
|
55
|
+
| W1076 | 3 | 13 |
|
56
|
+
| W0104 | 3 | 29 |
|
57
|
+
| W0105 | 3 | 29 |
|
58
|
+
| W1071 | 3 | 13 |
|
59
|
+
| W0629 | 3 | 13 |
|
60
|
+
| W0508 | 6 | 27 |
|
61
|
+
| W0114 | 5 | 5 |
|
62
|
+
| W0628 | 3 | 13 |
|
63
|
+
|
64
|
+
Scenario: member-access-expression and array-subscript-expression and
|
65
|
+
function-call-expression as an operand of logical-and-expression
|
66
|
+
grouped entirely
|
67
|
+
Given a target source named "fixture.c" with:
|
68
|
+
"""
|
69
|
+
struct foo { int (*a[3])(void); };
|
70
|
+
|
71
|
+
static void foo(struct foo *p)
|
72
|
+
{
|
73
|
+
if (p) {
|
74
|
+
if ((p->a[0]() && p->a[1]())) { /* W0488 */
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
"""
|
80
|
+
When I successfully run `adlint fixture.c` on noarch
|
81
|
+
Then the output should exactly match with:
|
82
|
+
| mesg | line | column |
|
83
|
+
| W1076 | 3 | 13 |
|
84
|
+
| W0104 | 3 | 29 |
|
85
|
+
| W0105 | 3 | 29 |
|
86
|
+
| W1071 | 3 | 13 |
|
87
|
+
| W0629 | 3 | 13 |
|
88
|
+
| W0488 | 6 | 13 |
|
89
|
+
| W0508 | 6 | 24 |
|
90
|
+
| W0114 | 5 | 5 |
|
91
|
+
| W0628 | 3 | 13 |
|
92
|
+
|
93
|
+
Scenario: ungrouped array-subscript-expression in a logical-and-expression
|
94
|
+
Given a target source named "fixture.c" with:
|
95
|
+
"""
|
96
|
+
static void foo(int i, int a[])
|
97
|
+
{
|
98
|
+
if (i && a[0]) { /* W0488 */
|
99
|
+
return;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
"""
|
103
|
+
When I successfully run `adlint fixture.c` on noarch
|
104
|
+
Then the output should exactly match with:
|
105
|
+
| mesg | line | column |
|
106
|
+
| W1076 | 1 | 13 |
|
107
|
+
| W0104 | 1 | 21 |
|
108
|
+
| W0104 | 1 | 28 |
|
109
|
+
| W1071 | 1 | 13 |
|
110
|
+
| W0629 | 1 | 13 |
|
111
|
+
| W0488 | 3 | 9 |
|
112
|
+
| W0628 | 1 | 13 |
|
113
|
+
|
114
|
+
Scenario: grouped array-subscript-expression in a logical-and-expression
|
115
|
+
Given a target source named "fixture.c" with:
|
116
|
+
"""
|
117
|
+
static void foo(int i, int a[])
|
118
|
+
{
|
119
|
+
if (i && (a[0])) { /* OK */
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
"""
|
124
|
+
When I successfully run `adlint fixture.c` on noarch
|
125
|
+
Then the output should exactly match with:
|
126
|
+
| mesg | line | column |
|
127
|
+
| W1076 | 1 | 13 |
|
128
|
+
| W0104 | 1 | 21 |
|
129
|
+
| W0104 | 1 | 28 |
|
130
|
+
| W1071 | 1 | 13 |
|
131
|
+
| W0629 | 1 | 13 |
|
132
|
+
| W0628 | 1 | 13 |
|
@@ -0,0 +1,78 @@
|
|
1
|
+
Feature: W0489
|
2
|
+
|
3
|
+
W0489 detects that multiple unary-expressions appear as an operand of a
|
4
|
+
logical-and-expression or a logical-or-expression without appropriate
|
5
|
+
grouping.
|
6
|
+
|
7
|
+
Scenario: unary-expressions appear as an operand of a logical-and-expression
|
8
|
+
Given a target source named "fixture.c" with:
|
9
|
+
"""
|
10
|
+
static void foo(int i, int *p)
|
11
|
+
{
|
12
|
+
if (p) {
|
13
|
+
if (-i++ && !*p) { /* W0489 */
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
"""
|
19
|
+
When I successfully run `adlint fixture.c` on noarch
|
20
|
+
Then the output should exactly match with:
|
21
|
+
| mesg | line | column |
|
22
|
+
| W1076 | 1 | 13 |
|
23
|
+
| W0104 | 1 | 29 |
|
24
|
+
| W0105 | 1 | 29 |
|
25
|
+
| W1071 | 1 | 13 |
|
26
|
+
| W0629 | 1 | 13 |
|
27
|
+
| W0489 | 4 | 13 |
|
28
|
+
| W0114 | 3 | 5 |
|
29
|
+
| W0628 | 1 | 13 |
|
30
|
+
|
31
|
+
Scenario: unary-expressions appear as an operand of a logical-and-expression
|
32
|
+
with grouping
|
33
|
+
Given a target source named "fixture.c" with:
|
34
|
+
"""
|
35
|
+
static void foo(int i, int *p)
|
36
|
+
{
|
37
|
+
if (p) {
|
38
|
+
if ((-i++) && (!*p)) { /* OK */
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
"""
|
44
|
+
When I successfully run `adlint fixture.c` on noarch
|
45
|
+
Then the output should exactly match with:
|
46
|
+
| mesg | line | column |
|
47
|
+
| W1076 | 1 | 13 |
|
48
|
+
| W0104 | 1 | 29 |
|
49
|
+
| W0105 | 1 | 29 |
|
50
|
+
| W1071 | 1 | 13 |
|
51
|
+
| W0629 | 1 | 13 |
|
52
|
+
| W0114 | 3 | 5 |
|
53
|
+
| W0628 | 1 | 13 |
|
54
|
+
|
55
|
+
Scenario: unary-expressions appear as an operand of a logical-and-expression
|
56
|
+
grouped entirely
|
57
|
+
Given a target source named "fixture.c" with:
|
58
|
+
"""
|
59
|
+
static void foo(int i, int *p)
|
60
|
+
{
|
61
|
+
if (p) {
|
62
|
+
if ((-i++ && !*p)) { /* W0489 */
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
"""
|
68
|
+
When I successfully run `adlint fixture.c` on noarch
|
69
|
+
Then the output should exactly match with:
|
70
|
+
| mesg | line | column |
|
71
|
+
| W1076 | 1 | 13 |
|
72
|
+
| W0104 | 1 | 29 |
|
73
|
+
| W0105 | 1 | 29 |
|
74
|
+
| W1071 | 1 | 13 |
|
75
|
+
| W0629 | 1 | 13 |
|
76
|
+
| W0489 | 4 | 13 |
|
77
|
+
| W0114 | 3 | 5 |
|
78
|
+
| W0628 | 1 | 13 |
|
@@ -0,0 +1,83 @@
|
|
1
|
+
Feature: W0490
|
2
|
+
|
3
|
+
W0490 detects that multiple precedence binary-expressions appear as an
|
4
|
+
operand of a logical-and-expression or a logical-or-expression without
|
5
|
+
appropriate grouping.
|
6
|
+
|
7
|
+
Scenario: precedence binary-expressions appear as an operand of a
|
8
|
+
logical-and-expression
|
9
|
+
Given a target source named "fixture.c" with:
|
10
|
+
"""
|
11
|
+
static void foo(int i, int j)
|
12
|
+
{
|
13
|
+
if (i + j && i * j) { /* W0490 */
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
"""
|
18
|
+
When I successfully run `adlint fixture.c` on noarch
|
19
|
+
Then the output should exactly match with:
|
20
|
+
| mesg | line | column |
|
21
|
+
| W1076 | 1 | 13 |
|
22
|
+
| W0723 | 3 | 11 |
|
23
|
+
| W0723 | 3 | 20 |
|
24
|
+
| W0104 | 1 | 21 |
|
25
|
+
| W0104 | 1 | 28 |
|
26
|
+
| W1071 | 1 | 13 |
|
27
|
+
| W0629 | 1 | 13 |
|
28
|
+
| W0490 | 3 | 9 |
|
29
|
+
| W0500 | 3 | 9 |
|
30
|
+
| W0502 | 3 | 9 |
|
31
|
+
| W0732 | 3 | 15 |
|
32
|
+
| W0628 | 1 | 13 |
|
33
|
+
|
34
|
+
Scenario: precedence binary-expressions appear as an operand of a
|
35
|
+
logical-and-expression with grouping
|
36
|
+
Given a target source named "fixture.c" with:
|
37
|
+
"""
|
38
|
+
static void foo(int i, int j)
|
39
|
+
{
|
40
|
+
if ((i + j) && (i * j)) { /* OK */
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
"""
|
45
|
+
When I successfully run `adlint fixture.c` on noarch
|
46
|
+
Then the output should exactly match with:
|
47
|
+
| mesg | line | column |
|
48
|
+
| W1076 | 1 | 13 |
|
49
|
+
| W0723 | 3 | 12 |
|
50
|
+
| W0723 | 3 | 23 |
|
51
|
+
| W0104 | 1 | 21 |
|
52
|
+
| W0104 | 1 | 28 |
|
53
|
+
| W1071 | 1 | 13 |
|
54
|
+
| W0629 | 1 | 13 |
|
55
|
+
| W0732 | 3 | 17 |
|
56
|
+
| W0628 | 1 | 13 |
|
57
|
+
|
58
|
+
Scenario: precedence binary-expressions appear as an operand of a
|
59
|
+
logical-and-expression grouped entirely
|
60
|
+
Given a target source named "fixture.c" with:
|
61
|
+
"""
|
62
|
+
static void foo(int i, int j)
|
63
|
+
{
|
64
|
+
if ((i + j && i * j)) { /* W0490 */
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
"""
|
69
|
+
When I successfully run `adlint fixture.c` on noarch
|
70
|
+
Then the output should exactly match with:
|
71
|
+
| mesg | line | column |
|
72
|
+
| W1076 | 1 | 13 |
|
73
|
+
| W0723 | 3 | 12 |
|
74
|
+
| W0723 | 3 | 21 |
|
75
|
+
| W0104 | 1 | 21 |
|
76
|
+
| W0104 | 1 | 28 |
|
77
|
+
| W1071 | 1 | 13 |
|
78
|
+
| W0629 | 1 | 13 |
|
79
|
+
| W0490 | 3 | 9 |
|
80
|
+
| W0500 | 3 | 9 |
|
81
|
+
| W0502 | 3 | 9 |
|
82
|
+
| W0732 | 3 | 16 |
|
83
|
+
| W0628 | 1 | 13 |
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Feature: W0495
|
2
|
+
|
3
|
+
W0495 detects that different arithmetic operators appear with modulo operator
|
4
|
+
in an expression without appropriate grouping.
|
5
|
+
|
6
|
+
Scenario: without grouping
|
7
|
+
Given a target source named "fixture.c" with:
|
8
|
+
"""
|
9
|
+
static int foo(int a, int b)
|
10
|
+
{
|
11
|
+
return a + b % 5; /* W0495 */
|
12
|
+
}
|
13
|
+
"""
|
14
|
+
When I successfully run `adlint fixture.c` on noarch
|
15
|
+
Then the output should exactly match with:
|
16
|
+
| mesg | line | column |
|
17
|
+
| W1076 | 1 | 12 |
|
18
|
+
| W0723 | 3 | 14 |
|
19
|
+
| W0104 | 1 | 20 |
|
20
|
+
| W0104 | 1 | 27 |
|
21
|
+
| W0629 | 1 | 12 |
|
22
|
+
| W0495 | 3 | 12 |
|
23
|
+
| W0628 | 1 | 12 |
|
24
|
+
|
25
|
+
Scenario: with appropriate grouping
|
26
|
+
Given a target source named "fixture.c" with:
|
27
|
+
"""
|
28
|
+
static int foo(int a, int b)
|
29
|
+
{
|
30
|
+
return (a + b) % 5; /* OK */
|
31
|
+
}
|
32
|
+
"""
|
33
|
+
When I successfully run `adlint fixture.c` on noarch
|
34
|
+
Then the output should exactly match with:
|
35
|
+
| mesg | line | column |
|
36
|
+
| W1076 | 1 | 12 |
|
37
|
+
| W0723 | 3 | 15 |
|
38
|
+
| W0104 | 1 | 20 |
|
39
|
+
| W0104 | 1 | 27 |
|
40
|
+
| W0629 | 1 | 12 |
|
41
|
+
| W0628 | 1 | 12 |
|
42
|
+
|
43
|
+
Scenario: entirely grouped
|
44
|
+
Given a target source named "fixture.c" with:
|
45
|
+
"""
|
46
|
+
static int foo(int a, int b)
|
47
|
+
{
|
48
|
+
return (a + b % 5); /* W0495 */
|
49
|
+
}
|
50
|
+
"""
|
51
|
+
When I successfully run `adlint fixture.c` on noarch
|
52
|
+
Then the output should exactly match with:
|
53
|
+
| mesg | line | column |
|
54
|
+
| W1076 | 1 | 12 |
|
55
|
+
| W0723 | 3 | 15 |
|
56
|
+
| W0104 | 1 | 20 |
|
57
|
+
| W0104 | 1 | 27 |
|
58
|
+
| W0629 | 1 | 12 |
|
59
|
+
| W0495 | 3 | 12 |
|
60
|
+
| W0628 | 1 | 12 |
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Feature: W0496
|
2
|
+
|
3
|
+
W0496 detects that multiple conditional-expressions appear in an expression
|
4
|
+
without appropriate grouping.
|
5
|
+
|
6
|
+
Scenario: without grouping
|
7
|
+
Given a target source named "fixture.c" with:
|
8
|
+
"""
|
9
|
+
static int foo(int a, int b)
|
10
|
+
{
|
11
|
+
return a < 0 ? a : b > 0 ? a + b : b; /* W0496 */
|
12
|
+
}
|
13
|
+
"""
|
14
|
+
When I successfully run `adlint fixture.c` on noarch
|
15
|
+
Then the output should exactly match with:
|
16
|
+
| mesg | line | column |
|
17
|
+
| W1076 | 1 | 12 |
|
18
|
+
| W0723 | 3 | 34 |
|
19
|
+
| W0104 | 1 | 20 |
|
20
|
+
| W0104 | 1 | 27 |
|
21
|
+
| W0629 | 1 | 12 |
|
22
|
+
| W0496 | 3 | 12 |
|
23
|
+
| W0501 | 3 | 18 |
|
24
|
+
| W0628 | 1 | 12 |
|
25
|
+
|
26
|
+
Scenario: with appropriate grouping
|
27
|
+
Given a target source named "fixture.c" with:
|
28
|
+
"""
|
29
|
+
static int foo(int a, int b)
|
30
|
+
{
|
31
|
+
return a < 0 ? a : (b > 0 ? a + b : b); /* OK */
|
32
|
+
}
|
33
|
+
"""
|
34
|
+
When I successfully run `adlint fixture.c` on noarch
|
35
|
+
Then the output should exactly match with:
|
36
|
+
| mesg | line | column |
|
37
|
+
| W1076 | 1 | 12 |
|
38
|
+
| W0723 | 3 | 35 |
|
39
|
+
| W0104 | 1 | 20 |
|
40
|
+
| W0104 | 1 | 27 |
|
41
|
+
| W0629 | 1 | 12 |
|
42
|
+
| W0501 | 3 | 18 |
|
43
|
+
| W0628 | 1 | 12 |
|
44
|
+
|
45
|
+
Scenario: entirely grouped
|
46
|
+
Given a target source named "fixture.c" with:
|
47
|
+
"""
|
48
|
+
static int foo(int a, int b)
|
49
|
+
{
|
50
|
+
return (a < 0 ? a : b > 0 ? a + b : b); /* W0496 */
|
51
|
+
}
|
52
|
+
"""
|
53
|
+
When I successfully run `adlint fixture.c` on noarch
|
54
|
+
Then the output should exactly match with:
|
55
|
+
| mesg | line | column |
|
56
|
+
| W1076 | 1 | 12 |
|
57
|
+
| W0723 | 3 | 35 |
|
58
|
+
| W0104 | 1 | 20 |
|
59
|
+
| W0104 | 1 | 27 |
|
60
|
+
| W0629 | 1 | 12 |
|
61
|
+
| W0496 | 3 | 13 |
|
62
|
+
| W0501 | 3 | 19 |
|
63
|
+
| W0628 | 1 | 12 |
|
@@ -0,0 +1,65 @@
|
|
1
|
+
Feature: W0497
|
2
|
+
|
3
|
+
W0497 detects that multiple shift-expressions or relational-expressions or
|
4
|
+
equality-expressions appear in an expression without appropriate grouping.
|
5
|
+
|
6
|
+
Scenario: without grouping
|
7
|
+
Given a target source named "fixture.c" with:
|
8
|
+
"""
|
9
|
+
static int foo(unsigned int a, unsigned int b)
|
10
|
+
{
|
11
|
+
return a << 1 < b << 2; /* W0497 */
|
12
|
+
}
|
13
|
+
"""
|
14
|
+
When I successfully run `adlint fixture.c` on noarch
|
15
|
+
Then the output should exactly match with:
|
16
|
+
| mesg | line | column |
|
17
|
+
| W1076 | 1 | 12 |
|
18
|
+
| W0116 | 3 | 14 |
|
19
|
+
| W0116 | 3 | 23 |
|
20
|
+
| W0104 | 1 | 29 |
|
21
|
+
| W0104 | 1 | 45 |
|
22
|
+
| W0629 | 1 | 12 |
|
23
|
+
| W0497 | 3 | 12 |
|
24
|
+
| W0502 | 3 | 12 |
|
25
|
+
| W0628 | 1 | 12 |
|
26
|
+
|
27
|
+
Scenario: with appropriate grouping
|
28
|
+
Given a target source named "fixture.c" with:
|
29
|
+
"""
|
30
|
+
static int foo(unsigned int a, unsigned int b)
|
31
|
+
{
|
32
|
+
return (a << 1) < (b << 2); /* OK */
|
33
|
+
}
|
34
|
+
"""
|
35
|
+
When I successfully run `adlint fixture.c` on noarch
|
36
|
+
Then the output should exactly match with:
|
37
|
+
| mesg | line | column |
|
38
|
+
| W1076 | 1 | 12 |
|
39
|
+
| W0116 | 3 | 15 |
|
40
|
+
| W0116 | 3 | 26 |
|
41
|
+
| W0104 | 1 | 29 |
|
42
|
+
| W0104 | 1 | 45 |
|
43
|
+
| W0629 | 1 | 12 |
|
44
|
+
| W0628 | 1 | 12 |
|
45
|
+
|
46
|
+
Scenario: entirely grouped
|
47
|
+
Given a target source named "fixture.c" with:
|
48
|
+
"""
|
49
|
+
static int foo(unsigned int a, unsigned int b)
|
50
|
+
{
|
51
|
+
return (a << 1 < b << 2); /* W0497 */
|
52
|
+
}
|
53
|
+
"""
|
54
|
+
When I successfully run `adlint fixture.c` on noarch
|
55
|
+
Then the output should exactly match with:
|
56
|
+
| mesg | line | column |
|
57
|
+
| W1076 | 1 | 12 |
|
58
|
+
| W0116 | 3 | 15 |
|
59
|
+
| W0116 | 3 | 24 |
|
60
|
+
| W0104 | 1 | 29 |
|
61
|
+
| W0104 | 1 | 45 |
|
62
|
+
| W0629 | 1 | 12 |
|
63
|
+
| W0497 | 3 | 12 |
|
64
|
+
| W0502 | 3 | 12 |
|
65
|
+
| W0628 | 1 | 12 |
|