adlint 1.16.0 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/ChangeLog +471 -0
  2. data/MANIFEST +35 -8
  3. data/NEWS +50 -4
  4. data/bin/adlint +7 -7
  5. data/bin/adlint_chk +7 -7
  6. data/bin/adlint_cma +7 -7
  7. data/bin/adlint_sma +7 -7
  8. data/bin/adlintize +5 -5
  9. data/etc/mesg.d/en_US/messages.yml +3 -3
  10. data/etc/mesg.d/ja_JP/messages.yml +3 -3
  11. data/features/message_detection/E0013.feature +34 -0
  12. data/features/message_detection/W0007.feature +2 -0
  13. data/features/message_detection/W0583.feature +1 -2
  14. data/features/message_detection/W0641.feature +132 -0
  15. data/features/message_detection/W0643.feature +1 -1
  16. data/features/message_detection/W0644.feature +529 -0
  17. data/features/message_detection/W0645.feature +1 -1
  18. data/features/message_detection/W0649.feature +277 -0
  19. data/features/message_detection/W0650.feature +208 -0
  20. data/features/message_detection/W0697.feature +6 -0
  21. data/features/message_detection/W0705.feature +350 -0
  22. data/features/message_detection/W0707.feature +223 -0
  23. data/features/message_detection/W0711.feature +113 -0
  24. data/features/message_detection/W0712.feature +113 -0
  25. data/features/message_detection/W0713.feature +110 -0
  26. data/features/message_detection/W0714.feature +118 -0
  27. data/features/message_detection/W0715.feature +118 -0
  28. data/features/message_detection/W0716.feature +1 -0
  29. data/features/message_detection/W0717.feature +1 -0
  30. data/features/message_detection/W0718.feature +1 -0
  31. data/features/message_detection/W0719.feature +154 -0
  32. data/features/message_detection/W0723.feature +1 -2
  33. data/features/message_detection/W0732.feature +3 -0
  34. data/features/message_detection/W0733.feature +3 -0
  35. data/features/message_detection/W0734.feature +4 -0
  36. data/features/message_detection/W0735.feature +4 -0
  37. data/features/message_detection/W0745.feature +132 -0
  38. data/features/message_detection/W0780.feature +68 -0
  39. data/features/message_detection/W0783.feature +95 -0
  40. data/features/message_detection/W0792.feature +124 -0
  41. data/features/message_detection/W0793.feature +153 -0
  42. data/features/message_detection/W0794.feature +90 -0
  43. data/features/message_detection/W0830.feature +65 -0
  44. data/features/message_detection/W0833.feature +220 -0
  45. data/features/message_detection/W0834.feature +189 -0
  46. data/features/message_detection/W1026.feature +105 -0
  47. data/features/message_detection/W1031.feature +17 -34
  48. data/features/message_detection/W1039.feature +268 -0
  49. data/features/message_detection/W1047.feature +163 -0
  50. data/features/message_detection/W1066.feature +1 -0
  51. data/features/message_detection/W1067.feature +1 -0
  52. data/features/message_detection/W1068.feature +1 -0
  53. data/features/message_detection/W1069.feature +5 -0
  54. data/features/message_detection/W1070.feature +5 -0
  55. data/features/message_detection/W1071.feature +83 -0
  56. data/features/message_detection/W1073.feature +3 -2
  57. data/features/message_detection/W9003.feature +7 -12
  58. data/features/step_definitions/message_detection_steps.rb +4 -31
  59. data/features/support/env.rb +117 -2
  60. data/lib/adlint/c/branch.rb +0 -2
  61. data/lib/adlint/c/ctrlexpr.rb +33 -0
  62. data/lib/adlint/c/expr.rb +119 -31
  63. data/lib/adlint/c/interp.rb +44 -3
  64. data/lib/adlint/c/message.rb +1411 -29
  65. data/lib/adlint/c/object.rb +16 -2
  66. data/lib/adlint/c/option.rb +1 -0
  67. data/lib/adlint/c/parser.rb +101 -100
  68. data/lib/adlint/c/parser.y +3 -2
  69. data/lib/adlint/c/phase.rb +18 -0
  70. data/lib/adlint/c/resolver.rb +23 -0
  71. data/lib/adlint/c/syntax.rb +90 -4
  72. data/lib/adlint/c/type.rb +177 -110
  73. data/lib/adlint/cpp/macro.rb +4 -4
  74. data/lib/adlint/version.rb +2 -2
  75. data/share/demo/bad_include/test/"1/".h +0 -0
  76. data/share/doc/developers_guide_ja.html +3 -3
  77. data/share/doc/developers_guide_ja.texi +1 -1
  78. data/share/doc/users_guide_en.html +467 -506
  79. data/share/doc/users_guide_en.texi +95 -125
  80. data/share/doc/users_guide_ja.html +471 -518
  81. data/share/doc/users_guide_ja.texi +95 -133
  82. data/spec/spec_helper.rb +6 -0
  83. metadata +37 -10
