adlint 1.14.0 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/ChangeLog +265 -0
  2. data/MANIFEST +15 -0
  3. data/NEWS +30 -4
  4. data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
  5. data/etc/mesg.d/en_US/messages.yml +3 -3
  6. data/etc/mesg.d/ja_JP/messages.yml +3 -3
  7. data/features/message_detection/W0001.feature +2 -0
  8. data/features/message_detection/W0007.feature +8 -0
  9. data/features/message_detection/W0010.feature +4 -1
  10. data/features/message_detection/W0013.feature +8 -0
  11. data/features/message_detection/W0093.feature +3 -0
  12. data/features/message_detection/W0104.feature +7 -0
  13. data/features/message_detection/W0643.feature +80 -0
  14. data/features/message_detection/W0646.feature +115 -0
  15. data/features/message_detection/W0691.feature +100 -0
  16. data/features/message_detection/W0692.feature +32 -0
  17. data/features/message_detection/W0694.feature +128 -0
  18. data/features/message_detection/W0716.feature +3 -0
  19. data/features/message_detection/W0717.feature +3 -0
  20. data/features/message_detection/W0718.feature +3 -0
  21. data/features/message_detection/W0723.feature +2 -0
  22. data/features/message_detection/W0732.feature +3 -0
  23. data/features/message_detection/W0733.feature +3 -0
  24. data/features/message_detection/W0734.feature +8 -0
  25. data/features/message_detection/W0735.feature +8 -0
  26. data/features/message_detection/W0805.feature +92 -0
  27. data/features/message_detection/W0811.feature +79 -0
  28. data/features/message_detection/W1031.feature +7 -0
  29. data/features/message_detection/W1040.feature +89 -0
  30. data/features/message_detection/W1041.feature +15 -0
  31. data/features/message_detection/W1046.feature +60 -0
  32. data/features/message_detection/W1052.feature +3 -0
  33. data/features/message_detection/W1066.feature +3 -0
  34. data/features/message_detection/W1067.feature +3 -0
  35. data/features/message_detection/W1068.feature +3 -0
  36. data/features/message_detection/W1069.feature +5 -0
  37. data/features/message_detection/W1070.feature +6 -0
  38. data/features/message_detection/W1072.feature +1 -0
  39. data/features/message_detection/W1073.feature +145 -0
  40. data/features/message_detection/W1074.feature +139 -0
  41. data/features/message_detection/W1075.feature +86 -0
  42. data/features/message_detection/W1076.feature +66 -0
  43. data/features/message_detection/W1077.feature +105 -0
  44. data/features/message_detection/W9003.feature +4 -0
  45. data/lib/adlint/c/ctrlexpr.rb +3 -0
  46. data/lib/adlint/c/interp.rb +11 -5
  47. data/lib/adlint/c/lexer.rb +14 -3
  48. data/lib/adlint/c/message.rb +192 -0
  49. data/lib/adlint/c/parser.rb +19 -3
  50. data/lib/adlint/c/parser.y +18 -2
  51. data/lib/adlint/c/phase.rb +19 -6
  52. data/lib/adlint/c/syntax.rb +6 -0
  53. data/lib/adlint/c/type.rb +5 -1
  54. data/lib/adlint/cpp/constexpr.rb +3 -3
  55. data/lib/adlint/cpp/constexpr.y +3 -3
  56. data/lib/adlint/cpp/eval.rb +60 -86
  57. data/lib/adlint/cpp/lexer.rb +82 -28
  58. data/lib/adlint/cpp/macro.rb +64 -35
  59. data/lib/adlint/cpp/message.rb +137 -4
  60. data/lib/adlint/cpp/phase.rb +8 -0
  61. data/lib/adlint/cpp/syntax.rb +25 -0
  62. data/lib/adlint/lang.rb +2 -1
  63. data/lib/adlint/version.rb +2 -2
  64. data/share/doc/developers_guide_ja.html +3 -3
  65. data/share/doc/developers_guide_ja.texi +1 -1
  66. data/share/doc/users_guide_en.html +102 -85
  67. data/share/doc/users_guide_en.texi +85 -69
  68. data/share/doc/users_guide_ja.html +102 -94
  69. data/share/doc/users_guide_ja.texi +85 -77
  70. metadata +17 -2
@@ -0,0 +1,79 @@
1
+ Feature: W0811
2
+
3
+ W0811 detects that token sequence replaced by macro contains `defined'
4
+ operator.
5
+
6
+ Scenario: no macro replacement
7
+ Given a target source named "W0805.c" with:
8
+ """
9
+ #if defined(FOO) /* OK */
10
+ int i = 0;
11
+ #endif
12
+ """
13
+ When I successfully run `adlint W0805.c` on noarch
14
+ Then the output should exactly match with:
15
+ | mesg | line | column |
16
+
17
+ Scenario: expanding a wellformed `defined' operator
18
+ Given a target source named "W0805.c" with:
19
+ """
20
+ #define COND defined(FOO)
21
+
22
+ #if COND /* W0811 */
23
+ int i = 0;
24
+ #endif
25
+ """
26
+ When I successfully run `adlint W0805.c` on noarch
27
+ Then the output should exactly match with:
28
+ | mesg | line | column |
29
+ | W0811 | 3 | 5 |
30
+
31
+ Scenario: expanding a wellformed expression contains `defined' operator from
32
+ object-like macro
33
+ Given a target source named "W0805.c" with:
34
+ """
35
+ #define COND defined(FOO) && !defined(BAR)
36
+
37
+ #if COND /* W0811 */
38
+ int i = 0;
39
+ #endif
40
+ """
41
+ When I successfully run `adlint W0805.c` on noarch
42
+ Then the output should exactly match with:
43
+ | mesg | line | column |
44
+ | W0811 | 3 | 5 |
45
+
46
+ Scenario: expanding a wellformed `defined' operator from function-like macro
47
+ Given a target source named "W0805.c" with:
48
+ """
49
+ #define COND(id) defined(id)
50
+
51
+ #if COND(FOO) /* W0811 */
52
+ int i = 0;
53
+ #endif
54
+ """
55
+ When I successfully run `adlint W0805.c` on noarch
56
+ Then the output should exactly match with:
57
+ | mesg | line | column |
58
+ | W0442 | 1 | 1 |
59
+ | W0811 | 3 | 5 |
60
+ | W0443 | 1 | 1 |
61
+
62
+ Scenario: expanding a wellformed expression contains `defined' operator from
63
+ function-like macro
64
+ Given a target source named "W0805.c" with:
65
+ """
66
+ #define COND(id1, id2) defined(id1) && !defined(id2)
67
+
68
+ #if COND(FOO, BAR) /* W0811 */
69
+ int i = 0;
70
+ #endif
71
+ """
72
+ When I successfully run `adlint W0805.c` on noarch
73
+ Then the output should exactly match with:
74
+ | mesg | line | column |
75
+ | W0442 | 1 | 1 |
76
+ | W0811 | 3 | 5 |
77
+ | W0443 | 1 | 1 |
78
+
79
+ # vim:ts=2:sw=2:sts=2:et:
@@ -17,6 +17,7 @@ Feature: W1031
17
17
  Then the output should not match with /3:.*:W1031/
18
18
  And the output should exactly match with:
19
19
  | mesg | line | column |
20
+ | W1075 | 3 | 5 |
20
21
  | W0104 | 3 | 14 |
21
22
  | W0629 | 3 | 5 |
22
23
  | W0628 | 3 | 5 |
@@ -108,6 +109,7 @@ Feature: W1031
108
109
  And the output should exactly match with:
109
110
  | mesg | line | column |
110
111
  | W1031 | 3 | 12 |
112
+ | W1075 | 3 | 12 |
111
113
  | W0104 | 3 | 21 |
112
114
  | W0629 | 3 | 12 |
113
115
  | W0628 | 3 | 12 |
@@ -170,6 +172,7 @@ Feature: W1031
170
172
  And the output should exactly match with:
171
173
  | mesg | line | column |
172
174
  | W1031 | 2 | 12 |
175
+ | W1075 | 2 | 12 |
173
176
 
174
177
  Scenario: variable declaration with `extern' and variable definition with
175
178
  `static'
@@ -199,7 +202,9 @@ Feature: W1031
199
202
  Then the output should not match with /5:.*:W1031/
200
203
  And the output should exactly match with:
201
204
  | mesg | line | column |
205
+ | W1076 | 1 | 12 |
202
206
  | W0104 | 1 | 21 |
207
+ | W1075 | 5 | 5 |
203
208
  | W0629 | 1 | 12 |
204
209
  | W0543 | 1 | 12 |
205
210
  | W0628 | 1 | 12 |
@@ -299,8 +304,10 @@ Feature: W1031
299
304
  Then the output should match with /5:.*:W1031/
300
305
  And the output should exactly match with:
301
306
  | mesg | line | column |
307
+ | W1076 | 1 | 12 |
302
308
  | W0104 | 1 | 21 |
303
309
  | W1031 | 5 | 12 |
310
+ | W1075 | 5 | 12 |
304
311
  | W0629 | 1 | 12 |
305
312
  | W0628 | 1 | 12 |
306
313
 
@@ -0,0 +1,89 @@
1
+ Feature: W1040
2
+
3
+ W1040 detects that extra tokens after the preprocessing directive.
4
+
5
+ Scenario: extra tokens after #endif directive
6
+ Given a target source named "W1040.c" with:
7
+ """
8
+ #define TEST
9
+
10
+ #ifdef TEST
11
+ #if defined(CASE_1)
12
+ int i = 1;
13
+ #elif defined(CASE_2)
14
+ int i = 2;
15
+ #endif CASE /* W1040 */
16
+ #else
17
+ int i = 0;
18
+ #endif TEST /* W1040 */
19
+ """
20
+ When I successfully run `adlint W1040.c` on noarch
21
+ Then the output should exactly match with:
22
+ | mesg | line | column |
23
+ | W1040 | 8 | 8 |
24
+ | W1040 | 11 | 8 |
25
+
26
+ Scenario: extra tokens after #endif directive in an invisible branch
27
+ Given a target source named "W1040.c" with:
28
+ """
29
+ #ifdef TEST
30
+ #if defined(CASE_1)
31
+ int i = 1;
32
+ #elif defined(CASE_2)
33
+ int i = 2;
34
+ #endif CASE /* OK */
35
+ #else
36
+ int i = 0;
37
+ #endif TEST /* W1040 */
38
+ """
39
+ When I successfully run `adlint W1040.c` on noarch
40
+ Then the output should exactly match with:
41
+ | mesg | line | column |
42
+ | W1040 | 9 | 8 |
43
+ | W0117 | 8 | 5 |
44
+
45
+ Scenario: extra tokens after #else directive
46
+ Given a target source named "W1040.c" with:
47
+ """
48
+ #define TEST
49
+
50
+ #ifdef TEST
51
+ #if defined(CASE_1)
52
+ int i = 1;
53
+ #elif defined(CASE_2)
54
+ int i = 2;
55
+ #else CASE_X /* W1040 */
56
+ int i = 9;
57
+ #endif
58
+ #else
59
+ int i = 0;
60
+ #endif TEST /* W1040 */
61
+ """
62
+ When I successfully run `adlint W1040.c` on noarch
63
+ Then the output should exactly match with:
64
+ | mesg | line | column |
65
+ | W1040 | 8 | 7 |
66
+ | W1040 | 13 | 8 |
67
+ | W0117 | 9 | 5 |
68
+
69
+ Scenario: extra tokens after #else directive in an invisible branch
70
+ Given a target source named "W1040.c" with:
71
+ """
72
+ #ifdef TEST
73
+ #if defined(CASE_1)
74
+ int i = 1;
75
+ #elif defined(CASE_2)
76
+ int i = 2;
77
+ #else CASE_X /* OK */
78
+ int i = 9;
79
+ #endif
80
+ #else
81
+ int i = 0;
82
+ #endif
83
+ """
84
+ When I successfully run `adlint W1040.c` on noarch
85
+ Then the output should exactly match with:
86
+ | mesg | line | column |
87
+ | W0117 | 10 | 5 |
88
+
89
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,15 @@
1
+ Feature: W1041
2
+
3
+ W1041 detects that a non-standard preprocessing directive is found.
4
+
5
+ Scenario: a compiler-specific preprocessing directive
6
+ Given a target source named "W1041.c" with:
7
+ """
8
+ #compiler_specific_extension 1 2.3 "4" /* W1041 */
9
+ """
10
+ When I successfully run `adlint W1041.c` on noarch
11
+ Then the output should exactly match with:
12
+ | mesg | line | column |
13
+ | W1041 | 1 | 1 |
14
+
15
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,60 @@
1
+ Feature: W1046
2
+
3
+ W1046 detects that a space or tab character is found after newline escaping
4
+ `\' character.
5
+
6
+ Scenario: illformed newline escape in #define directive
7
+ Given a target source named "W1046.c" with:
8
+ """
9
+ #define FOO(a, b) /* OK */ \
10
+ ( /* W1046 */ \
11
+ (a) + (b) /* W1046 */ \
12
+ )
13
+ """
14
+ When I successfully run `adlint W1046.c` on noarch
15
+ Then the output should exactly match with:
16
+ | mesg | line | column |
17
+ | W1046 | 2 | 33 |
18
+ | W1046 | 3 | 33 |
19
+ | W0442 | 1 | 1 |
20
+ | W0443 | 1 | 1 |
21
+
22
+ Scenario: illformed newline escape in declaration
23
+ Given a target source named "W1046.c" with:
24
+ """
25
+ const char *str = "foo" /* OK */ \
26
+ "bar" /* W1046 */ \
27
+ "baz" /* W1046 */ \
28
+ "qux";
29
+ """
30
+ When I successfully run `adlint W1046.c` on noarch
31
+ Then the output should exactly match with:
32
+ | mesg | line | column |
33
+ | W1046 | 2 | 41 |
34
+ | W1046 | 3 | 41 |
35
+ | W0117 | 1 | 13 |
36
+ | W0947 | 1 | 19 |
37
+
38
+ Scenario: illformed newline escape in expression
39
+ Given a target source named "W1046.c" with:
40
+ """
41
+ static void bar(const char *str);
42
+
43
+ void foo(void)
44
+ {
45
+ bar("foo" /* OK */ \
46
+ "bar" /* W1046 */ \
47
+ "baz" /* W1046 */ \
48
+ "qux");
49
+ }
50
+ """
51
+ When I successfully run `adlint W1046.c` on noarch
52
+ Then the output should exactly match with:
53
+ | mesg | line | column |
54
+ | W1046 | 6 | 31 |
55
+ | W1046 | 7 | 31 |
56
+ | W0117 | 3 | 6 |
57
+ | W0947 | 5 | 9 |
58
+ | W0628 | 3 | 6 |
59
+
60
+ # vim:ts=2:sw=2:sts=2:et:
@@ -14,6 +14,7 @@ Feature: W1052
14
14
  When I successfully run `adlint W1052.c` on noarch
15
15
  Then the output should exactly match with:
16
16
  | mesg | line | column |
17
+ | W1076 | 1 | 21 |
17
18
  | W0123 | 3 | 12 |
18
19
  | W0246 | 3 | 12 |
19
20
  | W0123 | 3 | 16 |
@@ -36,6 +37,7 @@ Feature: W1052
36
37
  When I successfully run `adlint W1052.c` on noarch
37
38
  Then the output should exactly match with:
38
39
  | mesg | line | column |
40
+ | W1076 | 1 | 21 |
39
41
  | W0248 | 3 | 12 |
40
42
  | W0248 | 3 | 16 |
41
43
  | W1052 | 3 | 14 |
@@ -57,6 +59,7 @@ Feature: W1052
57
59
  When I successfully run `adlint W1052.c` on noarch
58
60
  Then the output should exactly match with:
59
61
  | mesg | line | column |
62
+ | W1076 | 1 | 21 |
60
63
  | W1052 | 3 | 14 |
61
64
  | W0104 | 1 | 38 |
62
65
  | W0104 | 1 | 54 |
@@ -19,6 +19,7 @@ Feature: W1066
19
19
  When I successfully run `adlint W1066.c` on noarch
20
20
  Then the output should exactly match with:
21
21
  | mesg | line | column |
22
+ | W1076 | 1 | 13 |
22
23
  | W0723 | 4 | 21 |
23
24
  | W1066 | 4 | 21 |
24
25
  | W0723 | 5 | 21 |
@@ -48,6 +49,7 @@ Feature: W1066
48
49
  When I successfully run `adlint W1066.c` on noarch
49
50
  Then the output should exactly match with:
50
51
  | mesg | line | column |
52
+ | W1076 | 1 | 13 |
51
53
  | W0093 | 4 | 21 |
52
54
  | W0570 | 6 | 21 |
53
55
  | W0572 | 6 | 21 |
@@ -72,6 +74,7 @@ Feature: W1066
72
74
  When I successfully run `adlint W1066.c` on noarch
73
75
  Then the output should exactly match with:
74
76
  | mesg | line | column |
77
+ | W1076 | 1 | 13 |
75
78
  | W0723 | 4 | 11 |
76
79
  | W0777 | 4 | 11 |
77
80
  | W0723 | 5 | 11 |
@@ -19,6 +19,7 @@ Feature: W1067
19
19
  When I successfully run `adlint W1067.c` on noarch
20
20
  Then the output should exactly match with:
21
21
  | mesg | line | column |
22
+ | W1076 | 1 | 13 |
22
23
  | W0723 | 4 | 26 |
23
24
  | W1067 | 4 | 26 |
24
25
  | W0723 | 5 | 26 |
@@ -48,6 +49,7 @@ Feature: W1067
48
49
  When I successfully run `adlint W1067.c` on noarch
49
50
  Then the output should exactly match with:
50
51
  | mesg | line | column |
52
+ | W1076 | 1 | 13 |
51
53
  | W0093 | 4 | 26 |
52
54
  | W0570 | 6 | 26 |
53
55
  | W0572 | 6 | 26 |
@@ -72,6 +74,7 @@ Feature: W1067
72
74
  When I successfully run `adlint W1067.c` on noarch
73
75
  Then the output should exactly match with:
74
76
  | mesg | line | column |
77
+ | W1076 | 1 | 13 |
75
78
  | W0723 | 4 | 11 |
76
79
  | W0778 | 4 | 11 |
77
80
  | W0723 | 5 | 11 |
@@ -19,6 +19,7 @@ Feature: W1068
19
19
  When I successfully run `adlint W1068.c` on noarch
20
20
  Then the output should exactly match with:
21
21
  | mesg | line | column |
22
+ | W1076 | 1 | 13 |
22
23
  | W0723 | 4 | 26 |
23
24
  | W1068 | 4 | 26 |
24
25
  | W0723 | 5 | 26 |
@@ -48,6 +49,7 @@ Feature: W1068
48
49
  When I successfully run `adlint W1068.c` on noarch
49
50
  Then the output should exactly match with:
50
51
  | mesg | line | column |
52
+ | W1076 | 1 | 13 |
51
53
  | W0093 | 4 | 26 |
52
54
  | W0570 | 6 | 26 |
53
55
  | W0572 | 6 | 26 |
@@ -72,6 +74,7 @@ Feature: W1068
72
74
  When I successfully run `adlint W1068.c` on noarch
73
75
  Then the output should exactly match with:
74
76
  | mesg | line | column |
77
+ | W1076 | 1 | 13 |
75
78
  | W0723 | 4 | 11 |
76
79
  | W0779 | 4 | 11 |
77
80
  | W0723 | 5 | 11 |
@@ -20,6 +20,7 @@ Feature: W1069
20
20
  When I successfully run `adlint W1069.c` on noarch
21
21
  Then the output should exactly match with:
22
22
  | mesg | line | column |
23
+ | W1076 | 1 | 12 |
23
24
  | W0104 | 1 | 21 |
24
25
  | W0629 | 1 | 12 |
25
26
  | W1069 | 3 | 5 |
@@ -45,6 +46,7 @@ Feature: W1069
45
46
  When I successfully run `adlint W1069.c` on noarch
46
47
  Then the output should exactly match with:
47
48
  | mesg | line | column |
49
+ | W1076 | 1 | 12 |
48
50
  | W0104 | 1 | 21 |
49
51
  | W0629 | 1 | 12 |
50
52
  | W1069 | 3 | 5 |
@@ -72,6 +74,7 @@ Feature: W1069
72
74
  When I successfully run `adlint W1069.c` on noarch
73
75
  Then the output should exactly match with:
74
76
  | mesg | line | column |
77
+ | W1076 | 1 | 12 |
75
78
  | W0104 | 1 | 21 |
76
79
  | W0629 | 1 | 12 |
77
80
  | W0628 | 1 | 12 |
@@ -90,6 +93,7 @@ Feature: W1069
90
93
  When I successfully run `adlint W1069.c` on noarch
91
94
  Then the output should exactly match with:
92
95
  | mesg | line | column |
96
+ | W1076 | 1 | 12 |
93
97
  | W0104 | 1 | 21 |
94
98
  | W0629 | 1 | 12 |
95
99
  | W0628 | 1 | 12 |
@@ -113,6 +117,7 @@ Feature: W1069
113
117
  When I successfully run `adlint W1069.c` on noarch
114
118
  Then the output should exactly match with:
115
119
  | mesg | line | column |
120
+ | W1076 | 1 | 12 |
116
121
  | W0104 | 1 | 21 |
117
122
  | W0629 | 1 | 12 |
118
123
  | W0628 | 1 | 12 |
@@ -19,6 +19,7 @@ Feature: W1070
19
19
  When I successfully run `adlint W1070.c` on noarch
20
20
  Then the output should exactly match with:
21
21
  | mesg | line | column |
22
+ | W1076 | 1 | 12 |
22
23
  | W0629 | 1 | 12 |
23
24
  | W1070 | 3 | 5 |
24
25
  | W0628 | 1 | 12 |
@@ -41,6 +42,7 @@ Feature: W1070
41
42
  When I successfully run `adlint W1070.c` on noarch
42
43
  Then the output should exactly match with:
43
44
  | mesg | line | column |
45
+ | W1076 | 1 | 12 |
44
46
  | W0629 | 1 | 12 |
45
47
  | W0003 | 3 | 5 |
46
48
  | W1070 | 3 | 5 |
@@ -66,6 +68,7 @@ Feature: W1070
66
68
  When I successfully run `adlint W1070.c` on noarch
67
69
  Then the output should exactly match with:
68
70
  | mesg | line | column |
71
+ | W1076 | 1 | 12 |
69
72
  | W0629 | 1 | 12 |
70
73
  | W9001 | 5 | 9 |
71
74
  | W9001 | 6 | 13 |
@@ -87,6 +90,7 @@ Feature: W1070
87
90
  When I successfully run `adlint W1070.c` on noarch
88
91
  Then the output should exactly match with:
89
92
  | mesg | line | column |
93
+ | W1076 | 1 | 12 |
90
94
  | W0629 | 1 | 12 |
91
95
  | W0781 | 3 | 5 |
92
96
  | W0628 | 1 | 12 |
@@ -113,6 +117,7 @@ Feature: W1070
113
117
  When I successfully run `adlint W1070.c` on noarch
114
118
  Then the output should exactly match with:
115
119
  | mesg | line | column |
120
+ | W1076 | 1 | 12 |
116
121
  | W0629 | 1 | 12 |
117
122
  | W9001 | 5 | 9 |
118
123
  | W9001 | 6 | 13 |
@@ -139,6 +144,7 @@ Feature: W1070
139
144
  When I successfully run `adlint W1070.c` on noarch
140
145
  Then the output should exactly match with:
141
146
  | mesg | line | column |
147
+ | W1076 | 1 | 12 |
142
148
  | W0629 | 1 | 12 |
143
149
  | W0628 | 1 | 12 |
144
150