adlint 1.12.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +133 -34
- data/MANIFEST +10 -0
- data/NEWS +22 -4
- data/etc/mesg.d/en_US/messages.yml +1 -1
- data/etc/mesg.d/ja_JP/messages.yml +1 -1
- data/features/message_detection/W0093.feature +3 -3
- data/features/message_detection/W0104.feature +111 -0
- data/features/message_detection/W0606.feature +1 -1
- data/features/message_detection/W0645.feature +142 -0
- data/features/message_detection/W0697.feature +183 -0
- data/features/message_detection/W0699.feature +1 -0
- data/features/message_detection/W0700.feature +56 -0
- data/features/message_detection/W1031.feature +18 -18
- data/features/message_detection/W1066.feature +88 -0
- data/features/message_detection/W1067.feature +88 -0
- data/features/message_detection/W1068.feature +88 -0
- data/features/message_detection/W1069.feature +120 -0
- data/features/message_detection/W1070.feature +145 -0
- data/features/message_detection/W1072.feature +32 -0
- data/lib/adlint/c/interp.rb +17 -10
- data/lib/adlint/c/mediator.rb +1 -0
- data/lib/adlint/c/message_shima.rb +222 -0
- data/lib/adlint/c/phase.rb +9 -0
- data/lib/adlint/c/type.rb +13 -12
- 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 +59 -50
- data/share/doc/users_guide_en.texi +48 -40
- data/share/doc/users_guide_ja.html +60 -52
- data/share/doc/users_guide_ja.texi +49 -41
- metadata +12 -2
@@ -0,0 +1,183 @@
|
|
1
|
+
Feature: W0697
|
2
|
+
|
3
|
+
W0697 detects that some execution paths terminate implicitly without explicit
|
4
|
+
`return' statements in the non-void function.
|
5
|
+
|
6
|
+
Scenario: no `return' statement in non-void function
|
7
|
+
Given a target source named "W0697.c" with:
|
8
|
+
"""
|
9
|
+
extern int func(void) /* W0697 */
|
10
|
+
{
|
11
|
+
}
|
12
|
+
"""
|
13
|
+
When I successfully run `adlint W0697.c` on noarch
|
14
|
+
Then the output should exactly match with:
|
15
|
+
| mesg | line | column |
|
16
|
+
| W0117 | 1 | 12 |
|
17
|
+
| W0697 | 1 | 12 |
|
18
|
+
| W0628 | 1 | 12 |
|
19
|
+
|
20
|
+
Scenario: a `return' statement is only in a `if' statement
|
21
|
+
Given a target source named "W0697.c" with:
|
22
|
+
"""
|
23
|
+
extern int func(int value) /* W0697 */
|
24
|
+
{
|
25
|
+
if (value == 0) {
|
26
|
+
return 0;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
"""
|
30
|
+
When I successfully run `adlint W0697.c` on noarch
|
31
|
+
Then the output should exactly match with:
|
32
|
+
| mesg | line | column |
|
33
|
+
| W0117 | 1 | 12 |
|
34
|
+
| W0697 | 1 | 12 |
|
35
|
+
| W0104 | 1 | 21 |
|
36
|
+
| W0628 | 1 | 12 |
|
37
|
+
|
38
|
+
Scenario: `return' statements are only in a `if-else-if' statements chain
|
39
|
+
Given a target source named "W0697.c" with:
|
40
|
+
"""
|
41
|
+
extern int func(int value) /* W0697 */
|
42
|
+
{
|
43
|
+
if (value == 0) {
|
44
|
+
return 0;
|
45
|
+
} else if (value == 1) {
|
46
|
+
return 1;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
"""
|
50
|
+
When I successfully run `adlint W0697.c` on noarch
|
51
|
+
Then the output should exactly match with:
|
52
|
+
| mesg | line | column |
|
53
|
+
| W0117 | 1 | 12 |
|
54
|
+
| W0697 | 1 | 12 |
|
55
|
+
| W0104 | 1 | 21 |
|
56
|
+
| W1069 | 3 | 5 |
|
57
|
+
| W0628 | 1 | 12 |
|
58
|
+
|
59
|
+
Scenario: `return' statements are in all `case' clauses but not in the
|
60
|
+
`default` clause
|
61
|
+
Given a target source named "W0697.c" with:
|
62
|
+
"""
|
63
|
+
extern int func(int value) /* W0697 */
|
64
|
+
{
|
65
|
+
switch (value) {
|
66
|
+
case 1:
|
67
|
+
return 0;
|
68
|
+
case 2:
|
69
|
+
return 1;
|
70
|
+
case 3:
|
71
|
+
return 2;
|
72
|
+
default:
|
73
|
+
break;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
"""
|
77
|
+
When I successfully run `adlint W0697.c` on noarch
|
78
|
+
Then the output should exactly match with:
|
79
|
+
| mesg | line | column |
|
80
|
+
| W0117 | 1 | 12 |
|
81
|
+
| W0697 | 1 | 12 |
|
82
|
+
| W0104 | 1 | 21 |
|
83
|
+
| W0628 | 1 | 12 |
|
84
|
+
|
85
|
+
Scenario: a `return' statement in non-void function
|
86
|
+
Given a target source named "W0697.c" with:
|
87
|
+
"""
|
88
|
+
extern int func(void) /* OK */
|
89
|
+
{
|
90
|
+
return 1;
|
91
|
+
}
|
92
|
+
"""
|
93
|
+
When I successfully run `adlint W0697.c` on noarch
|
94
|
+
Then the output should exactly match with:
|
95
|
+
| mesg | line | column |
|
96
|
+
| W0117 | 1 | 12 |
|
97
|
+
| W0628 | 1 | 12 |
|
98
|
+
|
99
|
+
Scenario: no implicit termination in all execution paths
|
100
|
+
Given a target source named "W0697.c" with:
|
101
|
+
"""
|
102
|
+
extern int func(int value) /* OK */
|
103
|
+
{
|
104
|
+
if (value == 0) {
|
105
|
+
return 0;
|
106
|
+
}
|
107
|
+
return 1;
|
108
|
+
}
|
109
|
+
"""
|
110
|
+
When I successfully run `adlint W0697.c` on noarch
|
111
|
+
Then the output should exactly match with:
|
112
|
+
| mesg | line | column |
|
113
|
+
| W0117 | 1 | 12 |
|
114
|
+
| W0104 | 1 | 21 |
|
115
|
+
| W0628 | 1 | 12 |
|
116
|
+
|
117
|
+
Scenario: no implicit termination in `if-else-if' statements chain
|
118
|
+
Given a target source named "W0697.c" with:
|
119
|
+
"""
|
120
|
+
extern int func(int value) /* OK */
|
121
|
+
{
|
122
|
+
if (value == 0) {
|
123
|
+
return 0;
|
124
|
+
} else if (value == 1) {
|
125
|
+
return 1;
|
126
|
+
} else {
|
127
|
+
return 2;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
"""
|
131
|
+
When I successfully run `adlint W0697.c` on noarch
|
132
|
+
Then the output should exactly match with:
|
133
|
+
| mesg | line | column |
|
134
|
+
| W0117 | 1 | 12 |
|
135
|
+
| W0104 | 1 | 21 |
|
136
|
+
| W0628 | 1 | 12 |
|
137
|
+
|
138
|
+
Scenario: no implicit termination with `switch' statement
|
139
|
+
Given a target source named "W0697.c" with:
|
140
|
+
"""
|
141
|
+
extern int func(int value) /* OK */
|
142
|
+
{
|
143
|
+
switch (value) {
|
144
|
+
case 1:
|
145
|
+
return 0;
|
146
|
+
case 2:
|
147
|
+
return 1;
|
148
|
+
case 3:
|
149
|
+
return 2;
|
150
|
+
default:
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
return 10;
|
154
|
+
}
|
155
|
+
"""
|
156
|
+
When I successfully run `adlint W0697.c` on noarch
|
157
|
+
Then the output should exactly match with:
|
158
|
+
| mesg | line | column |
|
159
|
+
| W0117 | 1 | 12 |
|
160
|
+
| W0104 | 1 | 21 |
|
161
|
+
| W0628 | 1 | 12 |
|
162
|
+
|
163
|
+
Scenario: no implicit termination with `goto' statement
|
164
|
+
Given a target source named "W0697.c" with:
|
165
|
+
"""
|
166
|
+
extern int func(int value) /* OK */
|
167
|
+
{
|
168
|
+
if (value == 10) {
|
169
|
+
goto A;
|
170
|
+
}
|
171
|
+
A:
|
172
|
+
return 1;
|
173
|
+
}
|
174
|
+
"""
|
175
|
+
When I successfully run `adlint W0697.c` on noarch
|
176
|
+
Then the output should exactly match with:
|
177
|
+
| mesg | line | column |
|
178
|
+
| W0117 | 1 | 12 |
|
179
|
+
| W0104 | 1 | 21 |
|
180
|
+
| W1072 | 4 | 9 |
|
181
|
+
| W0628 | 1 | 12 |
|
182
|
+
|
183
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Feature: W0700
|
2
|
+
|
3
|
+
W0700 detects that no `return' statements with expression is in the function
|
4
|
+
which is implicitly declared to return `int' value.
|
5
|
+
|
6
|
+
Scenario: no `return' statement in the implicitly typed function
|
7
|
+
Given a target source named "W0700.c" with:
|
8
|
+
"""
|
9
|
+
extern func(void) /* W0700 */
|
10
|
+
{
|
11
|
+
}
|
12
|
+
"""
|
13
|
+
When I successfully run `adlint W0700.c` on noarch
|
14
|
+
Then the output should exactly match with:
|
15
|
+
| mesg | line | column |
|
16
|
+
| W0117 | 1 | 8 |
|
17
|
+
| W0697 | 1 | 8 |
|
18
|
+
| W0700 | 1 | 8 |
|
19
|
+
| W0457 | 1 | 8 |
|
20
|
+
| W0628 | 1 | 8 |
|
21
|
+
|
22
|
+
Scenario: a `return' statement without expression in the implicitly typed
|
23
|
+
function
|
24
|
+
Given a target source named "W0700.c" with:
|
25
|
+
"""
|
26
|
+
extern func(void) /* W0700 */
|
27
|
+
{
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
"""
|
31
|
+
When I successfully run `adlint W0700.c` on noarch
|
32
|
+
Then the output should exactly match with:
|
33
|
+
| mesg | line | column |
|
34
|
+
| W0117 | 1 | 8 |
|
35
|
+
| W0700 | 1 | 8 |
|
36
|
+
| W0457 | 1 | 8 |
|
37
|
+
| W0699 | 3 | 5 |
|
38
|
+
| W0628 | 1 | 8 |
|
39
|
+
|
40
|
+
Scenario: a `return' statement with expression in the implicitly typed
|
41
|
+
function
|
42
|
+
Given a target source named "W0700.c" with:
|
43
|
+
"""
|
44
|
+
extern func(void) /* OK */
|
45
|
+
{
|
46
|
+
return 0;
|
47
|
+
}
|
48
|
+
"""
|
49
|
+
When I successfully run `adlint W0700.c` on noarch
|
50
|
+
Then the output should exactly match with:
|
51
|
+
| mesg | line | column |
|
52
|
+
| W0117 | 1 | 8 |
|
53
|
+
| W0457 | 1 | 8 |
|
54
|
+
| W0628 | 1 | 8 |
|
55
|
+
|
56
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -4,7 +4,7 @@ Feature: W1031
|
|
4
4
|
storage-class-specifiers.
|
5
5
|
|
6
6
|
Scenario: function declaration with `static' and function definition without
|
7
|
-
storage-class-specifier
|
7
|
+
storage-class-specifier
|
8
8
|
Given a target source named "W1031.c" with:
|
9
9
|
"""
|
10
10
|
static int foo(long);
|
@@ -22,7 +22,7 @@ Feature: W1031
|
|
22
22
|
| W0628 | 3 | 5 |
|
23
23
|
|
24
24
|
Scenario: function declaration with `extern' and function definition without
|
25
|
-
storage-class-specifier
|
25
|
+
storage-class-specifier
|
26
26
|
Given a target source named "W1031.c" with:
|
27
27
|
"""
|
28
28
|
extern int foo(long);
|
@@ -40,7 +40,7 @@ Feature: W1031
|
|
40
40
|
| W0628 | 3 | 5 |
|
41
41
|
|
42
42
|
Scenario: function declaration without storage-class-specifier and function
|
43
|
-
definition without storage-class-specifier
|
43
|
+
definition without storage-class-specifier
|
44
44
|
Given a target source named "W1031.c" with:
|
45
45
|
"""
|
46
46
|
int foo(long);
|
@@ -58,7 +58,7 @@ Feature: W1031
|
|
58
58
|
| W0628 | 3 | 5 |
|
59
59
|
|
60
60
|
Scenario: function declaration without storage-class-specifier and function
|
61
|
-
definition with `static'
|
61
|
+
definition with `static'
|
62
62
|
Given a target source named "W1031.c" with:
|
63
63
|
"""
|
64
64
|
int foo(long);
|
@@ -76,7 +76,7 @@ Feature: W1031
|
|
76
76
|
| W0628 | 3 | 12 |
|
77
77
|
|
78
78
|
Scenario: function declaration without storage-class-specifier and function
|
79
|
-
definition with `extern'
|
79
|
+
definition with `extern'
|
80
80
|
Given a target source named "W1031.c" with:
|
81
81
|
"""
|
82
82
|
int foo(long);
|
@@ -94,7 +94,7 @@ Feature: W1031
|
|
94
94
|
| W0628 | 3 | 12 |
|
95
95
|
|
96
96
|
Scenario: function declaration with `static' and function definition with
|
97
|
-
`extern'
|
97
|
+
`extern'
|
98
98
|
Given a target source named "W1031.c" with:
|
99
99
|
"""
|
100
100
|
static int foo(long);
|
@@ -113,7 +113,7 @@ Feature: W1031
|
|
113
113
|
| W0628 | 3 | 12 |
|
114
114
|
|
115
115
|
Scenario: function declaration with `extern' and function definition with
|
116
|
-
`static'
|
116
|
+
`static'
|
117
117
|
Given a target source named "W1031.c" with:
|
118
118
|
"""
|
119
119
|
extern int foo(long);
|
@@ -132,7 +132,7 @@ Feature: W1031
|
|
132
132
|
| W0628 | 3 | 12 |
|
133
133
|
|
134
134
|
Scenario: variable declaration with `extern' and variable definition without
|
135
|
-
storage-class-specifier
|
135
|
+
storage-class-specifier
|
136
136
|
Given a target source named "W1031.c" with:
|
137
137
|
"""
|
138
138
|
extern int i;
|
@@ -145,7 +145,7 @@ Feature: W1031
|
|
145
145
|
| W0118 | 1 | 12 |
|
146
146
|
|
147
147
|
Scenario: variable definition without storage-class-specifier and variable
|
148
|
-
declaration with `extern'
|
148
|
+
declaration with `extern'
|
149
149
|
Given a target source named "W1031.c" with:
|
150
150
|
"""
|
151
151
|
int i;
|
@@ -159,7 +159,7 @@ Feature: W1031
|
|
159
159
|
| W0118 | 2 | 12 |
|
160
160
|
|
161
161
|
Scenario: function declaration with `static' and function definition with
|
162
|
-
`extern'
|
162
|
+
`extern'
|
163
163
|
Given a target source named "W1031.c" with:
|
164
164
|
"""
|
165
165
|
static int i;
|
@@ -172,7 +172,7 @@ Feature: W1031
|
|
172
172
|
| W1031 | 2 | 12 |
|
173
173
|
|
174
174
|
Scenario: variable declaration with `extern' and variable definition with
|
175
|
-
`static'
|
175
|
+
`static'
|
176
176
|
Given a target source named "W1031.c" with:
|
177
177
|
"""
|
178
178
|
extern int i;
|
@@ -186,7 +186,7 @@ Feature: W1031
|
|
186
186
|
| W1031 | 2 | 12 |
|
187
187
|
|
188
188
|
Scenario: function definition with `static' and function declaration without
|
189
|
-
storage-class-specifier
|
189
|
+
storage-class-specifier
|
190
190
|
Given a target source named "W1031.c" with:
|
191
191
|
"""
|
192
192
|
static int foo(long l) {
|
@@ -205,7 +205,7 @@ Feature: W1031
|
|
205
205
|
| W0628 | 1 | 12 |
|
206
206
|
|
207
207
|
Scenario: function definition with `extern' and function declaration without
|
208
|
-
storage-class-specifier
|
208
|
+
storage-class-specifier
|
209
209
|
Given a target source named "W1031.c" with:
|
210
210
|
"""
|
211
211
|
extern int foo(long l) {
|
@@ -225,7 +225,7 @@ Feature: W1031
|
|
225
225
|
| W0628 | 1 | 12 |
|
226
226
|
|
227
227
|
Scenario: function definition without storage-class-specifier and function
|
228
|
-
declaration without storage-class-specifier
|
228
|
+
declaration without storage-class-specifier
|
229
229
|
Given a target source named "W1031.c" with:
|
230
230
|
"""
|
231
231
|
int foo(long l) {
|
@@ -245,7 +245,7 @@ Feature: W1031
|
|
245
245
|
| W0628 | 1 | 5 |
|
246
246
|
|
247
247
|
Scenario: function definition without storage-class-specifier and function
|
248
|
-
declaration with `static'
|
248
|
+
declaration with `static'
|
249
249
|
Given a target source named "W1031.c" with:
|
250
250
|
"""
|
251
251
|
int foo(long l) {
|
@@ -266,7 +266,7 @@ Feature: W1031
|
|
266
266
|
| W0628 | 1 | 5 |
|
267
267
|
|
268
268
|
Scenario: function definition without storage-class-specifier and function
|
269
|
-
declaration with `extern'
|
269
|
+
declaration with `extern'
|
270
270
|
Given a target source named "W1031.c" with:
|
271
271
|
"""
|
272
272
|
int foo(long l) {
|
@@ -286,7 +286,7 @@ Feature: W1031
|
|
286
286
|
| W0628 | 1 | 5 |
|
287
287
|
|
288
288
|
Scenario: function definition with `static' and function declaration with
|
289
|
-
`extern'
|
289
|
+
`extern'
|
290
290
|
Given a target source named "W1031.c" with:
|
291
291
|
"""
|
292
292
|
static int foo(long l) {
|
@@ -305,7 +305,7 @@ Feature: W1031
|
|
305
305
|
| W0628 | 1 | 12 |
|
306
306
|
|
307
307
|
Scenario: function definition with `extern' and function declaration with
|
308
|
-
`static'
|
308
|
+
`static'
|
309
309
|
Given a target source named "W1031.c" with:
|
310
310
|
"""
|
311
311
|
extern int foo(long l) {
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Feature: W1066
|
2
|
+
|
3
|
+
W1066 detects that a value of the `float' typed compound expression is
|
4
|
+
explicitly converted into a `double' value.
|
5
|
+
|
6
|
+
Scenario: explicit conversion from `float' to `double' when the source value
|
7
|
+
is derived from `+', `-', `*' or `/' expressions
|
8
|
+
Given a target source named "W1066.c" with:
|
9
|
+
"""
|
10
|
+
static void func(float a, float b)
|
11
|
+
{
|
12
|
+
double c;
|
13
|
+
c = (double) (a + b); /* W1066 */
|
14
|
+
c = (double) (a - b); /* W1066 */
|
15
|
+
c = (double) (a * b); /* W1066 */
|
16
|
+
c = (double) (a / b); /* W1066 */
|
17
|
+
}
|
18
|
+
"""
|
19
|
+
When I successfully run `adlint W1066.c` on noarch
|
20
|
+
Then the output should exactly match with:
|
21
|
+
| mesg | line | column |
|
22
|
+
| W0723 | 4 | 21 |
|
23
|
+
| W1066 | 4 | 21 |
|
24
|
+
| W0723 | 5 | 21 |
|
25
|
+
| W1066 | 5 | 21 |
|
26
|
+
| W0723 | 6 | 21 |
|
27
|
+
| W1066 | 6 | 21 |
|
28
|
+
| W0093 | 7 | 21 |
|
29
|
+
| W1066 | 7 | 21 |
|
30
|
+
| W0104 | 1 | 24 |
|
31
|
+
| W0104 | 1 | 33 |
|
32
|
+
| W0629 | 1 | 13 |
|
33
|
+
| W0628 | 1 | 13 |
|
34
|
+
|
35
|
+
Scenario: explicit conversion from `float' to `double' when the source value
|
36
|
+
is not derived from `+', `-', `*' or `/' expressions
|
37
|
+
Given a target source named "W1066.c" with:
|
38
|
+
"""
|
39
|
+
static void func(float a, float b)
|
40
|
+
{
|
41
|
+
double c;
|
42
|
+
c = (double) (a % b); /* OK */
|
43
|
+
c = (double) (a < b); /* OK */
|
44
|
+
c = (double) (a << b); /* OK */
|
45
|
+
c = (double) (a ^ b); /* OK */
|
46
|
+
}
|
47
|
+
"""
|
48
|
+
When I successfully run `adlint W1066.c` on noarch
|
49
|
+
Then the output should exactly match with:
|
50
|
+
| mesg | line | column |
|
51
|
+
| W0093 | 4 | 21 |
|
52
|
+
| W0570 | 6 | 21 |
|
53
|
+
| W0572 | 6 | 21 |
|
54
|
+
| W0572 | 7 | 21 |
|
55
|
+
| W0104 | 1 | 24 |
|
56
|
+
| W0104 | 1 | 33 |
|
57
|
+
| W0629 | 1 | 13 |
|
58
|
+
| W0628 | 1 | 13 |
|
59
|
+
|
60
|
+
Scenario: implicit conversion from `float' to `double'
|
61
|
+
Given a target source named "W1066.c" with:
|
62
|
+
"""
|
63
|
+
static void func(float a, float b)
|
64
|
+
{
|
65
|
+
double c;
|
66
|
+
c = a + b; /* W0777 */
|
67
|
+
c = a - b; /* W0777 */
|
68
|
+
c = a * b; /* W0777 */
|
69
|
+
c = a / b; /* W0777 */
|
70
|
+
}
|
71
|
+
"""
|
72
|
+
When I successfully run `adlint W1066.c` on noarch
|
73
|
+
Then the output should exactly match with:
|
74
|
+
| mesg | line | column |
|
75
|
+
| W0723 | 4 | 11 |
|
76
|
+
| W0777 | 4 | 11 |
|
77
|
+
| W0723 | 5 | 11 |
|
78
|
+
| W0777 | 5 | 11 |
|
79
|
+
| W0723 | 6 | 11 |
|
80
|
+
| W0777 | 6 | 11 |
|
81
|
+
| W0093 | 7 | 11 |
|
82
|
+
| W0777 | 7 | 11 |
|
83
|
+
| W0104 | 1 | 24 |
|
84
|
+
| W0104 | 1 | 33 |
|
85
|
+
| W0629 | 1 | 13 |
|
86
|
+
| W0628 | 1 | 13 |
|
87
|
+
|
88
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Feature: W1067
|
2
|
+
|
3
|
+
W1067 detects that a value of the `float' typed compound expression is
|
4
|
+
explicitly converted into a `long double' value.
|
5
|
+
|
6
|
+
Scenario: explicit conversion from `float' to `double' when the source value
|
7
|
+
is derived from `+', `-', `*' or `/' expressions
|
8
|
+
Given a target source named "W1067.c" with:
|
9
|
+
"""
|
10
|
+
static void func(float a, float b)
|
11
|
+
{
|
12
|
+
long double c;
|
13
|
+
c = (long double) (a + b); /* W1067 */
|
14
|
+
c = (long double) (a - b); /* W1067 */
|
15
|
+
c = (long double) (a * b); /* W1067 */
|
16
|
+
c = (long double) (a / b); /* W1067 */
|
17
|
+
}
|
18
|
+
"""
|
19
|
+
When I successfully run `adlint W1067.c` on noarch
|
20
|
+
Then the output should exactly match with:
|
21
|
+
| mesg | line | column |
|
22
|
+
| W0723 | 4 | 26 |
|
23
|
+
| W1067 | 4 | 26 |
|
24
|
+
| W0723 | 5 | 26 |
|
25
|
+
| W1067 | 5 | 26 |
|
26
|
+
| W0723 | 6 | 26 |
|
27
|
+
| W1067 | 6 | 26 |
|
28
|
+
| W0093 | 7 | 26 |
|
29
|
+
| W1067 | 7 | 26 |
|
30
|
+
| W0104 | 1 | 24 |
|
31
|
+
| W0104 | 1 | 33 |
|
32
|
+
| W0629 | 1 | 13 |
|
33
|
+
| W0628 | 1 | 13 |
|
34
|
+
|
35
|
+
Scenario: explicit conversion from `float' to `double' when the source value
|
36
|
+
is not derived from `+', `-', `*' or `/' expressions
|
37
|
+
Given a target source named "W1067.c" with:
|
38
|
+
"""
|
39
|
+
static void func(float a, float b)
|
40
|
+
{
|
41
|
+
long double c;
|
42
|
+
c = (long double) (a % b); /* OK */
|
43
|
+
c = (long double) (a < b); /* OK */
|
44
|
+
c = (long double) (a << b); /* OK */
|
45
|
+
c = (long double) (a ^ b); /* OK */
|
46
|
+
}
|
47
|
+
"""
|
48
|
+
When I successfully run `adlint W1067.c` on noarch
|
49
|
+
Then the output should exactly match with:
|
50
|
+
| mesg | line | column |
|
51
|
+
| W0093 | 4 | 26 |
|
52
|
+
| W0570 | 6 | 26 |
|
53
|
+
| W0572 | 6 | 26 |
|
54
|
+
| W0572 | 7 | 26 |
|
55
|
+
| W0104 | 1 | 24 |
|
56
|
+
| W0104 | 1 | 33 |
|
57
|
+
| W0629 | 1 | 13 |
|
58
|
+
| W0628 | 1 | 13 |
|
59
|
+
|
60
|
+
Scenario: implicit conversion from `float' to `long double'
|
61
|
+
Given a target source named "W1067.c" with:
|
62
|
+
"""
|
63
|
+
static void func(float a, float b)
|
64
|
+
{
|
65
|
+
long double c;
|
66
|
+
c = a + b; /* W0778 */
|
67
|
+
c = a - b; /* W0778 */
|
68
|
+
c = a * b; /* W0778 */
|
69
|
+
c = a / b; /* W0778 */
|
70
|
+
}
|
71
|
+
"""
|
72
|
+
When I successfully run `adlint W1067.c` on noarch
|
73
|
+
Then the output should exactly match with:
|
74
|
+
| mesg | line | column |
|
75
|
+
| W0723 | 4 | 11 |
|
76
|
+
| W0778 | 4 | 11 |
|
77
|
+
| W0723 | 5 | 11 |
|
78
|
+
| W0778 | 5 | 11 |
|
79
|
+
| W0723 | 6 | 11 |
|
80
|
+
| W0778 | 6 | 11 |
|
81
|
+
| W0093 | 7 | 11 |
|
82
|
+
| W0778 | 7 | 11 |
|
83
|
+
| W0104 | 1 | 24 |
|
84
|
+
| W0104 | 1 | 33 |
|
85
|
+
| W0629 | 1 | 13 |
|
86
|
+
| W0628 | 1 | 13 |
|
87
|
+
|
88
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Feature: W1068
|
2
|
+
|
3
|
+
W1068 detects that a value of the `double' typed compound expression is
|
4
|
+
explicitly converted into a `long double' value.
|
5
|
+
|
6
|
+
Scenario: explicit conversion from `double' to `long double' when the source
|
7
|
+
value is derived from `+', `-', `*' or `/' expressions
|
8
|
+
Given a target source named "W1068.c" with:
|
9
|
+
"""
|
10
|
+
static void func(double a, double b)
|
11
|
+
{
|
12
|
+
long double c;
|
13
|
+
c = (long double) (a + b); /* W1068 */
|
14
|
+
c = (long double) (a - b); /* W1068 */
|
15
|
+
c = (long double) (a * b); /* W1068 */
|
16
|
+
c = (long double) (a / b); /* W1068 */
|
17
|
+
}
|
18
|
+
"""
|
19
|
+
When I successfully run `adlint W1068.c` on noarch
|
20
|
+
Then the output should exactly match with:
|
21
|
+
| mesg | line | column |
|
22
|
+
| W0723 | 4 | 26 |
|
23
|
+
| W1068 | 4 | 26 |
|
24
|
+
| W0723 | 5 | 26 |
|
25
|
+
| W1068 | 5 | 26 |
|
26
|
+
| W0723 | 6 | 26 |
|
27
|
+
| W1068 | 6 | 26 |
|
28
|
+
| W0093 | 7 | 26 |
|
29
|
+
| W1068 | 7 | 26 |
|
30
|
+
| W0104 | 1 | 25 |
|
31
|
+
| W0104 | 1 | 35 |
|
32
|
+
| W0629 | 1 | 13 |
|
33
|
+
| W0628 | 1 | 13 |
|
34
|
+
|
35
|
+
Scenario: explicit conversion from `double' to `long double' when the source
|
36
|
+
value is not derived from `+', `-', `*' or `/' expressions
|
37
|
+
Given a target source named "W1068.c" with:
|
38
|
+
"""
|
39
|
+
static void func(double a, double b)
|
40
|
+
{
|
41
|
+
long double c;
|
42
|
+
c = (long double) (a % b); /* OK */
|
43
|
+
c = (long double) (a < b); /* OK */
|
44
|
+
c = (long double) (a << b); /* OK */
|
45
|
+
c = (long double) (a ^ b); /* OK */
|
46
|
+
}
|
47
|
+
"""
|
48
|
+
When I successfully run `adlint W1068.c` on noarch
|
49
|
+
Then the output should exactly match with:
|
50
|
+
| mesg | line | column |
|
51
|
+
| W0093 | 4 | 26 |
|
52
|
+
| W0570 | 6 | 26 |
|
53
|
+
| W0572 | 6 | 26 |
|
54
|
+
| W0572 | 7 | 26 |
|
55
|
+
| W0104 | 1 | 25 |
|
56
|
+
| W0104 | 1 | 35 |
|
57
|
+
| W0629 | 1 | 13 |
|
58
|
+
| W0628 | 1 | 13 |
|
59
|
+
|
60
|
+
Scenario: implicit conversion from `double' to `long double'
|
61
|
+
Given a target source named "W1068.c" with:
|
62
|
+
"""
|
63
|
+
static void func(double a, double b)
|
64
|
+
{
|
65
|
+
long double c;
|
66
|
+
c = a + b; /* W0779 */
|
67
|
+
c = a - b; /* W0779 */
|
68
|
+
c = a * b; /* W0779 */
|
69
|
+
c = a / b; /* W0779 */
|
70
|
+
}
|
71
|
+
"""
|
72
|
+
When I successfully run `adlint W1068.c` on noarch
|
73
|
+
Then the output should exactly match with:
|
74
|
+
| mesg | line | column |
|
75
|
+
| W0723 | 4 | 11 |
|
76
|
+
| W0779 | 4 | 11 |
|
77
|
+
| W0723 | 5 | 11 |
|
78
|
+
| W0779 | 5 | 11 |
|
79
|
+
| W0723 | 6 | 11 |
|
80
|
+
| W0779 | 6 | 11 |
|
81
|
+
| W0093 | 7 | 11 |
|
82
|
+
| W0779 | 7 | 11 |
|
83
|
+
| W0104 | 1 | 25 |
|
84
|
+
| W0104 | 1 | 35 |
|
85
|
+
| W0629 | 1 | 13 |
|
86
|
+
| W0628 | 1 | 13 |
|
87
|
+
|
88
|
+
# vim:ts=2:sw=2:sts=2:et:
|