adlint 1.14.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +265 -0
- data/MANIFEST +15 -0
- data/NEWS +30 -4
- data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
- data/etc/mesg.d/en_US/messages.yml +3 -3
- data/etc/mesg.d/ja_JP/messages.yml +3 -3
- data/features/message_detection/W0001.feature +2 -0
- data/features/message_detection/W0007.feature +8 -0
- data/features/message_detection/W0010.feature +4 -1
- data/features/message_detection/W0013.feature +8 -0
- data/features/message_detection/W0093.feature +3 -0
- data/features/message_detection/W0104.feature +7 -0
- data/features/message_detection/W0643.feature +80 -0
- data/features/message_detection/W0646.feature +115 -0
- data/features/message_detection/W0691.feature +100 -0
- data/features/message_detection/W0692.feature +32 -0
- data/features/message_detection/W0694.feature +128 -0
- data/features/message_detection/W0716.feature +3 -0
- data/features/message_detection/W0717.feature +3 -0
- data/features/message_detection/W0718.feature +3 -0
- data/features/message_detection/W0723.feature +2 -0
- data/features/message_detection/W0732.feature +3 -0
- data/features/message_detection/W0733.feature +3 -0
- data/features/message_detection/W0734.feature +8 -0
- data/features/message_detection/W0735.feature +8 -0
- data/features/message_detection/W0805.feature +92 -0
- data/features/message_detection/W0811.feature +79 -0
- data/features/message_detection/W1031.feature +7 -0
- data/features/message_detection/W1040.feature +89 -0
- data/features/message_detection/W1041.feature +15 -0
- data/features/message_detection/W1046.feature +60 -0
- data/features/message_detection/W1052.feature +3 -0
- data/features/message_detection/W1066.feature +3 -0
- data/features/message_detection/W1067.feature +3 -0
- data/features/message_detection/W1068.feature +3 -0
- data/features/message_detection/W1069.feature +5 -0
- data/features/message_detection/W1070.feature +6 -0
- data/features/message_detection/W1072.feature +1 -0
- data/features/message_detection/W1073.feature +145 -0
- data/features/message_detection/W1074.feature +139 -0
- data/features/message_detection/W1075.feature +86 -0
- data/features/message_detection/W1076.feature +66 -0
- data/features/message_detection/W1077.feature +105 -0
- data/features/message_detection/W9003.feature +4 -0
- data/lib/adlint/c/ctrlexpr.rb +3 -0
- data/lib/adlint/c/interp.rb +11 -5
- data/lib/adlint/c/lexer.rb +14 -3
- data/lib/adlint/c/message.rb +192 -0
- data/lib/adlint/c/parser.rb +19 -3
- data/lib/adlint/c/parser.y +18 -2
- data/lib/adlint/c/phase.rb +19 -6
- data/lib/adlint/c/syntax.rb +6 -0
- data/lib/adlint/c/type.rb +5 -1
- data/lib/adlint/cpp/constexpr.rb +3 -3
- data/lib/adlint/cpp/constexpr.y +3 -3
- data/lib/adlint/cpp/eval.rb +60 -86
- data/lib/adlint/cpp/lexer.rb +82 -28
- data/lib/adlint/cpp/macro.rb +64 -35
- data/lib/adlint/cpp/message.rb +137 -4
- data/lib/adlint/cpp/phase.rb +8 -0
- data/lib/adlint/cpp/syntax.rb +25 -0
- data/lib/adlint/lang.rb +2 -1
- 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 +102 -85
- data/share/doc/users_guide_en.texi +85 -69
- data/share/doc/users_guide_ja.html +102 -94
- data/share/doc/users_guide_ja.texi +85 -77
- metadata +17 -2
@@ -0,0 +1,145 @@
|
|
1
|
+
Feature: W1073
|
2
|
+
|
3
|
+
W1073 detects that a return value of the function is discarded.
|
4
|
+
|
5
|
+
Scenario: simply discarding a return value
|
6
|
+
Given a target source named "W1073.c" with:
|
7
|
+
"""
|
8
|
+
extern int bar(void);
|
9
|
+
static void foo(void)
|
10
|
+
{
|
11
|
+
bar(); /* W1073 */
|
12
|
+
}
|
13
|
+
"""
|
14
|
+
When I successfully run `adlint W1073.c` on noarch
|
15
|
+
Then the output should exactly match with:
|
16
|
+
| mesg | line | column |
|
17
|
+
| W0118 | 1 | 12 |
|
18
|
+
| W1076 | 2 | 13 |
|
19
|
+
| W1073 | 4 | 8 |
|
20
|
+
| W0629 | 2 | 13 |
|
21
|
+
| W0628 | 2 | 13 |
|
22
|
+
|
23
|
+
Scenario: calling `void' function
|
24
|
+
Given a target source named "W1073.c" with:
|
25
|
+
"""
|
26
|
+
extern void bar(void);
|
27
|
+
static void foo(void)
|
28
|
+
{
|
29
|
+
bar(); /* OK */
|
30
|
+
}
|
31
|
+
"""
|
32
|
+
When I successfully run `adlint W1073.c` on noarch
|
33
|
+
Then the output should exactly match with:
|
34
|
+
| mesg | line | column |
|
35
|
+
| W0118 | 1 | 13 |
|
36
|
+
| W1076 | 2 | 13 |
|
37
|
+
| W0629 | 2 | 13 |
|
38
|
+
| W0628 | 2 | 13 |
|
39
|
+
|
40
|
+
Scenario: discarding return value in comma separated expression
|
41
|
+
Given a target source named "W1073.c" with:
|
42
|
+
"""
|
43
|
+
extern int bar(void);
|
44
|
+
extern void baz(void);
|
45
|
+
static void foo(void)
|
46
|
+
{
|
47
|
+
int i;
|
48
|
+
i = (bar(), baz()); /* W1073 */
|
49
|
+
}
|
50
|
+
"""
|
51
|
+
When I successfully run `adlint W1073.c` on noarch
|
52
|
+
Then the output should exactly match with:
|
53
|
+
| mesg | line | column |
|
54
|
+
| W0118 | 1 | 12 |
|
55
|
+
| W0118 | 2 | 13 |
|
56
|
+
| W1076 | 3 | 13 |
|
57
|
+
| W0100 | 5 | 9 |
|
58
|
+
| W1073 | 6 | 13 |
|
59
|
+
| W0629 | 3 | 13 |
|
60
|
+
| W0447 | 6 | 10 |
|
61
|
+
| W0628 | 3 | 13 |
|
62
|
+
|
63
|
+
Scenario: discarding return value in for-statement
|
64
|
+
Given a target source named "W1073.c" with:
|
65
|
+
"""
|
66
|
+
extern int bar(void);
|
67
|
+
static void foo(void)
|
68
|
+
{
|
69
|
+
int i;
|
70
|
+
int j;
|
71
|
+
for (i = 0, bar(); i < 10; i++) { /* W1073 */
|
72
|
+
j = bar(); /* OK */
|
73
|
+
}
|
74
|
+
}
|
75
|
+
"""
|
76
|
+
When I successfully run `adlint W1073.c` on noarch
|
77
|
+
Then the output should exactly match with:
|
78
|
+
| mesg | line | column |
|
79
|
+
| W0118 | 1 | 12 |
|
80
|
+
| W1076 | 2 | 13 |
|
81
|
+
| W0100 | 5 | 9 |
|
82
|
+
| W1073 | 6 | 20 |
|
83
|
+
| W0629 | 2 | 13 |
|
84
|
+
| W0535 | 6 | 10 |
|
85
|
+
| W0628 | 2 | 13 |
|
86
|
+
|
87
|
+
Scenario: no assignment but not discarding the return value
|
88
|
+
Given a target source named "W1073.c" with:
|
89
|
+
"""
|
90
|
+
extern int bar(void);
|
91
|
+
static void foo(void)
|
92
|
+
{
|
93
|
+
if (bar() == 0) { /* OK */
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
"""
|
98
|
+
When I successfully run `adlint W1073.c` on noarch
|
99
|
+
Then the output should exactly match with:
|
100
|
+
| mesg | line | column |
|
101
|
+
| W0118 | 1 | 12 |
|
102
|
+
| W1076 | 2 | 13 |
|
103
|
+
| W0629 | 2 | 13 |
|
104
|
+
| W0628 | 2 | 13 |
|
105
|
+
|
106
|
+
Scenario: propagating the return value
|
107
|
+
Given a target source named "W1073.c" with:
|
108
|
+
"""
|
109
|
+
extern int bar(void);
|
110
|
+
static int foo(void)
|
111
|
+
{
|
112
|
+
return bar(); /* OK */
|
113
|
+
}
|
114
|
+
"""
|
115
|
+
When I successfully run `adlint W1073.c` on noarch
|
116
|
+
Then the output should exactly match with:
|
117
|
+
| mesg | line | column |
|
118
|
+
| W0118 | 1 | 12 |
|
119
|
+
| W1076 | 2 | 12 |
|
120
|
+
| W0629 | 2 | 12 |
|
121
|
+
| W0628 | 2 | 12 |
|
122
|
+
|
123
|
+
Scenario: propagating the return value in a conditional-expression
|
124
|
+
Given a target source named "W1073.c" with:
|
125
|
+
"""
|
126
|
+
extern int bar(void);
|
127
|
+
extern int baz(void);
|
128
|
+
static int foo(void)
|
129
|
+
{
|
130
|
+
return bar() == 0 ? baz() : 0; /* OK */
|
131
|
+
}
|
132
|
+
"""
|
133
|
+
When I successfully run `adlint W1073.c` on noarch
|
134
|
+
Then the output should exactly match with:
|
135
|
+
| mesg | line | column |
|
136
|
+
| W0118 | 1 | 12 |
|
137
|
+
| W0118 | 2 | 12 |
|
138
|
+
| W1076 | 3 | 12 |
|
139
|
+
| W0629 | 3 | 12 |
|
140
|
+
| W0501 | 5 | 12 |
|
141
|
+
| W0010 | 5 | 23 |
|
142
|
+
| W0086 | 5 | 23 |
|
143
|
+
| W0628 | 3 | 12 |
|
144
|
+
|
145
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,139 @@
|
|
1
|
+
Feature: W1074
|
2
|
+
|
3
|
+
W1074 detects that an expression with possible side-effects appears in the
|
4
|
+
`sizeof' expression.
|
5
|
+
|
6
|
+
Scenario: postfix-increment-expression in the sizeof-expression
|
7
|
+
Given a target source named "W1074.c" with:
|
8
|
+
"""
|
9
|
+
static int foo(void)
|
10
|
+
{
|
11
|
+
int i = 0;
|
12
|
+
|
13
|
+
if (sizeof(i++) == 4) { /* W1074 */
|
14
|
+
return 0;
|
15
|
+
}
|
16
|
+
else {
|
17
|
+
return 1;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
"""
|
21
|
+
When I successfully run `adlint W1074.c` on noarch
|
22
|
+
Then the output should exactly match with:
|
23
|
+
| mesg | line | column |
|
24
|
+
| W1076 | 1 | 12 |
|
25
|
+
| W0612 | 5 | 21 |
|
26
|
+
| W0609 | 5 | 21 |
|
27
|
+
| W0629 | 1 | 12 |
|
28
|
+
| W1074 | 5 | 15 |
|
29
|
+
| W9001 | 9 | 9 |
|
30
|
+
| W0628 | 1 | 12 |
|
31
|
+
|
32
|
+
Scenario: nested sizeof-expression
|
33
|
+
Given a target source named "W1074.c" with:
|
34
|
+
"""
|
35
|
+
static int foo(void)
|
36
|
+
{
|
37
|
+
int i = 0;
|
38
|
+
|
39
|
+
if (sizeof(1 + sizeof(i++)) == 5) { /* W1074 */
|
40
|
+
return 0;
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
return 1;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
"""
|
47
|
+
When I successfully run `adlint W1074.c` on noarch
|
48
|
+
Then the output should exactly match with:
|
49
|
+
| mesg | line | column |
|
50
|
+
| W1076 | 1 | 12 |
|
51
|
+
| W0613 | 5 | 33 |
|
52
|
+
| W0610 | 5 | 33 |
|
53
|
+
| W0629 | 1 | 12 |
|
54
|
+
| W1074 | 5 | 26 |
|
55
|
+
| W9001 | 6 | 9 |
|
56
|
+
| W0628 | 1 | 12 |
|
57
|
+
|
58
|
+
Scenario: ungrouped postfix-increment-expression in the sizeof-expression
|
59
|
+
Given a target source named "W1074.c" with:
|
60
|
+
"""
|
61
|
+
static int foo(void)
|
62
|
+
{
|
63
|
+
int i = 0;
|
64
|
+
|
65
|
+
if (sizeof i++ == 4) { /* W1074 */
|
66
|
+
return 0;
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
return 1;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
"""
|
73
|
+
When I successfully run `adlint W1074.c` on noarch
|
74
|
+
Then the output should exactly match with:
|
75
|
+
| mesg | line | column |
|
76
|
+
| W1076 | 1 | 12 |
|
77
|
+
| W0612 | 5 | 20 |
|
78
|
+
| W0609 | 5 | 20 |
|
79
|
+
| W0629 | 1 | 12 |
|
80
|
+
| W1074 | 5 | 17 |
|
81
|
+
| W9001 | 9 | 9 |
|
82
|
+
| W0628 | 1 | 12 |
|
83
|
+
|
84
|
+
Scenario: function-call-expression in the sizeof-expression
|
85
|
+
Given a target source named "W1074.c" with:
|
86
|
+
"""
|
87
|
+
extern int bar(void);
|
88
|
+
|
89
|
+
static int foo(void)
|
90
|
+
{
|
91
|
+
if (sizeof(bar()) == 4) { /* W1074 */
|
92
|
+
return 0;
|
93
|
+
}
|
94
|
+
else {
|
95
|
+
return 1;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
"""
|
99
|
+
When I successfully run `adlint W1074.c` on noarch
|
100
|
+
Then the output should exactly match with:
|
101
|
+
| mesg | line | column |
|
102
|
+
| W0118 | 1 | 12 |
|
103
|
+
| W1076 | 3 | 12 |
|
104
|
+
| W0612 | 5 | 23 |
|
105
|
+
| W0609 | 5 | 23 |
|
106
|
+
| W1073 | 5 | 19 |
|
107
|
+
| W0629 | 3 | 12 |
|
108
|
+
| W1074 | 5 | 15 |
|
109
|
+
| W9001 | 9 | 9 |
|
110
|
+
| W0628 | 3 | 12 |
|
111
|
+
|
112
|
+
Scenario: array-subscript-expression in the sizeof-expression
|
113
|
+
Given a target source named "W1074.c" with:
|
114
|
+
"""
|
115
|
+
extern int a[];
|
116
|
+
|
117
|
+
static int foo(void)
|
118
|
+
{
|
119
|
+
if (sizeof(a[0]) == 4) { /* OK */
|
120
|
+
return 0;
|
121
|
+
}
|
122
|
+
else {
|
123
|
+
return 1;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
"""
|
127
|
+
When I successfully run `adlint W1074.c` on noarch
|
128
|
+
Then the output should exactly match with:
|
129
|
+
| mesg | line | column |
|
130
|
+
| W0118 | 1 | 12 |
|
131
|
+
| W1077 | 1 | 12 |
|
132
|
+
| W1076 | 3 | 12 |
|
133
|
+
| W0612 | 5 | 22 |
|
134
|
+
| W0609 | 5 | 22 |
|
135
|
+
| W0629 | 3 | 12 |
|
136
|
+
| W9001 | 9 | 9 |
|
137
|
+
| W0628 | 3 | 12 |
|
138
|
+
|
139
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,86 @@
|
|
1
|
+
Feature: W1075
|
2
|
+
|
3
|
+
W1075 detects that a declaration has no `static' specifier while the anterior
|
4
|
+
declaration is specified as `static'.
|
5
|
+
|
6
|
+
Scenario: colliding global variable declarations
|
7
|
+
Given a target source named "W1075.c" with:
|
8
|
+
"""
|
9
|
+
static int i;
|
10
|
+
extern int i; /* W1075 */
|
11
|
+
"""
|
12
|
+
When I successfully run `adlint W1075.c` on noarch
|
13
|
+
Then the output should exactly match with:
|
14
|
+
| mesg | line | column |
|
15
|
+
| W1031 | 2 | 12 |
|
16
|
+
| W1075 | 2 | 12 |
|
17
|
+
|
18
|
+
Scenario: `static' function declaration followed by its definition without
|
19
|
+
storage-class-specifier
|
20
|
+
Given a target source named "W1075.c" with:
|
21
|
+
"""
|
22
|
+
static int foo(void);
|
23
|
+
|
24
|
+
int foo(void) /* W1075 */
|
25
|
+
{
|
26
|
+
return 0;
|
27
|
+
}
|
28
|
+
"""
|
29
|
+
When I successfully run `adlint W1075.c` on noarch
|
30
|
+
Then the output should exactly match with:
|
31
|
+
| mesg | line | column |
|
32
|
+
| W1075 | 3 | 5 |
|
33
|
+
| W0629 | 3 | 5 |
|
34
|
+
| W0628 | 3 | 5 |
|
35
|
+
|
36
|
+
Scenario: colliding function declarations with `static' and `extern'
|
37
|
+
Given a target source named "W1075.c" with:
|
38
|
+
"""
|
39
|
+
static int foo(void);
|
40
|
+
|
41
|
+
extern int foo(void) /* W1075 */
|
42
|
+
{
|
43
|
+
return 0;
|
44
|
+
}
|
45
|
+
"""
|
46
|
+
When I successfully run `adlint W1075.c` on noarch
|
47
|
+
Then the output should exactly match with:
|
48
|
+
| mesg | line | column |
|
49
|
+
| W1031 | 3 | 12 |
|
50
|
+
| W1075 | 3 | 12 |
|
51
|
+
| W0629 | 3 | 12 |
|
52
|
+
| W0628 | 3 | 12 |
|
53
|
+
|
54
|
+
Scenario: all function declarations with `static'
|
55
|
+
Given a target source named "W1075.c" with:
|
56
|
+
"""
|
57
|
+
static int foo(void);
|
58
|
+
|
59
|
+
static int foo(void) /* OK */
|
60
|
+
{
|
61
|
+
return 0;
|
62
|
+
}
|
63
|
+
"""
|
64
|
+
When I successfully run `adlint W1075.c` on noarch
|
65
|
+
Then the output should exactly match with:
|
66
|
+
| mesg | line | column |
|
67
|
+
| W0629 | 3 | 12 |
|
68
|
+
| W0628 | 3 | 12 |
|
69
|
+
|
70
|
+
Scenario: all function declarations with `extern'
|
71
|
+
Given a target source named "W1075.c" with:
|
72
|
+
"""
|
73
|
+
extern int foo(void);
|
74
|
+
|
75
|
+
extern int foo(void) /* OK */
|
76
|
+
{
|
77
|
+
return 0;
|
78
|
+
}
|
79
|
+
"""
|
80
|
+
When I successfully run `adlint W1075.c` on noarch
|
81
|
+
Then the output should exactly match with:
|
82
|
+
| mesg | line | column |
|
83
|
+
| W0118 | 1 | 12 |
|
84
|
+
| W0628 | 3 | 12 |
|
85
|
+
|
86
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,66 @@
|
|
1
|
+
Feature: W1076
|
2
|
+
|
3
|
+
W1076 detects that a `static' function definition appears with no anterior
|
4
|
+
function declarations.
|
5
|
+
|
6
|
+
Scenario: `static' function definition
|
7
|
+
Given a target source named "W1076.c" with:
|
8
|
+
"""
|
9
|
+
static int foo(void) /* W1076 */
|
10
|
+
{
|
11
|
+
return 0;
|
12
|
+
}
|
13
|
+
"""
|
14
|
+
When I successfully run `adlint W1076.c` on noarch
|
15
|
+
Then the output should exactly match with:
|
16
|
+
| mesg | line | column |
|
17
|
+
| W1076 | 1 | 12 |
|
18
|
+
| W0629 | 1 | 12 |
|
19
|
+
| W0628 | 1 | 12 |
|
20
|
+
|
21
|
+
Scenario: `static' function declaration followed by the `static' function
|
22
|
+
definition
|
23
|
+
Given a target source named "W1076.c" with:
|
24
|
+
"""
|
25
|
+
static int foo(void);
|
26
|
+
|
27
|
+
static int foo(void) /* OK */
|
28
|
+
{
|
29
|
+
return 0;
|
30
|
+
}
|
31
|
+
"""
|
32
|
+
When I successfully run `adlint W1076.c` on noarch
|
33
|
+
Then the output should exactly match with:
|
34
|
+
| mesg | line | column |
|
35
|
+
| W0629 | 3 | 12 |
|
36
|
+
| W0628 | 3 | 12 |
|
37
|
+
|
38
|
+
Scenario: `extern' function definition
|
39
|
+
Given a target source named "W1076.c" with:
|
40
|
+
"""
|
41
|
+
extern int foo(void) /* OK */
|
42
|
+
{
|
43
|
+
return 0;
|
44
|
+
}
|
45
|
+
"""
|
46
|
+
When I successfully run `adlint W1076.c` on noarch
|
47
|
+
Then the output should exactly match with:
|
48
|
+
| mesg | line | column |
|
49
|
+
| W0117 | 1 | 12 |
|
50
|
+
| W0628 | 1 | 12 |
|
51
|
+
|
52
|
+
Scenario: function definition without storage-class-specifier
|
53
|
+
Given a target source named "W1076.c" with:
|
54
|
+
"""
|
55
|
+
int foo(void) /* OK */
|
56
|
+
{
|
57
|
+
return 0;
|
58
|
+
}
|
59
|
+
"""
|
60
|
+
When I successfully run `adlint W1076.c` on noarch
|
61
|
+
Then the output should exactly match with:
|
62
|
+
| mesg | line | column |
|
63
|
+
| W0117 | 1 | 5 |
|
64
|
+
| W0628 | 1 | 5 |
|
65
|
+
|
66
|
+
# vim:ts=2:sw=2:sts=2:et:
|