@@ -98,7 +98,7 @@ Feature: W0645
98
98
  Scenario: a `void' as a parameter-type-list
99
99
  Given a target source named "W0645.c" with:
100
100
  """
101
- extern void func(void); /* OK */
101
+ extern void func(void); /* OK */
102
102
  """
103
103
  When I successfully run `adlint W0645.c` on noarch
104
104
  Then the output should exactly match with:
@@ -0,0 +1,277 @@
1
+ Feature: W0649
2
+
3
+ W0649 detects that right hand side of the shift-expression is
4
+ a constant-expression of negative value.
5
+
6
+ Scenario: left shift-expression with negative constant rhs value
7
+ Given a target source named "W0649.c" with:
8
+ """
9
+ int foo(int i)
10
+ {
11
+ return i << -1; /* W0649 */
12
+ }
13
+ """
14
+ When I successfully run `adlint W0649.c` on noarch
15
+ Then the output should exactly match with:
16
+ | mesg | line | column |
17
+ | W0117 | 1 | 5 |
18
+ | W0570 | 3 | 14 |
19
+ | W0572 | 3 | 14 |
20
+ | W0649 | 3 | 14 |
21
+ | W0794 | 3 | 14 |
22
+ | W0104 | 1 | 13 |
23
+ | W0628 | 1 | 5 |
24
+
25
+ Scenario: right shift-expression with negative constant rhs value
26
+ Given a target source named "W0649.c" with:
27
+ """
28
+ int foo(int i)
29
+ {
30
+ return i >> -1; /* W0649 */
31
+ }
32
+ """
33
+ When I successfully run `adlint W0649.c` on noarch
34
+ Then the output should exactly match with:
35
+ | mesg | line | column |
36
+ | W0117 | 1 | 5 |
37
+ | W0571 | 3 | 14 |
38
+ | W0572 | 3 | 14 |
39
+ | W0649 | 3 | 14 |
40
+ | W0104 | 1 | 13 |
41
+ | W0628 | 1 | 5 |
42
+
43
+ Scenario: left shift-expression with negative constant rhs value derived by
44
+ macro
45
+ Given a target source named "W0649.c" with:
46
+ """
47
+ #define VAL (-1)
48
+
49
+ int foo(int i)
50
+ {
51
+ return i << VAL; /* W0649 */
52
+ }
53
+ """
54
+ When I successfully run `adlint W0649.c` on noarch
55
+ Then the output should exactly match with:
56
+ | mesg | line | column |
57
+ | W0117 | 3 | 5 |
58
+ | W0570 | 5 | 14 |
59
+ | W0572 | 5 | 14 |
60
+ | W0649 | 5 | 14 |
61
+ | W0794 | 5 | 14 |
62
+ | W0104 | 3 | 13 |
63
+ | W0628 | 3 | 5 |
64
+
65
+ Scenario: right shift-expression with negative constant rhs value derived by
66
+ macro
67
+ Given a target source named "W0649.c" with:
68
+ """
69
+ #define VAL (-1)
70
+
71
+ int foo(int i)
72
+ {
73
+ return i >> VAL; /* W0649 */
74
+ }
75
+ """
76
+ When I successfully run `adlint W0649.c` on noarch
77
+ Then the output should exactly match with:
78
+ | mesg | line | column |
79
+ | W0117 | 3 | 5 |
80
+ | W0571 | 5 | 14 |
81
+ | W0572 | 5 | 14 |
82
+ | W0649 | 5 | 14 |
83
+ | W0104 | 3 | 13 |
84
+ | W0628 | 3 | 5 |
85
+
86
+ Scenario: left shift-expression with positive constant rhs value
87
+ Given a target source named "W0649.c" with:
88
+ """
89
+ int foo(int i)
90
+ {
91
+ return i << 1; /* OK */
92
+ }
93
+ """
94
+ When I successfully run `adlint W0649.c` on noarch
95
+ Then the output should exactly match with:
96
+ | mesg | line | column |
97
+ | W0117 | 1 | 5 |
98
+ | W0570 | 3 | 14 |
99
+ | W0572 | 3 | 14 |
100
+ | W0794 | 3 | 14 |
101
+ | W0104 | 1 | 13 |
102
+ | W0628 | 1 | 5 |
103
+
104
+ Scenario: right shift-expression with positive constant rhs value
105
+ Given a target source named "W0649.c" with:
106
+ """
107
+ int foo(int i)
108
+ {
109
+ return i >> 1; /* OK */
110
+ }
111
+ """
112
+ When I successfully run `adlint W0649.c` on noarch
113
+ Then the output should exactly match with:
114
+ | mesg | line | column |
115
+ | W0117 | 1 | 5 |
116
+ | W0571 | 3 | 14 |
117
+ | W0572 | 3 | 14 |
118
+ | W0104 | 1 | 13 |
119
+ | W0628 | 1 | 5 |
120
+
121
+ Scenario: left shift-expression with zero constant rhs value
122
+ Given a target source named "W0649.c" with:
123
+ """
124
+ int foo(int i)
125
+ {
126
+ return i << 0; /* OK */
127
+ }
128
+ """
129
+ When I successfully run `adlint W0649.c` on noarch
130
+ Then the output should exactly match with:
131
+ | mesg | line | column |
132
+ | W0117 | 1 | 5 |
133
+ | W0570 | 3 | 14 |
134
+ | W0572 | 3 | 14 |
135
+ | W0794 | 3 | 14 |
136
+ | W0104 | 1 | 13 |
137
+ | W0628 | 1 | 5 |
138
+
139
+ Scenario: right shift-expression with zero constant rhs value
140
+ Given a target source named "W0649.c" with:
141
+ """
142
+ int foo(int i)
143
+ {
144
+ return i >> 0; /* OK */
145
+ }
146
+ """
147
+ When I successfully run `adlint W0649.c` on noarch
148
+ Then the output should exactly match with:
149
+ | mesg | line | column |
150
+ | W0117 | 1 | 5 |
151
+ | W0571 | 3 | 14 |
152
+ | W0572 | 3 | 14 |
153
+ | W0104 | 1 | 13 |
154
+ | W0628 | 1 | 5 |
155
+
156
+ Scenario: left shift compound-assignment-expression with negative constant
157
+ rhs value
158
+ Given a target source named "W0649.c" with:
159
+ """
160
+ void foo(int i)
161
+ {
162
+ i <<= -1; /* W0649 */
163
+ }
164
+ """
165
+ When I successfully run `adlint W0649.c` on noarch
166
+ Then the output should exactly match with:
167
+ | mesg | line | column |
168
+ | W0117 | 1 | 6 |
169
+ | W0570 | 3 | 7 |
170
+ | W0572 | 3 | 7 |
171
+ | W0649 | 3 | 7 |
172
+ | W0794 | 3 | 7 |
173
+ | W0628 | 1 | 6 |
174
+
175
+ Scenario: right shift compound-assignment-expression with negative constant
176
+ rhs value
177
+ Given a target source named "W0649.c" with:
178
+ """
179
+ void foo(int i)
180
+ {
181
+ i >>= -1; /* W0649 */
182
+ }
183
+ """
184
+ When I successfully run `adlint W0649.c` on noarch
185
+ Then the output should exactly match with:
186
+ | mesg | line | column |
187
+ | W0117 | 1 | 6 |
188
+ | W0571 | 3 | 7 |
189
+ | W0572 | 3 | 7 |
190
+ | W0649 | 3 | 7 |
191
+ | W0628 | 1 | 6 |
192
+
193
+ Scenario: left shift-expression with negative constant rhs value derived by
194
+ enumerator
195
+ Given a target source named "W0649.c" with:
196
+ """
197
+ enum e { VAL = -2 };
198
+
199
+ int foo(int i)
200
+ {
201
+ return i << VAL; /* W0649 */
202
+ }
203
+ """
204
+ When I successfully run `adlint W0649.c` on noarch
205
+ Then the output should exactly match with:
206
+ | mesg | line | column |
207
+ | W0117 | 3 | 5 |
208
+ | W0570 | 5 | 14 |
209
+ | W0572 | 5 | 14 |
210
+ | W0649 | 5 | 14 |
211
+ | W0794 | 5 | 14 |
212
+ | W0104 | 3 | 13 |
213
+ | W0628 | 3 | 5 |
214
+
215
+ Scenario: right shift-expression with negative constant rhs value derived by
216
+ enumerator
217
+ Given a target source named "W0649.c" with:
218
+ """
219
+ enum e { VAL = -2 };
220
+
221
+ int foo(int i)
222
+ {
223
+ return i >> VAL; /* W0649 */
224
+ }
225
+ """
226
+ When I successfully run `adlint W0649.c` on noarch
227
+ Then the output should exactly match with:
228
+ | mesg | line | column |
229
+ | W0117 | 3 | 5 |
230
+ | W0571 | 5 | 14 |
231
+ | W0572 | 5 | 14 |
232
+ | W0649 | 5 | 14 |
233
+ | W0104 | 3 | 13 |
234
+ | W0628 | 3 | 5 |
235
+
236
+ Scenario: left shift-expression with positive constant rhs value derived by
237
+ enumerator
238
+ Given a target source named "W0649.c" with:
239
+ """
240
+ enum e { VAL = 2 };
241
+
242
+ int foo(int i)
243
+ {
244
+ return i << VAL; /* OK */
245
+ }
246
+ """
247
+ When I successfully run `adlint W0649.c` on noarch
248
+ Then the output should exactly match with:
249
+ | mesg | line | column |
250
+ | W0117 | 3 | 5 |
251
+ | W0570 | 5 | 14 |
252
+ | W0572 | 5 | 14 |
253
+ | W0794 | 5 | 14 |
254
+ | W0104 | 3 | 13 |
255
+ | W0628 | 3 | 5 |
256
+
257
+ Scenario: right shift-expression with positive constant rhs value derived by
258
+ enumerator
259
+ Given a target source named "W0649.c" with:
260
+ """
261
+ enum e { VAL = 2 };
262
+
263
+ int foo(int i)
264
+ {
265
+ return i >> VAL; /* OK */
266
+ }
267
+ """
268
+ When I successfully run `adlint W0649.c` on noarch
269
+ Then the output should exactly match with:
270
+ | mesg | line | column |
271
+ | W0117 | 3 | 5 |
272
+ | W0571 | 5 | 14 |
273
+ | W0572 | 5 | 14 |
274
+ | W0104 | 3 | 13 |
275
+ | W0628 | 3 | 5 |
276
+
277
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,208 @@
1
+ Feature: W0650
2
+
3
+ W0650 detects that right hand side of shift-expression is greater than the
4
+ bit length of left hand side value.
5
+
6
+ Scenario: 32-bit left shift-expression of `int' value
7
+ Given a target source named "W0650.c" with:
8
+ """
9
+ unsigned int foo(unsigned int i)
10
+ {
11
+ return i << 32; /* W0650 */
12
+ }
13
+ """
14
+ When I successfully run `adlint W0650.c` on noarch
15
+ Then the output should exactly match with:
16
+ | mesg | line | column |
17
+ | W0117 | 1 | 14 |
18
+ | W0116 | 3 | 14 |
19
+ | W0650 | 3 | 14 |
20
+ | W0104 | 1 | 31 |
21
+ | W0628 | 1 | 14 |
22
+
23
+ Scenario: 32-bit right shift-expression of `int' value
24
+ Given a target source named "W0650.c" with:
25
+ """
26
+ unsigned int foo(unsigned int i)
27
+ {
28
+ return i >> 32; /* W0650 */
29
+ }
30
+ """
31
+ When I successfully run `adlint W0650.c` on noarch
32
+ Then the output should exactly match with:
33
+ | mesg | line | column |
34
+ | W0117 | 1 | 14 |
35
+ | W0650 | 3 | 14 |
36
+ | W0104 | 1 | 31 |
37
+ | W0628 | 1 | 14 |
38
+
39
+ Scenario: 31-bit left shift-expression of `int' value
40
+ Given a target source named "W0650.c" with:
41
+ """
42
+ unsigned int foo(unsigned int i)
43
+ {
44
+ return i << 31; /* OK */
45
+ }
46
+ """
47
+ When I successfully run `adlint W0650.c` on noarch
48
+ Then the output should exactly match with:
49
+ | mesg | line | column |
50
+ | W0117 | 1 | 14 |
51
+ | W0116 | 3 | 14 |
52
+ | W0104 | 1 | 31 |
53
+ | W0628 | 1 | 14 |
54
+
55
+ Scenario: 31-bit right shift-expression of `int' value
56
+ Given a target source named "W0650.c" with:
57
+ """
58
+ unsigned int foo(unsigned int i)
59
+ {
60
+ return i >> 31; /* OK */
61
+ }
62
+ """
63
+ When I successfully run `adlint W0650.c` on noarch
64
+ Then the output should exactly match with:
65
+ | mesg | line | column |
66
+ | W0117 | 1 | 14 |
67
+ | W0104 | 1 | 31 |
68
+ | W0628 | 1 | 14 |
69
+
70
+ Scenario: 64-bit left shift-expression of `int' value
71
+ Given a target source named "W0650.c" with:
72
+ """
73
+ unsigned int foo(unsigned int i)
74
+ {
75
+ return i << 64; /* W0650 */
76
+ }
77
+ """
78
+ When I successfully run `adlint W0650.c` on noarch
79
+ Then the output should exactly match with:
80
+ | mesg | line | column |
81
+ | W0117 | 1 | 14 |
82
+ | W0116 | 3 | 14 |
83
+ | W0650 | 3 | 14 |
84
+ | W0104 | 1 | 31 |
85
+ | W0628 | 1 | 14 |
86
+
87
+ Scenario: 64-bit right shift-expression of `int' value
88
+ Given a target source named "W0650.c" with:
89
+ """
90
+ unsigned int foo(unsigned int i)
91
+ {
92
+ return i >> 64; /* W0650 */
93
+ }
94
+ """
95
+ When I successfully run `adlint W0650.c` on noarch
96
+ Then the output should exactly match with:
97
+ | mesg | line | column |
98
+ | W0117 | 1 | 14 |
99
+ | W0650 | 3 | 14 |
100
+ | W0104 | 1 | 31 |
101
+ | W0628 | 1 | 14 |
102
+
103
+ Scenario: 32-bit left shift compound-assignment-expression of `int' value
104
+ Given a target source named "W0650.c" with:
105
+ """
106
+ void foo(unsigned int i)
107
+ {
108
+ i <<= 32; /* W0650 */
109
+ }
110
+ """
111
+ When I successfully run `adlint W0650.c` on noarch
112
+ Then the output should exactly match with:
113
+ | mesg | line | column |
114
+ | W0117 | 1 | 6 |
115
+ | W0116 | 3 | 7 |
116
+ | W0650 | 3 | 7 |
117
+ | W0628 | 1 | 6 |
118
+
119
+ Scenario: 32-bit right shift compound-assignment-expression of `int' value
120
+ Given a target source named "W0650.c" with:
121
+ """
122
+ void foo(unsigned int i)
123
+ {
124
+ i >>= 32; /* W0650 */
125
+ }
126
+ """
127
+ When I successfully run `adlint W0650.c` on noarch
128
+ Then the output should exactly match with:
129
+ | mesg | line | column |
130
+ | W0117 | 1 | 6 |
131
+ | W0650 | 3 | 7 |
132
+ | W0628 | 1 | 6 |
133
+
134
+ Scenario: 31-bit left shift-expression of `char' value
135
+ Given a target source named "W0650.c" with:
136
+ """
137
+ int foo(char c)
138
+ {
139
+ return c << 31; /* OK because of the integer-promotion */
140
+ }
141
+ """
142
+ When I successfully run `adlint W0650.c` on noarch
143
+ Then the output should exactly match with:
144
+ | mesg | line | column |
145
+ | W0117 | 1 | 5 |
146
+ | W0123 | 3 | 12 |
147
+ | W0246 | 3 | 12 |
148
+ | W0116 | 3 | 14 |
149
+ | W0719 | 3 | 14 |
150
+ | W0104 | 1 | 14 |
151
+ | W0628 | 1 | 5 |
152
+
153
+ Scenario: 31-bit right shift-expression of `char' value
154
+ Given a target source named "W0650.c" with:
155
+ """
156
+ int foo(char c)
157
+ {
158
+ return c >> 31; /* OK because of the integer-promotion */
159
+ }
160
+ """
161
+ When I successfully run `adlint W0650.c` on noarch
162
+ Then the output should exactly match with:
163
+ | mesg | line | column |
164
+ | W0117 | 1 | 5 |
165
+ | W0123 | 3 | 12 |
166
+ | W0246 | 3 | 12 |
167
+ | W0719 | 3 | 14 |
168
+ | W0104 | 1 | 14 |
169
+ | W0628 | 1 | 5 |
170
+
171
+ Scenario: 31-bit left shift-expression of `char' value
172
+ Given a target source named "W0650.c" with:
173
+ """
174
+ int foo(char c)
175
+ {
176
+ return c << 32; /* W0650 */
177
+ }
178
+ """
179
+ When I successfully run `adlint W0650.c` on noarch
180
+ Then the output should exactly match with:
181
+ | mesg | line | column |
182
+ | W0117 | 1 | 5 |
183
+ | W0123 | 3 | 12 |
184
+ | W0246 | 3 | 12 |
185
+ | W0116 | 3 | 14 |
186
+ | W0650 | 3 | 14 |
187
+ | W0104 | 1 | 14 |
188
+ | W0628 | 1 | 5 |
189
+
190
+ Scenario: 31-bit right shift-expression of `char' value
191
+ Given a target source named "W0650.c" with:
192
+ """
193
+ int foo(char c)
194
+ {
195
+ return c >> 32; /* W0650 */
196
+ }
197
+ """
198
+ When I successfully run `adlint W0650.c` on noarch
199
+ Then the output should exactly match with:
200
+ | mesg | line | column |
201
+ | W0117 | 1 | 5 |
202
+ | W0123 | 3 | 12 |
203
+ | W0246 | 3 | 12 |
204
+ | W0650 | 3 | 14 |
205
+ | W0104 | 1 | 14 |
206
+ | W0628 | 1 | 5 |
207
+
208
+ # vim:ts=2:sw=2:sts=2:et: