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.
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
@@ -0,0 +1,65 @@
1
+ Feature: W0830
2
+
3
+ W0830 detects that an extra comma appears after enumerator-list.
4
+
5
+ Scenario: an extra comma after enumerator-list in the named enum-specifier
6
+ Given a target source named "W0830.c" with:
7
+ """
8
+ enum Color { Red, Green, Blue, }; /* W0830 */
9
+ """
10
+ When I successfully run `adlint W0830.c` on noarch
11
+ Then the output should exactly match with:
12
+ | mesg | line | column |
13
+ | W0830 | 1 | 30 |
14
+
15
+ Scenario: an extra comma after enumerator-list in the unnamed enum-specifier
16
+ Given a target source named "W0830.c" with:
17
+ """
18
+ enum { Red, Green, Blue, }; /* W0830 */
19
+ """
20
+ When I successfully run `adlint W0830.c` on noarch
21
+ Then the output should exactly match with:
22
+ | mesg | line | column |
23
+ | W0830 | 1 | 24 |
24
+
25
+ Scenario: no extra comma after enumerator-list in the named enum-specifier
26
+ Given a target source named "W0830.c" with:
27
+ """
28
+ enum Color { Red, Green, Blue }; /* OK */
29
+ """
30
+ When I successfully run `adlint W0830.c` on noarch
31
+ Then the output should exactly match with:
32
+ | mesg | line | column |
33
+
34
+ Scenario: no extra comma after enumerator-list in the unnamed enum-specifier
35
+ Given a target source named "W0830.c" with:
36
+ """
37
+ enum { Red, Green, Blue }; /* OK */
38
+ """
39
+ When I successfully run `adlint W0830.c` on noarch
40
+ Then the output should exactly match with:
41
+ | mesg | line | column |
42
+
43
+ Scenario: an extra comma after initialized enumerator-list in the named
44
+ enum-specifier
45
+ Given a target source named "W0830.c" with:
46
+ """
47
+ enum Color { Red = 1, Green = 2, Blue = 3, }; /* W0830 */
48
+ """
49
+ When I successfully run `adlint W0830.c` on noarch
50
+ Then the output should exactly match with:
51
+ | mesg | line | column |
52
+ | W0830 | 1 | 42 |
53
+
54
+ Scenario: an extra comma after initialized enumerator-list in the unnamed
55
+ enum-specifier
56
+ Given a target source named "W0830.c" with:
57
+ """
58
+ enum { Red = 1, Green = 2, Blue = 3, }; /* W0830 */
59
+ """
60
+ When I successfully run `adlint W0830.c` on noarch
61
+ Then the output should exactly match with:
62
+ | mesg | line | column |
63
+ | W0830 | 1 | 36 |
64
+
65
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,220 @@
1
+ Feature: W0833
2
+
3
+ W0833 detects that an integer-constant has a long-long-suffix `LL'.
4
+
5
+ Scenario: LL-ed decimal-constant in initializer
6
+ Given a target source named "W0833.c" with:
7
+ """
8
+ long long ll = 123LL; /* W0833 */
9
+ """
10
+ When I successfully run `adlint W0833.c` on noarch
11
+ Then the output should exactly match with:
12
+ | mesg | line | column |
13
+ | W0833 | 1 | 16 |
14
+ | W0117 | 1 | 11 |
15
+ | W0834 | 1 | 1 |
16
+
17
+ Scenario: LL-ed octal-constant in initializer
18
+ Given a target source named "W0833.c" with:
19
+ """
20
+ long long ll = 0123LL; /* W0833 */
21
+ """
22
+ When I successfully run `adlint W0833.c` on noarch
23
+ Then the output should exactly match with:
24
+ | mesg | line | column |
25
+ | W0833 | 1 | 16 |
26
+ | W0117 | 1 | 11 |
27
+ | W0529 | 1 | 16 |
28
+ | W0834 | 1 | 1 |
29
+
30
+ Scenario: LL-ed hexadecimal-constant in initializer
31
+ Given a target source named "W0833.c" with:
32
+ """
33
+ long long ll = 0x123LL; /* W0833 */
34
+ """
35
+ When I successfully run `adlint W0833.c` on noarch
36
+ Then the output should exactly match with:
37
+ | mesg | line | column |
38
+ | W0833 | 1 | 16 |
39
+ | W0117 | 1 | 11 |
40
+ | W0834 | 1 | 1 |
41
+
42
+ Scenario: ULL-ed decimal-constant in initializer
43
+ Given a target source named "W0833.c" with:
44
+ """
45
+ unsigned long long ull = 123ULL; /* W0833 */
46
+ """
47
+ When I successfully run `adlint W0833.c` on noarch
48
+ Then the output should exactly match with:
49
+ | mesg | line | column |
50
+ | W0833 | 1 | 26 |
51
+ | W0117 | 1 | 20 |
52
+ | W0834 | 1 | 1 |
53
+
54
+ Scenario: ULL-ed octal-constant in initializer
55
+ Given a target source named "W0833.c" with:
56
+ """
57
+ unsigned long long ull = 0123LLU; /* W0833 */
58
+ """
59
+ When I successfully run `adlint W0833.c` on noarch
60
+ Then the output should exactly match with:
61
+ | mesg | line | column |
62
+ | W0833 | 1 | 26 |
63
+ | W0117 | 1 | 20 |
64
+ | W0529 | 1 | 26 |
65
+ | W0834 | 1 | 1 |
66
+
67
+ Scenario: ULL-ed hexadecimal-constant in initializer
68
+ Given a target source named "W0833.c" with:
69
+ """
70
+ unsigned long long ull = 0x123LLU; /* W0833 */
71
+ """
72
+ When I successfully run `adlint W0833.c` on noarch
73
+ Then the output should exactly match with:
74
+ | mesg | line | column |
75
+ | W0833 | 1 | 26 |
76
+ | W0117 | 1 | 20 |
77
+ | W0834 | 1 | 1 |
78
+
79
+ Scenario: LL-ed decimal-constant in assignment-expression
80
+ Given a target source named "W0833.c" with:
81
+ """
82
+ void foo(void)
83
+ {
84
+ long long ll;
85
+ ll = 123LL; /* W0833 */
86
+ }
87
+ """
88
+ When I successfully run `adlint W0833.c` on noarch
89
+ Then the output should exactly match with:
90
+ | mesg | line | column |
91
+ | W0117 | 1 | 6 |
92
+ | W0833 | 4 | 10 |
93
+ | W0100 | 3 | 15 |
94
+ | W0834 | 3 | 5 |
95
+ | W0628 | 1 | 6 |
96
+
97
+ Scenario: LL-ed octal-constant in assignment-expression
98
+ Given a target source named "W0833.c" with:
99
+ """
100
+ void foo(void)
101
+ {
102
+ long long ll;
103
+ ll = 0123LL; /* W0833 */
104
+ }
105
+ """
106
+ When I successfully run `adlint W0833.c` on noarch
107
+ Then the output should exactly match with:
108
+ | mesg | line | column |
109
+ | W0117 | 1 | 6 |
110
+ | W0833 | 4 | 10 |
111
+ | W0100 | 3 | 15 |
112
+ | W0834 | 3 | 5 |
113
+ | W0529 | 4 | 10 |
114
+ | W0628 | 1 | 6 |
115
+
116
+ Scenario: LL-ed hexadecimal-constant in assignment-expression
117
+ Given a target source named "W0833.c" with:
118
+ """
119
+ void foo(void)
120
+ {
121
+ long long ll;
122
+ ll = 0x123LL; /* W0833 */
123
+ }
124
+ """
125
+ When I successfully run `adlint W0833.c` on noarch
126
+ Then the output should exactly match with:
127
+ | mesg | line | column |
128
+ | W0117 | 1 | 6 |
129
+ | W0833 | 4 | 10 |
130
+ | W0100 | 3 | 15 |
131
+ | W0834 | 3 | 5 |
132
+ | W0628 | 1 | 6 |
133
+
134
+ Scenario: ULL-ed decimal-constant in assignment-expression
135
+ Given a target source named "W0833.c" with:
136
+ """
137
+ void foo(void)
138
+ {
139
+ unsigned long long ull;
140
+ ull = 123LLU; /* W0833 */
141
+ }
142
+ """
143
+ When I successfully run `adlint W0833.c` on noarch
144
+ Then the output should exactly match with:
145
+ | mesg | line | column |
146
+ | W0117 | 1 | 6 |
147
+ | W0833 | 4 | 11 |
148
+ | W0100 | 3 | 24 |
149
+ | W0834 | 3 | 5 |
150
+ | W0628 | 1 | 6 |
151
+
152
+ Scenario: ULL-ed octal-constant in assignment-expression
153
+ Given a target source named "W0833.c" with:
154
+ """
155
+ void foo(void)
156
+ {
157
+ unsigned long long ull;
158
+ ull = 0123ULL; /* W0833 */
159
+ }
160
+ """
161
+ When I successfully run `adlint W0833.c` on noarch
162
+ Then the output should exactly match with:
163
+ | mesg | line | column |
164
+ | W0117 | 1 | 6 |
165
+ | W0833 | 4 | 11 |
166
+ | W0100 | 3 | 24 |
167
+ | W0834 | 3 | 5 |
168
+ | W0529 | 4 | 11 |
169
+ | W0628 | 1 | 6 |
170
+
171
+ Scenario: ULL-ed hexadecimal-constant in assignment-expression
172
+ Given a target source named "W0833.c" with:
173
+ """
174
+ void foo(void)
175
+ {
176
+ unsigned long long ull;
177
+ ull = 0x123LLU; /* W0833 */
178
+ }
179
+ """
180
+ When I successfully run `adlint W0833.c` on noarch
181
+ Then the output should exactly match with:
182
+ | mesg | line | column |
183
+ | W0117 | 1 | 6 |
184
+ | W0833 | 4 | 11 |
185
+ | W0100 | 3 | 24 |
186
+ | W0834 | 3 | 5 |
187
+ | W0628 | 1 | 6 |
188
+
189
+ Scenario: L-ed decimal-constant in initializer
190
+ Given a target source named "W0833.c" with:
191
+ """
192
+ long l = 123L; /* OK */
193
+ """
194
+ When I successfully run `adlint W0833.c` on noarch
195
+ Then the output should exactly match with:
196
+ | mesg | line | column |
197
+ | W0117 | 1 | 6 |
198
+
199
+ Scenario: LL-ed octal-constant in initializer
200
+ Given a target source named "W0833.c" with:
201
+ """
202
+ long l = 0123L; /* OK */
203
+ """
204
+ When I successfully run `adlint W0833.c` on noarch
205
+ Then the output should exactly match with:
206
+ | mesg | line | column |
207
+ | W0117 | 1 | 6 |
208
+ | W0529 | 1 | 10 |
209
+
210
+ Scenario: LL-ed hexadecimal-constant in initializer
211
+ Given a target source named "W0833.c" with:
212
+ """
213
+ long l = 0x123L; /* OK */
214
+ """
215
+ When I successfully run `adlint W0833.c` on noarch
216
+ Then the output should exactly match with:
217
+ | mesg | line | column |
218
+ | W0117 | 1 | 6 |
219
+
220
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,189 @@
1
+ Feature: W0834
2
+
3
+ W0834 detects that a `long long' type of the ISO C99 standard is used.
4
+
5
+ Scenario: `long long' global variable declaration
6
+ Given a target source named "W0834.c" with:
7
+ """
8
+ extern long long ll; /* W0834 */
9
+ """
10
+ When I successfully run `adlint W0834.c` on noarch
11
+ Then the output should exactly match with:
12
+ | mesg | line | column |
13
+ | W0118 | 1 | 18 |
14
+ | W0834 | 1 | 8 |
15
+
16
+ Scenario: `long long' global variable definition
17
+ Given a target source named "W0834.c" with:
18
+ """
19
+ static long long ll; /* W0834 */
20
+ """
21
+ When I successfully run `adlint W0834.c` on noarch
22
+ Then the output should exactly match with:
23
+ | mesg | line | column |
24
+ | W0834 | 1 | 8 |
25
+
26
+ Scenario: `long long' parameter in function declaration
27
+ Given a target source named "W0834.c" with:
28
+ """
29
+ extern void foo(long long ll); /* W0834 */
30
+ """
31
+ When I successfully run `adlint W0834.c` on noarch
32
+ Then the output should exactly match with:
33
+ | mesg | line | column |
34
+ | W0118 | 1 | 13 |
35
+ | W0834 | 1 | 17 |
36
+
37
+ Scenario: `long long' parameter in function definition
38
+ Given a target source named "W0834.c" with:
39
+ """
40
+ static void foo(long long ll) /* W0834 */
41
+ {
42
+ }
43
+ """
44
+ When I successfully run `adlint W0834.c` on noarch
45
+ Then the output should exactly match with:
46
+ | mesg | line | column |
47
+ | W1076 | 1 | 13 |
48
+ | W0031 | 1 | 27 |
49
+ | W0104 | 1 | 27 |
50
+ | W0629 | 1 | 13 |
51
+ | W0834 | 1 | 17 |
52
+ | W0628 | 1 | 13 |
53
+
54
+ Scenario: `long long' function local variable definition
55
+ Given a target source named "W0834.c" with:
56
+ """
57
+ static void foo(void)
58
+ {
59
+ long long ll = 0; /* W0834 */
60
+ }
61
+ """
62
+ When I successfully run `adlint W0834.c` on noarch
63
+ Then the output should exactly match with:
64
+ | mesg | line | column |
65
+ | W1076 | 1 | 13 |
66
+ | W0100 | 3 | 15 |
67
+ | W0629 | 1 | 13 |
68
+ | W0834 | 3 | 5 |
69
+ | W0628 | 1 | 13 |
70
+
71
+ Scenario: `long long' as return type in function declaration
72
+ Given a target source named "W0834.c" with:
73
+ """
74
+ extern long long foo(void); /* W0834 */
75
+ """
76
+ When I successfully run `adlint W0834.c` on noarch
77
+ Then the output should exactly match with:
78
+ | mesg | line | column |
79
+ | W0118 | 1 | 18 |
80
+ | W0834 | 1 | 8 |
81
+
82
+ Scenario: `long long' as return type in function definition
83
+ Given a target source named "W0834.c" with:
84
+ """
85
+ static long long foo(void) /* W0834 */
86
+ {
87
+ return 0LL;
88
+ }
89
+ """
90
+ When I successfully run `adlint W0834.c` on noarch
91
+ Then the output should exactly match with:
92
+ | mesg | line | column |
93
+ | W1076 | 1 | 18 |
94
+ | W0833 | 3 | 12 |
95
+ | W0629 | 1 | 18 |
96
+ | W0834 | 1 | 8 |
97
+ | W0628 | 1 | 18 |
98
+
99
+ Scenario: `long long' in cast-expression
100
+ Given a target source named "W0834.c" with:
101
+ """
102
+ static long long foo(void) /* W0834 */
103
+ {
104
+ return (long long) 0; /* W0834 */
105
+ }
106
+ """
107
+ When I successfully run `adlint W0834.c` on noarch
108
+ Then the output should exactly match with:
109
+ | mesg | line | column |
110
+ | W1076 | 1 | 18 |
111
+ | W0629 | 1 | 18 |
112
+ | W0834 | 1 | 8 |
113
+ | W0834 | 3 | 13 |
114
+ | W0628 | 1 | 18 |
115
+
116
+ Scenario: `long long' in sizeof-expression
117
+ Given a target source named "W0834.c" with:
118
+ """
119
+ static int foo(void)
120
+ {
121
+ return sizeof(long long); /* W0834 */
122
+ }
123
+ """
124
+ When I successfully run `adlint W0834.c` on noarch
125
+ Then the output should exactly match with:
126
+ | mesg | line | column |
127
+ | W1076 | 1 | 12 |
128
+ | W0629 | 1 | 12 |
129
+ | W0834 | 3 | 19 |
130
+ | W0628 | 1 | 12 |
131
+
132
+ Scenario: multiple `long long' parameters in function declaration
133
+ Given a target source named "W0834.c" with:
134
+ """
135
+ extern void foo(long long a, int b, long long b); /* W0834 */
136
+ """
137
+ When I successfully run `adlint W0834.c` on noarch
138
+ Then the output should exactly match with:
139
+ | mesg | line | column |
140
+ | W0118 | 1 | 13 |
141
+ | W0834 | 1 | 17 |
142
+ | W0834 | 1 | 37 |
143
+
144
+ Scenario: nested function-declarators with `long long'
145
+ Given a target source named "W0834.c" with:
146
+ """
147
+ extern void (*p)(long long, int (*)(long long), unsigned long long); /* W0834 */
148
+ """
149
+ When I successfully run `adlint W0834.c` on noarch
150
+ Then the output should exactly match with:
151
+ | mesg | line | column |
152
+ | W0118 | 1 | 15 |
153
+ | W0834 | 1 | 18 |
154
+ | W0834 | 1 | 37 |
155
+ | W0834 | 1 | 49 |
156
+
157
+ Scenario: `long long' member in struct and union type.
158
+ Given a target source named "W0834.c" with:
159
+ """
160
+ struct Foo {
161
+ int i;
162
+ long long ll; /* W0834 */
163
+ union {
164
+ int i;
165
+ long long ll; /* W0834 */
166
+ } u;
167
+ } foo;
168
+ """
169
+ When I successfully run `adlint W0834.c` on noarch
170
+ Then the output should exactly match with:
171
+ | mesg | line | column |
172
+ | W0117 | 8 | 3 |
173
+ | W0834 | 3 | 5 |
174
+ | W0834 | 6 | 9 |
175
+ | W0551 | 4 | 5 |
176
+
177
+ Scenario: nested function-declarators with `long long' in typedef declaration
178
+ Given a target source named "W0834.c" with:
179
+ """
180
+ typedef void (*p)(long long, int (*)(long long), signed long long); /* W0834 */
181
+ """
182
+ When I successfully run `adlint W0834.c` on noarch
183
+ Then the output should exactly match with:
184
+ | mesg | line | column |
185
+ | W0834 | 1 | 19 |
186
+ | W0834 | 1 | 38 |
187
+ | W0834 | 1 | 50 |
188
+
189
+ # vim:ts=2:sw=2:sts=2:et: