adlint 1.8.10 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/ChangeLog +261 -3
  2. data/MANIFEST +25 -1
  3. data/NEWS +25 -5
  4. data/Rakefile +11 -0
  5. data/TODO +0 -1
  6. data/etc/mesg.d/en_US/messages.yml +1 -1
  7. data/etc/mesg.d/ja_JP/messages.yml +1 -1
  8. data/features/message_detection/W0001.feature +41 -0
  9. data/features/message_detection/W0002.feature +68 -0
  10. data/features/message_detection/W0003.feature +134 -0
  11. data/features/message_detection/W0007.feature +264 -0
  12. data/features/message_detection/W0010.feature +75 -0
  13. data/features/message_detection/W0013.feature +189 -0
  14. data/features/message_detection/W0109.feature +50 -0
  15. data/features/message_detection/W0583.feature +30 -0
  16. data/features/message_detection/W0606.feature +20 -0
  17. data/features/message_detection/W0698.feature +20 -0
  18. data/features/message_detection/W0699.feature +21 -0
  19. data/features/message_detection/W0703.feature +73 -0
  20. data/features/message_detection/W0716.feature +67 -0
  21. data/features/message_detection/W0717.feature +64 -0
  22. data/features/message_detection/W0718.feature +64 -0
  23. data/features/message_detection/W0723.feature +18 -0
  24. data/features/message_detection/W1031.feature +328 -0
  25. data/features/step_definitions/message_detection_steps.rb +45 -0
  26. data/features/support/env.rb +58 -0
  27. data/lib/adlint/c/branch.rb +16 -23
  28. data/lib/adlint/c/code.rb +1 -12
  29. data/lib/adlint/c/conv.rb +4 -4
  30. data/lib/adlint/c/ctrlexpr.rb +10 -6
  31. data/lib/adlint/c/domain.rb +2 -2
  32. data/lib/adlint/c/expr.rb +11 -33
  33. data/lib/adlint/c/format.rb +6 -6
  34. data/lib/adlint/c/interp.rb +137 -80
  35. data/lib/adlint/c/mediator.rb +5 -2
  36. data/lib/adlint/c/message.rb +123 -140
  37. data/lib/adlint/c/message_shima.rb +44 -0
  38. data/lib/adlint/c/object.rb +93 -26
  39. data/lib/adlint/c/option.rb +53 -0
  40. data/lib/adlint/c/phase.rb +4 -1
  41. data/lib/adlint/c/type.rb +112 -46
  42. data/lib/adlint/c.rb +1 -0
  43. data/lib/adlint/version.rb +3 -3
  44. data/share/doc/developers_guide_ja.html +3 -3
  45. data/share/doc/developers_guide_ja.texi +1 -1
  46. data/share/doc/users_guide_en.html +35 -28
  47. data/share/doc/users_guide_en.texi +30 -22
  48. data/share/doc/users_guide_ja.html +35 -31
  49. data/share/doc/users_guide_ja.texi +30 -24
  50. data/spec/adlint/c/type_spec.rb +110 -0
  51. data/spec/conf.d/default_traits.yml +216 -0
  52. data/spec/conf.d/empty_cinit.h +11 -0
  53. data/spec/conf.d/empty_pinit.h +11 -0
  54. data/spec/spec_helper.rb +49 -0
  55. metadata +27 -3
  56. data/spec/MUST_WRITE_SPECS_WITH_RSPEC +0 -0
@@ -0,0 +1,73 @@
1
+ Feature: W0703
2
+
3
+ W0703 detects that a tag name is hiding other tag names.
4
+
5
+ Scenario: tag hiding declaration in function-definition
6
+ Given a target source named "W0703.c" with:
7
+ """
8
+ struct Foo {
9
+ int i;
10
+ };
11
+
12
+ int main(void)
13
+ {
14
+ union Foo { /* W0703 */
15
+ int i;
16
+ int j;
17
+ } foo = { 0 };
18
+
19
+ return foo.i;
20
+ }
21
+ """
22
+ When I successfully run `adlint W0703.c` on noarch
23
+ Then the output should exactly match with:
24
+ | mesg | line | column |
25
+ | W0703 | 7 | 11 |
26
+ | W0785 | 7 | 11 |
27
+ | W0552 | 10 | 7 |
28
+ | W0100 | 10 | 7 |
29
+ | W0551 | 7 | 11 |
30
+
31
+ Scenario: tag hiding declaration in the global scope
32
+ Given a target source named "W0703.c" with:
33
+ """
34
+ struct Foo {
35
+ int i;
36
+ };
37
+
38
+ static union Foo { /* W0703 */
39
+ int i;
40
+ int j;
41
+ } foo = { 0 };
42
+ """
43
+ When I successfully run `adlint W0703.c` on noarch
44
+ Then the output should exactly match with:
45
+ | mesg | line | column |
46
+ | W0703 | 5 | 14 |
47
+ | W0785 | 5 | 14 |
48
+ | W0552 | 8 | 3 |
49
+ | W0551 | 5 | 14 |
50
+
51
+ Scenario: enum declaration in global and function scope
52
+ Given a target source named "W0703.c" with:
53
+ """
54
+ enum E { FOO, BAR };
55
+
56
+ int main(void)
57
+ {
58
+ enum E { BAR, BAZ } e = FOO; /* W0703 */
59
+ return e;
60
+ }
61
+ """
62
+ When I successfully run `adlint W0703.c` on noarch
63
+ Then the output should exactly match with:
64
+ | mesg | line | column |
65
+ | W0703 | 5 | 10 |
66
+ | W0704 | 5 | 14 |
67
+ | W0785 | 5 | 10 |
68
+ | W0789 | 5 | 14 |
69
+ | W1060 | 6 | 12 |
70
+ | W0100 | 5 | 25 |
71
+ | W0425 | 5 | 25 |
72
+
73
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,67 @@
1
+ Feature: W0716
2
+
3
+ W0716 detects that operands of both sides of bitwise expression or arithmetic
4
+ expression are `effectively boolean'.
5
+
6
+ Scenario: an arithmetic expression
7
+ Given a target source named "W0716.c" with:
8
+ """
9
+ static int foo(int a, int b, int c, int d)
10
+ {
11
+ return (a > b) + (c > d); /* W0716 */
12
+ }
13
+ """
14
+ When I successfully run `adlint W0716.c` on noarch
15
+ Then the output should exactly match with:
16
+ | mesg | line | column |
17
+ | W0723 | 3 | 20 |
18
+ | W0104 | 1 | 20 |
19
+ | W0104 | 1 | 27 |
20
+ | W0104 | 1 | 34 |
21
+ | W0104 | 1 | 41 |
22
+ | W0629 | 1 | 12 |
23
+ | W0716 | 3 | 20 |
24
+ | W0628 | 1 | 12 |
25
+
26
+ Scenario: a bitwise expression
27
+ Given a target source named "W0716.c" with:
28
+ """
29
+ static int foo(int a, int b, int c, int d)
30
+ {
31
+ return (a > b) ^ (c > d); /* W0716 */
32
+ }
33
+ """
34
+ When I successfully run `adlint W0716.c` on noarch
35
+ Then the output should exactly match with:
36
+ | mesg | line | column |
37
+ | W0572 | 3 | 20 |
38
+ | W0104 | 1 | 20 |
39
+ | W0104 | 1 | 27 |
40
+ | W0104 | 1 | 34 |
41
+ | W0104 | 1 | 41 |
42
+ | W0629 | 1 | 12 |
43
+ | W0716 | 3 | 20 |
44
+ | W0628 | 1 | 12 |
45
+
46
+ Scenario: a shift expression
47
+ Given a target source named "W0716.c" with:
48
+ """
49
+ static int foo(int a, int b, int c, int d)
50
+ {
51
+ return (a > b) << (c > d); /* W0716 */
52
+ }
53
+ """
54
+ When I successfully run `adlint W0716.c` on noarch
55
+ Then the output should exactly match with:
56
+ | mesg | line | column |
57
+ | W0570 | 3 | 20 |
58
+ | W0572 | 3 | 20 |
59
+ | W0104 | 1 | 20 |
60
+ | W0104 | 1 | 27 |
61
+ | W0104 | 1 | 34 |
62
+ | W0104 | 1 | 41 |
63
+ | W0629 | 1 | 12 |
64
+ | W0716 | 3 | 20 |
65
+ | W0628 | 1 | 12 |
66
+
67
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,64 @@
1
+ Feature: W0717
2
+
3
+ W0717 detects that operand of left side of bitwise expression or arithmetic
4
+ expression is `effectively boolean'.
5
+
6
+ Scenario: an arithmetic expression
7
+ Given a target source named "W0717.c" with:
8
+ """
9
+ static int func(int a, int b, int c)
10
+ {
11
+ return (a > b) + c; /* W0717 */
12
+ }
13
+ """
14
+ When I successfully run `adlint W0717.c` on noarch
15
+ Then the output should exactly match with:
16
+ | mesg | line | column |
17
+ | W0723 | 3 | 20 |
18
+ | W0104 | 1 | 21 |
19
+ | W0104 | 1 | 28 |
20
+ | W0104 | 1 | 35 |
21
+ | W0629 | 1 | 12 |
22
+ | W0717 | 3 | 12 |
23
+ | W0628 | 1 | 12 |
24
+
25
+ Scenario: a bitwise expression
26
+ Given a target source named "W0717.c" with:
27
+ """
28
+ static int func(int a, int b, int c)
29
+ {
30
+ return (a > b) ^ c; /* W0717 */
31
+ }
32
+ """
33
+ When I successfully run `adlint W0717.c` on noarch
34
+ Then the output should exactly match with:
35
+ | mesg | line | column |
36
+ | W0572 | 3 | 20 |
37
+ | W0104 | 1 | 21 |
38
+ | W0104 | 1 | 28 |
39
+ | W0104 | 1 | 35 |
40
+ | W0629 | 1 | 12 |
41
+ | W0717 | 3 | 12 |
42
+ | W0628 | 1 | 12 |
43
+
44
+ Scenario: a shift expression
45
+ Given a target source named "W0717.c" with:
46
+ """
47
+ static int func(int a, int b, int c)
48
+ {
49
+ return (a > b) << c; /* W0717 */
50
+ }
51
+ """
52
+ When I successfully run `adlint W0717.c` on noarch
53
+ Then the output should exactly match with:
54
+ | mesg | line | column |
55
+ | W0570 | 3 | 20 |
56
+ | W0572 | 3 | 20 |
57
+ | W0104 | 1 | 21 |
58
+ | W0104 | 1 | 28 |
59
+ | W0104 | 1 | 35 |
60
+ | W0629 | 1 | 12 |
61
+ | W0717 | 3 | 12 |
62
+ | W0628 | 1 | 12 |
63
+
64
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,64 @@
1
+ Feature: W0718
2
+
3
+ W0718 detects that operand of right side of bitwise expression or arithmetic
4
+ expression is `effectively boolean'.
5
+
6
+ Scenario: an arithmetic expression
7
+ Given a target source named "W0718.c" with:
8
+ """
9
+ static int func(int a, int b, int c)
10
+ {
11
+ return a + (b > c); /* W0718 */
12
+ }
13
+ """
14
+ When I successfully run `adlint W0718.c` on noarch
15
+ Then the output should exactly match with:
16
+ | mesg | line | column |
17
+ | W0723 | 3 | 14 |
18
+ | W0104 | 1 | 21 |
19
+ | W0104 | 1 | 28 |
20
+ | W0104 | 1 | 35 |
21
+ | W0629 | 1 | 12 |
22
+ | W0718 | 3 | 16 |
23
+ | W0628 | 1 | 12 |
24
+
25
+ Scenario: a bitwise expression
26
+ Given a target source named "W0718.c" with:
27
+ """
28
+ static int func(int a, int b, int c)
29
+ {
30
+ return a ^ (b > c); /* W0718 */
31
+ }
32
+ """
33
+ When I successfully run `adlint W0718.c` on noarch
34
+ Then the output should exactly match with:
35
+ | mesg | line | column |
36
+ | W0572 | 3 | 14 |
37
+ | W0104 | 1 | 21 |
38
+ | W0104 | 1 | 28 |
39
+ | W0104 | 1 | 35 |
40
+ | W0629 | 1 | 12 |
41
+ | W0718 | 3 | 16 |
42
+ | W0628 | 1 | 12 |
43
+
44
+ Scenario: a shift expression
45
+ Given a target source named "W0718.c" with:
46
+ """
47
+ static int func(int a, int b, int c)
48
+ {
49
+ return a << (b > c); /* W0718 */
50
+ }
51
+ """
52
+ When I successfully run `adlint W0718.c` on noarch
53
+ Then the output should exactly match with:
54
+ | mesg | line | column |
55
+ | W0570 | 3 | 14 |
56
+ | W0572 | 3 | 14 |
57
+ | W0104 | 1 | 21 |
58
+ | W0104 | 1 | 28 |
59
+ | W0104 | 1 | 35 |
60
+ | W0629 | 1 | 12 |
61
+ | W0718 | 3 | 17 |
62
+ | W0628 | 1 | 12 |
63
+
64
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,18 @@
1
+ Feature: W0723
2
+
3
+ W0723 detects that an arithmetic operation of signed values may be overflow.
4
+
5
+ Scenario: an arithmetic operation in initializer of a global variable
6
+ Given a target source named "W0723.c" with:
7
+ """
8
+ static int i = 5;
9
+ static unsigned int j = (unsigned int) &i + 1; /* OK */
10
+ """
11
+ When I successfully run `adlint W0723.c` on noarch
12
+ Then the output should not match with /2:.*:W0723/
13
+ And the output should exactly match with:
14
+ | mesg | line | column |
15
+ | W0567 | 2 | 25 |
16
+ | W0167 | 2 | 45 |
17
+
18
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,328 @@
1
+ Feature: W1031
2
+
3
+ W1031 detects that two or more object declarations have inconsistent
4
+ storage-class-specifiers.
5
+
6
+ Scenario: function declaration with `static' and function definition without
7
+ storage-class-specifier.
8
+ Given a target source named "W1031.c" with:
9
+ """
10
+ static int foo(long);
11
+
12
+ int foo(long l) { /* OK */
13
+ return (int) l;
14
+ }
15
+ """
16
+ When I successfully run `adlint W1031.c` on noarch
17
+ Then the output should not match with /3:.*:W1031/
18
+ And the output should exactly match with:
19
+ | mesg | line | column |
20
+ | W0104 | 3 | 14 |
21
+ | W0629 | 3 | 5 |
22
+ | W0628 | 3 | 5 |
23
+
24
+ Scenario: function declaration with `extern' and function definition without
25
+ storage-class-specifier.
26
+ Given a target source named "W1031.c" with:
27
+ """
28
+ extern int foo(long);
29
+
30
+ int foo(long l) { /* OK */
31
+ return (int) l;
32
+ }
33
+ """
34
+ When I successfully run `adlint W1031.c` on noarch
35
+ Then the output should not match with /3:.*:W1031/
36
+ And the output should exactly match with:
37
+ | mesg | line | column |
38
+ | W0118 | 1 | 12 |
39
+ | W0104 | 3 | 14 |
40
+ | W0628 | 3 | 5 |
41
+
42
+ Scenario: function declaration without storage-class-specifier and function
43
+ definition without storage-class-specifier.
44
+ Given a target source named "W1031.c" with:
45
+ """
46
+ int foo(long);
47
+
48
+ int foo(long l) { /* OK */
49
+ return (int) l;
50
+ }
51
+ """
52
+ When I successfully run `adlint W1031.c` on noarch
53
+ Then the output should not match with /3:.*:W1031/
54
+ And the output should exactly match with:
55
+ | mesg | line | column |
56
+ | W0118 | 1 | 5 |
57
+ | W0104 | 3 | 14 |
58
+ | W0628 | 3 | 5 |
59
+
60
+ Scenario: function declaration without storage-class-specifier and function
61
+ definition with `static'.
62
+ Given a target source named "W1031.c" with:
63
+ """
64
+ int foo(long);
65
+
66
+ static int foo(long l) { /* W1031 */
67
+ return (int) l;
68
+ }
69
+ """
70
+ When I successfully run `adlint W1031.c` on noarch
71
+ Then the output should exactly match with:
72
+ | mesg | line | column |
73
+ | W0118 | 1 | 5 |
74
+ | W1031 | 3 | 12 |
75
+ | W0104 | 3 | 21 |
76
+ | W0628 | 3 | 12 |
77
+
78
+ Scenario: function declaration without storage-class-specifier and function
79
+ definition with `extern'.
80
+ Given a target source named "W1031.c" with:
81
+ """
82
+ int foo(long);
83
+
84
+ extern int foo(long l) { /* OK */
85
+ return (int) l;
86
+ }
87
+ """
88
+ When I successfully run `adlint W1031.c` on noarch
89
+ Then the output should not match with /3:.*:W1031/
90
+ And the output should exactly match with:
91
+ | mesg | line | column |
92
+ | W0118 | 1 | 5 |
93
+ | W0104 | 3 | 21 |
94
+ | W0628 | 3 | 12 |
95
+
96
+ Scenario: function declaration with `static' and function definition with
97
+ `extern'.
98
+ Given a target source named "W1031.c" with:
99
+ """
100
+ static int foo(long);
101
+
102
+ extern int foo(long l) { /* W1031 */
103
+ return (int) l;
104
+ }
105
+ """
106
+ When I successfully run `adlint W1031.c` on noarch
107
+ Then the output should match with /3:.*:W1031/
108
+ And the output should exactly match with:
109
+ | mesg | line | column |
110
+ | W1031 | 3 | 12 |
111
+ | W0104 | 3 | 21 |
112
+ | W0629 | 3 | 12 |
113
+ | W0628 | 3 | 12 |
114
+
115
+ Scenario: function declaration with `extern' and function definition with
116
+ `static'.
117
+ Given a target source named "W1031.c" with:
118
+ """
119
+ extern int foo(long);
120
+
121
+ static int foo(long l) { /* W1031 */
122
+ return (int) l;
123
+ }
124
+ """
125
+ When I successfully run `adlint W1031.c` on noarch
126
+ Then the output should match with /3:.*:W1031/
127
+ And the output should exactly match with:
128
+ | mesg | line | column |
129
+ | W0118 | 1 | 12 |
130
+ | W1031 | 3 | 12 |
131
+ | W0104 | 3 | 21 |
132
+ | W0628 | 3 | 12 |
133
+
134
+ Scenario: variable declaration with `extern' and variable definition without
135
+ storage-class-specifier.
136
+ Given a target source named "W1031.c" with:
137
+ """
138
+ extern int i;
139
+ int i = 0; /* OK */
140
+ """
141
+ When I successfully run `adlint W1031.c` on noarch
142
+ Then the output should not match with /2:.*:W1031/
143
+ And the output should exactly match with:
144
+ | mesg | line | column |
145
+ | W0118 | 1 | 12 |
146
+
147
+ Scenario: variable definition without storage-class-specifier and variable
148
+ declaration with `extern'.
149
+ Given a target source named "W1031.c" with:
150
+ """
151
+ int i;
152
+ extern int i; /* OK */
153
+ """
154
+ When I successfully run `adlint W1031.c` on noarch
155
+ Then the output should not match with /2:.*:W1031/
156
+ And the output should exactly match with:
157
+ | mesg | line | column |
158
+ | W0117 | 1 | 5 |
159
+ | W0118 | 2 | 12 |
160
+
161
+ Scenario: function declaration with `static' and function definition with
162
+ `extern'.
163
+ Given a target source named "W1031.c" with:
164
+ """
165
+ static int i;
166
+ extern int i = 0; /* W1031 */
167
+ """
168
+ When I successfully run `adlint W1031.c` on noarch
169
+ Then the output should match with /2:.*:W1031/
170
+ And the output should exactly match with:
171
+ | mesg | line | column |
172
+ | W1031 | 2 | 12 |
173
+
174
+ Scenario: variable declaration with `extern' and variable definition with
175
+ `static'.
176
+ Given a target source named "W1031.c" with:
177
+ """
178
+ extern int i;
179
+ static int i = 0; /* W1031 */
180
+ """
181
+ When I successfully run `adlint W1031.c` on noarch
182
+ Then the output should match with /2:.*:W1031/
183
+ And the output should exactly match with:
184
+ | mesg | line | column |
185
+ | W0118 | 1 | 12 |
186
+ | W1031 | 2 | 12 |
187
+
188
+ Scenario: function definition with `static' and function declaration without
189
+ storage-class-specifier.
190
+ Given a target source named "W1031.c" with:
191
+ """
192
+ static int foo(long l) {
193
+ return (int) l;
194
+ }
195
+
196
+ int foo(long); /* OK */
197
+ """
198
+ When I successfully run `adlint W1031.c` on noarch
199
+ Then the output should not match with /5:.*:W1031/
200
+ And the output should exactly match with:
201
+ | mesg | line | column |
202
+ | W0104 | 1 | 21 |
203
+ | W0629 | 1 | 12 |
204
+ | W0543 | 1 | 12 |
205
+ | W0628 | 1 | 12 |
206
+
207
+ Scenario: function definition with `extern' and function declaration without
208
+ storage-class-specifier.
209
+ Given a target source named "W1031.c" with:
210
+ """
211
+ extern int foo(long l) {
212
+ return (int) l;
213
+ }
214
+
215
+ int foo(long); /* OK */
216
+ """
217
+ When I successfully run `adlint W1031.c` on noarch
218
+ Then the output should not match with /5:.*:W1031/
219
+ And the output should exactly match with:
220
+ | mesg | line | column |
221
+ | W0117 | 1 | 12 |
222
+ | W0104 | 1 | 21 |
223
+ | W0118 | 5 | 5 |
224
+ | W0543 | 1 | 12 |
225
+ | W0628 | 1 | 12 |
226
+
227
+ Scenario: function definition without storage-class-specifier and function
228
+ declaration without storage-class-specifier.
229
+ Given a target source named "W1031.c" with:
230
+ """
231
+ int foo(long l) {
232
+ return (int) l;
233
+ }
234
+
235
+ int foo(long); /* OK */
236
+ """
237
+ When I successfully run `adlint W1031.c` on noarch
238
+ Then the output should not match with /5:.*:W1031/
239
+ And the output should exactly match with:
240
+ | mesg | line | column |
241
+ | W0117 | 1 | 5 |
242
+ | W0104 | 1 | 14 |
243
+ | W0118 | 5 | 5 |
244
+ | W0543 | 1 | 5 |
245
+ | W0628 | 1 | 5 |
246
+
247
+ Scenario: function definition without storage-class-specifier and function
248
+ declaration with `static'.
249
+ Given a target source named "W1031.c" with:
250
+ """
251
+ int foo(long l) {
252
+ return (int) l;
253
+ }
254
+
255
+ static int foo(long); /* W1031 */
256
+ """
257
+ When I successfully run `adlint W1031.c` on noarch
258
+ Then the output should match with /5:.*:W1031/
259
+ And the output should exactly match with:
260
+ | mesg | line | column |
261
+ | W0117 | 1 | 5 |
262
+ | W0104 | 1 | 14 |
263
+ | W0118 | 5 | 12 |
264
+ | W1031 | 5 | 12 |
265
+ | W0543 | 1 | 5 |
266
+ | W0628 | 1 | 5 |
267
+
268
+ Scenario: function definition without storage-class-specifier and function
269
+ declaration with `extern'.
270
+ Given a target source named "W1031.c" with:
271
+ """
272
+ int foo(long l) {
273
+ return (int) l;
274
+ }
275
+
276
+ extern int foo(long); /* OK */
277
+ """
278
+ When I successfully run `adlint W1031.c` on noarch
279
+ Then the output should not match with /5:.*:W1031/
280
+ And the output should exactly match with:
281
+ | mesg | line | column |
282
+ | W0117 | 1 | 5 |
283
+ | W0104 | 1 | 14 |
284
+ | W0118 | 5 | 12 |
285
+ | W0543 | 1 | 5 |
286
+ | W0628 | 1 | 5 |
287
+
288
+ Scenario: function definition with `static' and function declaration with
289
+ `extern'.
290
+ Given a target source named "W1031.c" with:
291
+ """
292
+ static int foo(long l) {
293
+ return (int) l;
294
+ }
295
+
296
+ extern int foo(long l); /* W1031 */
297
+ """
298
+ When I successfully run `adlint W1031.c` on noarch
299
+ Then the output should match with /5:.*:W1031/
300
+ And the output should exactly match with:
301
+ | mesg | line | column |
302
+ | W0104 | 1 | 21 |
303
+ | W1031 | 5 | 12 |
304
+ | W0629 | 1 | 12 |
305
+ | W0628 | 1 | 12 |
306
+
307
+ Scenario: function definition with `extern' and function declaration with
308
+ `static'.
309
+ Given a target source named "W1031.c" with:
310
+ """
311
+ extern int foo(long l) {
312
+ return (int) l;
313
+ }
314
+
315
+ static int foo(long); /* W1031 */
316
+ """
317
+ When I successfully run `adlint W1031.c` on noarch
318
+ Then the output should match with /5:.*:W1031/
319
+ And the output should exactly match with:
320
+ | mesg | line | column |
321
+ | W0117 | 1 | 12 |
322
+ | W0104 | 1 | 21 |
323
+ | W0118 | 5 | 12 |
324
+ | W1031 | 5 | 12 |
325
+ | W0543 | 1 | 12 |
326
+ | W0628 | 1 | 12 |
327
+
328
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,45 @@
1
+ Given /^a target source named "(.*)" with:$/ do |src_name, content|
2
+ write_file(src_name, content + "\n")
3
+ end
4
+
5
+ Given /^expected messages of "(.*)" are:$/ do |src_name, mesg_table|
6
+ write_file("#{src_name}.expected", mesg_table.hashes.map { |row|
7
+ "#{row[:mesg]} #{row[:line]} #{row[:column]}" }.join("\n"))
8
+ end
9
+
10
+ When /^I successfully run `(.*)` on noarch$/ do |abbrev_cmd|
11
+ write_file("noarch_traits.yml", NOARCH_TRAITS)
12
+ write_file("empty_pinit.h", "\n")
13
+ write_file("empty_cinit.h", "\n")
14
+ run_simple(unescape(abbrev_cmd + " -t noarch_traits.yml"))
15
+ end
16
+
17
+ Then /^the output should match with \/(.*)\/$/ do |pattern|
18
+ all_output.should =~ /#{pattern}/
19
+ end
20
+
21
+ Then /^the output should not match with \/(.*)\/$/ do |pattern|
22
+ all_output.should_not =~ /#{pattern}/
23
+ end
24
+
25
+ Then /^the output should match with expected messages of "(.*)"$/ do |src_name|
26
+ prep_for_fs_check do
27
+ expected = File.read("#{src_name}.expected").each_line.map { |line|
28
+ fields = line.chomp.split(" ")
29
+ /#{fields[1]}:#{fields[2]}:.*:#{fields[0]}/
30
+ }
31
+ all_output.each_line.zip(expected).each do |line, pattern|
32
+ line.should =~ pattern
33
+ end
34
+ end
35
+ end
36
+
37
+ Then /^the output should exactly match with:$/ do |mesg_table|
38
+ all_output.each_line.zip(mesg_table.hashes).each do |line, row|
39
+ if row
40
+ line.should =~ /#{row[:line]}:#{row[:column]}:.*:#{row[:mesg]}/
41
+ else
42
+ line.should =~ /::.*:/
43
+ end
44
+ end
45
+ end