adlint 1.16.0 → 1.18.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 +471 -0
- data/MANIFEST +35 -8
- data/NEWS +50 -4
- data/bin/adlint +7 -7
- data/bin/adlint_chk +7 -7
- data/bin/adlint_cma +7 -7
- data/bin/adlint_sma +7 -7
- data/bin/adlintize +5 -5
- data/etc/mesg.d/en_US/messages.yml +3 -3
- data/etc/mesg.d/ja_JP/messages.yml +3 -3
- data/features/message_detection/E0013.feature +34 -0
- data/features/message_detection/W0007.feature +2 -0
- data/features/message_detection/W0583.feature +1 -2
- data/features/message_detection/W0641.feature +132 -0
- data/features/message_detection/W0643.feature +1 -1
- data/features/message_detection/W0644.feature +529 -0
- data/features/message_detection/W0645.feature +1 -1
- data/features/message_detection/W0649.feature +277 -0
- data/features/message_detection/W0650.feature +208 -0
- data/features/message_detection/W0697.feature +6 -0
- data/features/message_detection/W0705.feature +350 -0
- data/features/message_detection/W0707.feature +223 -0
- data/features/message_detection/W0711.feature +113 -0
- data/features/message_detection/W0712.feature +113 -0
- data/features/message_detection/W0713.feature +110 -0
- data/features/message_detection/W0714.feature +118 -0
- data/features/message_detection/W0715.feature +118 -0
- data/features/message_detection/W0716.feature +1 -0
- data/features/message_detection/W0717.feature +1 -0
- data/features/message_detection/W0718.feature +1 -0
- data/features/message_detection/W0719.feature +154 -0
- data/features/message_detection/W0723.feature +1 -2
- data/features/message_detection/W0732.feature +3 -0
- data/features/message_detection/W0733.feature +3 -0
- data/features/message_detection/W0734.feature +4 -0
- data/features/message_detection/W0735.feature +4 -0
- data/features/message_detection/W0745.feature +132 -0
- data/features/message_detection/W0780.feature +68 -0
- data/features/message_detection/W0783.feature +95 -0
- data/features/message_detection/W0792.feature +124 -0
- data/features/message_detection/W0793.feature +153 -0
- data/features/message_detection/W0794.feature +90 -0
- data/features/message_detection/W0830.feature +65 -0
- data/features/message_detection/W0833.feature +220 -0
- data/features/message_detection/W0834.feature +189 -0
- data/features/message_detection/W1026.feature +105 -0
- data/features/message_detection/W1031.feature +17 -34
- data/features/message_detection/W1039.feature +268 -0
- data/features/message_detection/W1047.feature +163 -0
- data/features/message_detection/W1066.feature +1 -0
- data/features/message_detection/W1067.feature +1 -0
- data/features/message_detection/W1068.feature +1 -0
- data/features/message_detection/W1069.feature +5 -0
- data/features/message_detection/W1070.feature +5 -0
- data/features/message_detection/W1071.feature +83 -0
- data/features/message_detection/W1073.feature +3 -2
- data/features/message_detection/W9003.feature +7 -12
- data/features/step_definitions/message_detection_steps.rb +4 -31
- data/features/support/env.rb +117 -2
- data/lib/adlint/c/branch.rb +0 -2
- data/lib/adlint/c/ctrlexpr.rb +33 -0
- data/lib/adlint/c/expr.rb +119 -31
- data/lib/adlint/c/interp.rb +44 -3
- data/lib/adlint/c/message.rb +1411 -29
- data/lib/adlint/c/object.rb +16 -2
- data/lib/adlint/c/option.rb +1 -0
- data/lib/adlint/c/parser.rb +101 -100
- data/lib/adlint/c/parser.y +3 -2
- data/lib/adlint/c/phase.rb +18 -0
- data/lib/adlint/c/resolver.rb +23 -0
- data/lib/adlint/c/syntax.rb +90 -4
- data/lib/adlint/c/type.rb +177 -110
- data/lib/adlint/cpp/macro.rb +4 -4
- data/lib/adlint/version.rb +2 -2
- data/share/demo/bad_include/test/"1/".h +0 -0
- 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 +467 -506
- data/share/doc/users_guide_en.texi +95 -125
- data/share/doc/users_guide_ja.html +471 -518
- data/share/doc/users_guide_ja.texi +95 -133
- data/spec/spec_helper.rb +6 -0
- metadata +37 -10
@@ -0,0 +1,118 @@
|
|
1
|
+
Feature: W0715
|
2
|
+
|
3
|
+
W0715 detects that operands of both sides of inclusive-or-expression is
|
4
|
+
`effectively boolean'.
|
5
|
+
|
6
|
+
Scenario: relational expressions
|
7
|
+
Given a target source named "W0715.c" with:
|
8
|
+
"""
|
9
|
+
static int foo(int a, int b, int c, int d)
|
10
|
+
{
|
11
|
+
return (a > b) | (c > d); /* W0715 */
|
12
|
+
}
|
13
|
+
"""
|
14
|
+
When I successfully run `adlint W0715.c` on noarch
|
15
|
+
Then the output should exactly match with:
|
16
|
+
| mesg | line | column |
|
17
|
+
| W1076 | 1 | 12 |
|
18
|
+
| W0572 | 3 | 20 |
|
19
|
+
| W0104 | 1 | 20 |
|
20
|
+
| W0104 | 1 | 27 |
|
21
|
+
| W0104 | 1 | 34 |
|
22
|
+
| W0104 | 1 | 41 |
|
23
|
+
| W0629 | 1 | 12 |
|
24
|
+
| W0715 | 3 | 20 |
|
25
|
+
| W0716 | 3 | 20 |
|
26
|
+
| W0628 | 1 | 12 |
|
27
|
+
|
28
|
+
Scenario: equality expressions
|
29
|
+
Given a target source named "W0715.c" with:
|
30
|
+
"""
|
31
|
+
static int foo(int a, int b, int c, int d)
|
32
|
+
{
|
33
|
+
return (a == b) | (c != d); /* W0715 */
|
34
|
+
}
|
35
|
+
"""
|
36
|
+
When I successfully run `adlint W0715.c` on noarch
|
37
|
+
Then the output should exactly match with:
|
38
|
+
| mesg | line | column |
|
39
|
+
| W1076 | 1 | 12 |
|
40
|
+
| W0572 | 3 | 21 |
|
41
|
+
| W0104 | 1 | 20 |
|
42
|
+
| W0104 | 1 | 27 |
|
43
|
+
| W0104 | 1 | 34 |
|
44
|
+
| W0104 | 1 | 41 |
|
45
|
+
| W0629 | 1 | 12 |
|
46
|
+
| W0715 | 3 | 21 |
|
47
|
+
| W0716 | 3 | 21 |
|
48
|
+
| W0628 | 1 | 12 |
|
49
|
+
|
50
|
+
Scenario: logical expressions
|
51
|
+
Given a target source named "W0715.c" with:
|
52
|
+
"""
|
53
|
+
static int foo(int a, int b, int c, int d)
|
54
|
+
{
|
55
|
+
return (a && b) | (c || d); /* W0715 */
|
56
|
+
}
|
57
|
+
"""
|
58
|
+
When I successfully run `adlint W0715.c` on noarch
|
59
|
+
Then the output should exactly match with:
|
60
|
+
| mesg | line | column |
|
61
|
+
| W1076 | 1 | 12 |
|
62
|
+
| W0572 | 3 | 21 |
|
63
|
+
| W0104 | 1 | 20 |
|
64
|
+
| W0104 | 1 | 27 |
|
65
|
+
| W0104 | 1 | 34 |
|
66
|
+
| W0104 | 1 | 41 |
|
67
|
+
| W0629 | 1 | 12 |
|
68
|
+
| W0715 | 3 | 21 |
|
69
|
+
| W0716 | 3 | 21 |
|
70
|
+
| W0628 | 1 | 12 |
|
71
|
+
|
72
|
+
Scenario: shift expressions
|
73
|
+
Given a target source named "W0715.c" with:
|
74
|
+
"""
|
75
|
+
static int foo(int a, int b, int c, int d)
|
76
|
+
{
|
77
|
+
return (a << b) | (c ^ d); /* OK */
|
78
|
+
}
|
79
|
+
"""
|
80
|
+
When I successfully run `adlint W0715.c` on noarch
|
81
|
+
Then the output should exactly match with:
|
82
|
+
| mesg | line | column |
|
83
|
+
| W1076 | 1 | 12 |
|
84
|
+
| W0570 | 3 | 15 |
|
85
|
+
| W0572 | 3 | 15 |
|
86
|
+
| W0794 | 3 | 15 |
|
87
|
+
| W0572 | 3 | 26 |
|
88
|
+
| W0572 | 3 | 21 |
|
89
|
+
| W0104 | 1 | 20 |
|
90
|
+
| W0104 | 1 | 27 |
|
91
|
+
| W0104 | 1 | 34 |
|
92
|
+
| W0104 | 1 | 41 |
|
93
|
+
| W0629 | 1 | 12 |
|
94
|
+
| W0628 | 1 | 12 |
|
95
|
+
|
96
|
+
Scenario: arithmetic expressions
|
97
|
+
Given a target source named "W0715.c" with:
|
98
|
+
"""
|
99
|
+
static int foo(int a, int b, int c, int d)
|
100
|
+
{
|
101
|
+
return (a + b) | (c - d); /* OK */
|
102
|
+
}
|
103
|
+
"""
|
104
|
+
When I successfully run `adlint W0715.c` on noarch
|
105
|
+
Then the output should exactly match with:
|
106
|
+
| mesg | line | column |
|
107
|
+
| W1076 | 1 | 12 |
|
108
|
+
| W0723 | 3 | 15 |
|
109
|
+
| W0723 | 3 | 25 |
|
110
|
+
| W0572 | 3 | 20 |
|
111
|
+
| W0104 | 1 | 20 |
|
112
|
+
| W0104 | 1 | 27 |
|
113
|
+
| W0104 | 1 | 34 |
|
114
|
+
| W0104 | 1 | 41 |
|
115
|
+
| W0629 | 1 | 12 |
|
116
|
+
| W0628 | 1 | 12 |
|
117
|
+
|
118
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,154 @@
|
|
1
|
+
Feature: W0719
|
2
|
+
|
3
|
+
W0719 detects that the right hand side of the shift-expression is greater
|
4
|
+
than the bit length of underlying type of the left hand side.
|
5
|
+
|
6
|
+
Scenario: 31-bit left shift-expression of `char' value
|
7
|
+
Given a target source named "W0719.c" with:
|
8
|
+
"""
|
9
|
+
int foo(char c)
|
10
|
+
{
|
11
|
+
return c << 31; /* W0719 */
|
12
|
+
}
|
13
|
+
"""
|
14
|
+
When I successfully run `adlint W0719.c` on noarch
|
15
|
+
Then the output should exactly match with:
|
16
|
+
| mesg | line | column |
|
17
|
+
| W0117 | 1 | 5 |
|
18
|
+
| W0123 | 3 | 12 |
|
19
|
+
| W0246 | 3 | 12 |
|
20
|
+
| W0116 | 3 | 14 |
|
21
|
+
| W0719 | 3 | 14 |
|
22
|
+
| W0104 | 1 | 14 |
|
23
|
+
| W0628 | 1 | 5 |
|
24
|
+
|
25
|
+
Scenario: 31-bit right shift-expression of `char' value
|
26
|
+
Given a target source named "W0719.c" with:
|
27
|
+
"""
|
28
|
+
int foo(char c)
|
29
|
+
{
|
30
|
+
return c >> 31; /* W0719 */
|
31
|
+
}
|
32
|
+
"""
|
33
|
+
When I successfully run `adlint W0719.c` on noarch
|
34
|
+
Then the output should exactly match with:
|
35
|
+
| mesg | line | column |
|
36
|
+
| W0117 | 1 | 5 |
|
37
|
+
| W0123 | 3 | 12 |
|
38
|
+
| W0246 | 3 | 12 |
|
39
|
+
| W0719 | 3 | 14 |
|
40
|
+
| W0104 | 1 | 14 |
|
41
|
+
| W0628 | 1 | 5 |
|
42
|
+
|
43
|
+
Scenario: 7-bit left shift-expression of `char' value
|
44
|
+
Given a target source named "W0719.c" with:
|
45
|
+
"""
|
46
|
+
int foo(char c)
|
47
|
+
{
|
48
|
+
return c << 7; /* OK */
|
49
|
+
}
|
50
|
+
"""
|
51
|
+
When I successfully run `adlint W0719.c` on noarch
|
52
|
+
Then the output should exactly match with:
|
53
|
+
| mesg | line | column |
|
54
|
+
| W0117 | 1 | 5 |
|
55
|
+
| W0123 | 3 | 12 |
|
56
|
+
| W0246 | 3 | 12 |
|
57
|
+
| W0116 | 3 | 14 |
|
58
|
+
| W0104 | 1 | 14 |
|
59
|
+
| W0628 | 1 | 5 |
|
60
|
+
|
61
|
+
Scenario: 7-bit right shift-expression of `char' value
|
62
|
+
Given a target source named "W0719.c" with:
|
63
|
+
"""
|
64
|
+
int foo(char c)
|
65
|
+
{
|
66
|
+
return c >> 7; /* OK */
|
67
|
+
}
|
68
|
+
"""
|
69
|
+
When I successfully run `adlint W0719.c` on noarch
|
70
|
+
Then the output should exactly match with:
|
71
|
+
| mesg | line | column |
|
72
|
+
| W0117 | 1 | 5 |
|
73
|
+
| W0123 | 3 | 12 |
|
74
|
+
| W0246 | 3 | 12 |
|
75
|
+
| W0104 | 1 | 14 |
|
76
|
+
| W0628 | 1 | 5 |
|
77
|
+
|
78
|
+
Scenario: 31-bit left shift compound-assignment-expression of `char' value
|
79
|
+
Given a target source named "W0719.c" with:
|
80
|
+
"""
|
81
|
+
void foo(char c)
|
82
|
+
{
|
83
|
+
c <<= 31; /* W0719 */
|
84
|
+
}
|
85
|
+
"""
|
86
|
+
When I successfully run `adlint W0719.c` on noarch
|
87
|
+
Then the output should exactly match with:
|
88
|
+
| mesg | line | column |
|
89
|
+
| W0117 | 1 | 6 |
|
90
|
+
| W0123 | 3 | 5 |
|
91
|
+
| W0246 | 3 | 5 |
|
92
|
+
| W0116 | 3 | 7 |
|
93
|
+
| W0719 | 3 | 7 |
|
94
|
+
| W0136 | 3 | 5 |
|
95
|
+
| W0165 | 3 | 5 |
|
96
|
+
| W0628 | 1 | 6 |
|
97
|
+
|
98
|
+
Scenario: 31-bit right shift-expression of `char' value
|
99
|
+
Given a target source named "W0719.c" with:
|
100
|
+
"""
|
101
|
+
int foo(char c)
|
102
|
+
{
|
103
|
+
return c >> 31; /* W0719 */
|
104
|
+
}
|
105
|
+
"""
|
106
|
+
When I successfully run `adlint W0719.c` on noarch
|
107
|
+
Then the output should exactly match with:
|
108
|
+
| mesg | line | column |
|
109
|
+
| W0117 | 1 | 5 |
|
110
|
+
| W0123 | 3 | 12 |
|
111
|
+
| W0246 | 3 | 12 |
|
112
|
+
| W0719 | 3 | 14 |
|
113
|
+
| W0104 | 1 | 14 |
|
114
|
+
| W0628 | 1 | 5 |
|
115
|
+
|
116
|
+
Scenario: 63-bit left shift compound-assignment-expression of `char' value
|
117
|
+
Given a target source named "W0719.c" with:
|
118
|
+
"""
|
119
|
+
void foo(char c)
|
120
|
+
{
|
121
|
+
c <<= 63; /* OK but W0650 */
|
122
|
+
}
|
123
|
+
"""
|
124
|
+
When I successfully run `adlint W0719.c` on noarch
|
125
|
+
Then the output should exactly match with:
|
126
|
+
| mesg | line | column |
|
127
|
+
| W0117 | 1 | 6 |
|
128
|
+
| W0123 | 3 | 5 |
|
129
|
+
| W0246 | 3 | 5 |
|
130
|
+
| W0116 | 3 | 7 |
|
131
|
+
| W0650 | 3 | 7 |
|
132
|
+
| W0136 | 3 | 5 |
|
133
|
+
| W0165 | 3 | 5 |
|
134
|
+
| W0628 | 1 | 6 |
|
135
|
+
|
136
|
+
Scenario: 63-bit right shift-expression of `char' value
|
137
|
+
Given a target source named "W0719.c" with:
|
138
|
+
"""
|
139
|
+
int foo(char c)
|
140
|
+
{
|
141
|
+
return c >> 63; /* OK but W0650 */
|
142
|
+
}
|
143
|
+
"""
|
144
|
+
When I successfully run `adlint W0719.c` on noarch
|
145
|
+
Then the output should exactly match with:
|
146
|
+
| mesg | line | column |
|
147
|
+
| W0117 | 1 | 5 |
|
148
|
+
| W0123 | 3 | 12 |
|
149
|
+
| W0246 | 3 | 12 |
|
150
|
+
| W0650 | 3 | 14 |
|
151
|
+
| W0104 | 1 | 14 |
|
152
|
+
| W0628 | 1 | 5 |
|
153
|
+
|
154
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -9,8 +9,7 @@ Feature: W0723
|
|
9
9
|
static unsigned int j = (unsigned int) &i + 1; /* OK */
|
10
10
|
"""
|
11
11
|
When I successfully run `adlint W0723.c` on noarch
|
12
|
-
Then the output should
|
13
|
-
And the output should exactly match with:
|
12
|
+
Then the output should exactly match with:
|
14
13
|
| mesg | line | column |
|
15
14
|
| W0567 | 2 | 25 |
|
16
15
|
| W0167 | 2 | 45 |
|
@@ -82,8 +82,10 @@ Feature: W0732
|
|
82
82
|
| W1076 | 1 | 13 |
|
83
83
|
| W0570 | 5 | 12 |
|
84
84
|
| W0572 | 5 | 12 |
|
85
|
+
| W0794 | 5 | 12 |
|
85
86
|
| W0570 | 5 | 24 |
|
86
87
|
| W0572 | 5 | 24 |
|
88
|
+
| W0794 | 5 | 24 |
|
87
89
|
| W0571 | 6 | 12 |
|
88
90
|
| W0572 | 6 | 12 |
|
89
91
|
| W0571 | 6 | 24 |
|
@@ -98,6 +100,7 @@ Feature: W0732
|
|
98
100
|
| W0572 | 11 | 24 |
|
99
101
|
| W0570 | 12 | 12 |
|
100
102
|
| W0572 | 12 | 12 |
|
103
|
+
| W0794 | 12 | 12 |
|
101
104
|
| W0571 | 12 | 25 |
|
102
105
|
| W0572 | 12 | 25 |
|
103
106
|
| W0104 | 1 | 29 |
|
@@ -82,8 +82,10 @@ Feature: W0733
|
|
82
82
|
| W1076 | 1 | 13 |
|
83
83
|
| W0570 | 5 | 12 |
|
84
84
|
| W0572 | 5 | 12 |
|
85
|
+
| W0794 | 5 | 12 |
|
85
86
|
| W0570 | 5 | 24 |
|
86
87
|
| W0572 | 5 | 24 |
|
88
|
+
| W0794 | 5 | 24 |
|
87
89
|
| W0571 | 6 | 12 |
|
88
90
|
| W0572 | 6 | 12 |
|
89
91
|
| W0571 | 6 | 24 |
|
@@ -98,6 +100,7 @@ Feature: W0733
|
|
98
100
|
| W0572 | 11 | 24 |
|
99
101
|
| W0570 | 12 | 12 |
|
100
102
|
| W0572 | 12 | 12 |
|
103
|
+
| W0794 | 12 | 12 |
|
101
104
|
| W0571 | 12 | 25 |
|
102
105
|
| W0572 | 12 | 25 |
|
103
106
|
| W0104 | 1 | 29 |
|
@@ -181,6 +181,7 @@ Feature: W0734
|
|
181
181
|
| W1076 | 1 | 13 |
|
182
182
|
| W0570 | 5 | 12 |
|
183
183
|
| W0572 | 5 | 12 |
|
184
|
+
| W0794 | 5 | 12 |
|
184
185
|
| W0571 | 6 | 12 |
|
185
186
|
| W0572 | 6 | 12 |
|
186
187
|
| W0572 | 7 | 12 |
|
@@ -222,6 +223,7 @@ Feature: W0734
|
|
222
223
|
| W1076 | 1 | 13 |
|
223
224
|
| W0570 | 5 | 12 |
|
224
225
|
| W0572 | 5 | 12 |
|
226
|
+
| W0794 | 5 | 12 |
|
225
227
|
| W0571 | 6 | 12 |
|
226
228
|
| W0572 | 6 | 12 |
|
227
229
|
| W0572 | 7 | 12 |
|
@@ -263,6 +265,7 @@ Feature: W0734
|
|
263
265
|
| W1076 | 1 | 13 |
|
264
266
|
| W0570 | 5 | 12 |
|
265
267
|
| W0572 | 5 | 12 |
|
268
|
+
| W0794 | 5 | 12 |
|
266
269
|
| W0571 | 6 | 12 |
|
267
270
|
| W0572 | 6 | 12 |
|
268
271
|
| W0572 | 7 | 12 |
|
@@ -305,6 +308,7 @@ Feature: W0734
|
|
305
308
|
| W1076 | 1 | 13 |
|
306
309
|
| W0570 | 5 | 12 |
|
307
310
|
| W0572 | 5 | 12 |
|
311
|
+
| W0794 | 5 | 12 |
|
308
312
|
| W0571 | 6 | 12 |
|
309
313
|
| W0572 | 6 | 12 |
|
310
314
|
| W0572 | 7 | 12 |
|
@@ -181,6 +181,7 @@ Feature: W0735
|
|
181
181
|
| W1076 | 1 | 13 |
|
182
182
|
| W0570 | 5 | 17 |
|
183
183
|
| W0572 | 5 | 17 |
|
184
|
+
| W0794 | 5 | 17 |
|
184
185
|
| W0571 | 6 | 17 |
|
185
186
|
| W0572 | 6 | 17 |
|
186
187
|
| W0572 | 7 | 17 |
|
@@ -222,6 +223,7 @@ Feature: W0735
|
|
222
223
|
| W1076 | 1 | 13 |
|
223
224
|
| W0570 | 5 | 17 |
|
224
225
|
| W0572 | 5 | 17 |
|
226
|
+
| W0794 | 5 | 17 |
|
225
227
|
| W0571 | 6 | 17 |
|
226
228
|
| W0572 | 6 | 17 |
|
227
229
|
| W0572 | 7 | 17 |
|
@@ -263,6 +265,7 @@ Feature: W0735
|
|
263
265
|
| W1076 | 1 | 13 |
|
264
266
|
| W0570 | 5 | 24 |
|
265
267
|
| W0572 | 5 | 24 |
|
268
|
+
| W0794 | 5 | 24 |
|
266
269
|
| W0571 | 6 | 23 |
|
267
270
|
| W0572 | 6 | 23 |
|
268
271
|
| W0572 | 7 | 24 |
|
@@ -305,6 +308,7 @@ Feature: W0735
|
|
305
308
|
| W1076 | 1 | 13 |
|
306
309
|
| W0570 | 5 | 24 |
|
307
310
|
| W0572 | 5 | 24 |
|
311
|
+
| W0794 | 5 | 24 |
|
308
312
|
| W0571 | 6 | 23 |
|
309
313
|
| W0572 | 6 | 23 |
|
310
314
|
| W0572 | 7 | 24 |
|
@@ -0,0 +1,132 @@
|
|
1
|
+
Feature: W0745
|
2
|
+
|
3
|
+
W0745 detects that an array subscript must cause out of bound access of the
|
4
|
+
array object.
|
5
|
+
|
6
|
+
Scenario: array-subscript-expression with non-constant subscript must cause
|
7
|
+
OOB access in an initializer
|
8
|
+
Given a target source named "W0745.c" with:
|
9
|
+
"""
|
10
|
+
extern int a[5];
|
11
|
+
|
12
|
+
int foo(int i)
|
13
|
+
{
|
14
|
+
if (i < 0) {
|
15
|
+
int j = a[i - 1]; /* W0745 */
|
16
|
+
return j;
|
17
|
+
}
|
18
|
+
return i;
|
19
|
+
}
|
20
|
+
"""
|
21
|
+
When I successfully run `adlint W0745.c` on noarch
|
22
|
+
Then the output should exactly match with:
|
23
|
+
| mesg | line | column |
|
24
|
+
| W0118 | 1 | 12 |
|
25
|
+
| W0117 | 3 | 5 |
|
26
|
+
| W0745 | 6 | 21 |
|
27
|
+
| W0100 | 6 | 13 |
|
28
|
+
| W0104 | 3 | 13 |
|
29
|
+
| W1071 | 3 | 5 |
|
30
|
+
| W0628 | 3 | 5 |
|
31
|
+
|
32
|
+
Scenario: array-subscript-expression with non-constant subscript must cause
|
33
|
+
OOB access in rhs operand of an assignment-expression
|
34
|
+
Given a target source named "W0745.c" with:
|
35
|
+
"""
|
36
|
+
extern int a[5];
|
37
|
+
|
38
|
+
int foo(int i)
|
39
|
+
{
|
40
|
+
int j = 0;
|
41
|
+
if (i > 4) {
|
42
|
+
j = a[i + 1]; /* W0745 */
|
43
|
+
}
|
44
|
+
return j;
|
45
|
+
}
|
46
|
+
"""
|
47
|
+
When I successfully run `adlint W0745.c` on noarch
|
48
|
+
Then the output should exactly match with:
|
49
|
+
| mesg | line | column |
|
50
|
+
| W0118 | 1 | 12 |
|
51
|
+
| W0117 | 3 | 5 |
|
52
|
+
| W0723 | 7 | 17 |
|
53
|
+
| W0745 | 7 | 17 |
|
54
|
+
| W0104 | 3 | 13 |
|
55
|
+
| W0628 | 3 | 5 |
|
56
|
+
|
57
|
+
Scenario: array-subscript-expression with non-constant subscript must cause
|
58
|
+
OOB access in lhs operand of an assignment-expression
|
59
|
+
Given a target source named "W0745.c" with:
|
60
|
+
"""
|
61
|
+
extern int a[5];
|
62
|
+
|
63
|
+
void foo(int i)
|
64
|
+
{
|
65
|
+
if (i < -2) {
|
66
|
+
a[i + 2] = 0; /* W0745 */
|
67
|
+
}
|
68
|
+
}
|
69
|
+
"""
|
70
|
+
When I successfully run `adlint W0745.c` on noarch
|
71
|
+
Then the output should exactly match with:
|
72
|
+
| mesg | line | column |
|
73
|
+
| W0118 | 1 | 12 |
|
74
|
+
| W0117 | 3 | 6 |
|
75
|
+
| W0745 | 6 | 13 |
|
76
|
+
| W0104 | 3 | 14 |
|
77
|
+
| W0628 | 3 | 6 |
|
78
|
+
|
79
|
+
Scenario: indirection-expression with non-constant subscript must cause OOB
|
80
|
+
access in rhs operand of an assignment-expression
|
81
|
+
Given a target source named "W0745.c" with:
|
82
|
+
"""
|
83
|
+
extern int a[5];
|
84
|
+
|
85
|
+
int foo(int i)
|
86
|
+
{
|
87
|
+
int j = 0;
|
88
|
+
if (i > 5) {
|
89
|
+
j = *(a + i + 2); /* W0745 */
|
90
|
+
}
|
91
|
+
return j;
|
92
|
+
}
|
93
|
+
"""
|
94
|
+
When I successfully run `adlint W0745.c` on noarch
|
95
|
+
Then the output should exactly match with:
|
96
|
+
| mesg | line | column |
|
97
|
+
| W0118 | 1 | 12 |
|
98
|
+
| W0117 | 3 | 5 |
|
99
|
+
| W9003 | 7 | 19 |
|
100
|
+
| W0023 | 7 | 17 |
|
101
|
+
| W9003 | 7 | 23 |
|
102
|
+
| W0023 | 7 | 21 |
|
103
|
+
| W0745 | 7 | 14 |
|
104
|
+
| W0104 | 3 | 13 |
|
105
|
+
| W0628 | 3 | 5 |
|
106
|
+
|
107
|
+
Scenario: indirection-expression with non-constant subscript must cause OOB
|
108
|
+
access in lhs operand of an assignment-expression
|
109
|
+
Given a target source named "W0745.c" with:
|
110
|
+
"""
|
111
|
+
extern int a[5];
|
112
|
+
|
113
|
+
void foo(int i)
|
114
|
+
{
|
115
|
+
if (i < 0) {
|
116
|
+
*(i + a - 1) = 0; /* W0745 */
|
117
|
+
}
|
118
|
+
}
|
119
|
+
"""
|
120
|
+
When I successfully run `adlint W0745.c` on noarch
|
121
|
+
Then the output should exactly match with:
|
122
|
+
| mesg | line | column |
|
123
|
+
| W0118 | 1 | 12 |
|
124
|
+
| W0117 | 3 | 6 |
|
125
|
+
| W9003 | 6 | 11 |
|
126
|
+
| W9003 | 6 | 19 |
|
127
|
+
| W0024 | 6 | 17 |
|
128
|
+
| W0745 | 6 | 10 |
|
129
|
+
| W0104 | 3 | 14 |
|
130
|
+
| W0628 | 3 | 6 |
|
131
|
+
|
132
|
+
# vim:ts=2:sw=2:sts=2:et:
|