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.
- data/ChangeLog +471 -0
- data/MANIFEST +35 -8
- data/NEWS +50 -4
- data/bin/adlint +7 -7
- data/bin/adlint_chk +7 -7
- data/bin/adlint_cma +7 -7
- data/bin/adlint_sma +7 -7
- data/bin/adlintize +5 -5
- data/etc/mesg.d/en_US/messages.yml +3 -3
- data/etc/mesg.d/ja_JP/messages.yml +3 -3
- data/features/message_detection/E0013.feature +34 -0
- data/features/message_detection/W0007.feature +2 -0
- data/features/message_detection/W0583.feature +1 -2
- data/features/message_detection/W0641.feature +132 -0
- data/features/message_detection/W0643.feature +1 -1
- data/features/message_detection/W0644.feature +529 -0
- data/features/message_detection/W0645.feature +1 -1
- data/features/message_detection/W0649.feature +277 -0
- data/features/message_detection/W0650.feature +208 -0
- data/features/message_detection/W0697.feature +6 -0
- data/features/message_detection/W0705.feature +350 -0
- data/features/message_detection/W0707.feature +223 -0
- data/features/message_detection/W0711.feature +113 -0
- data/features/message_detection/W0712.feature +113 -0
- data/features/message_detection/W0713.feature +110 -0
- data/features/message_detection/W0714.feature +118 -0
- data/features/message_detection/W0715.feature +118 -0
- data/features/message_detection/W0716.feature +1 -0
- data/features/message_detection/W0717.feature +1 -0
- data/features/message_detection/W0718.feature +1 -0
- data/features/message_detection/W0719.feature +154 -0
- data/features/message_detection/W0723.feature +1 -2
- data/features/message_detection/W0732.feature +3 -0
- data/features/message_detection/W0733.feature +3 -0
- data/features/message_detection/W0734.feature +4 -0
- data/features/message_detection/W0735.feature +4 -0
- data/features/message_detection/W0745.feature +132 -0
- data/features/message_detection/W0780.feature +68 -0
- data/features/message_detection/W0783.feature +95 -0
- data/features/message_detection/W0792.feature +124 -0
- data/features/message_detection/W0793.feature +153 -0
- data/features/message_detection/W0794.feature +90 -0
- data/features/message_detection/W0830.feature +65 -0
- data/features/message_detection/W0833.feature +220 -0
- data/features/message_detection/W0834.feature +189 -0
- data/features/message_detection/W1026.feature +105 -0
- data/features/message_detection/W1031.feature +17 -34
- data/features/message_detection/W1039.feature +268 -0
- data/features/message_detection/W1047.feature +163 -0
- data/features/message_detection/W1066.feature +1 -0
- data/features/message_detection/W1067.feature +1 -0
- data/features/message_detection/W1068.feature +1 -0
- data/features/message_detection/W1069.feature +5 -0
- data/features/message_detection/W1070.feature +5 -0
- data/features/message_detection/W1071.feature +83 -0
- data/features/message_detection/W1073.feature +3 -2
- data/features/message_detection/W9003.feature +7 -12
- data/features/step_definitions/message_detection_steps.rb +4 -31
- data/features/support/env.rb +117 -2
- data/lib/adlint/c/branch.rb +0 -2
- data/lib/adlint/c/ctrlexpr.rb +33 -0
- data/lib/adlint/c/expr.rb +119 -31
- data/lib/adlint/c/interp.rb +44 -3
- data/lib/adlint/c/message.rb +1411 -29
- data/lib/adlint/c/object.rb +16 -2
- data/lib/adlint/c/option.rb +1 -0
- data/lib/adlint/c/parser.rb +101 -100
- data/lib/adlint/c/parser.y +3 -2
- data/lib/adlint/c/phase.rb +18 -0
- data/lib/adlint/c/resolver.rb +23 -0
- data/lib/adlint/c/syntax.rb +90 -4
- data/lib/adlint/c/type.rb +177 -110
- data/lib/adlint/cpp/macro.rb +4 -4
- data/lib/adlint/version.rb +2 -2
- data/share/demo/bad_include/test/"1/".h +0 -0
- 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 +467 -506
- data/share/doc/users_guide_en.texi +95 -125
- data/share/doc/users_guide_ja.html +471 -518
- data/share/doc/users_guide_ja.texi +95 -133
- data/spec/spec_helper.rb +6 -0
- metadata +37 -10
@@ -0,0 +1,68 @@
|
|
1
|
+
Feature: W0780
|
2
|
+
|
3
|
+
W0780 detects that a left shift-expression of unsigned constant value
|
4
|
+
discards upper non-zero bits.
|
5
|
+
|
6
|
+
Scenario: discarding 3 of zero bits and 1 of non-zero bit in `unsigned int'
|
7
|
+
constant
|
8
|
+
Given a target source named "W0719.c" with:
|
9
|
+
"""
|
10
|
+
unsigned int foo(void)
|
11
|
+
{
|
12
|
+
return 0x08000000U << 5; /* W0780 */
|
13
|
+
}
|
14
|
+
"""
|
15
|
+
When I successfully run `adlint W0719.c` on noarch
|
16
|
+
Then the output should exactly match with:
|
17
|
+
| mesg | line | column |
|
18
|
+
| W0117 | 1 | 14 |
|
19
|
+
| W0115 | 3 | 24 |
|
20
|
+
| W0780 | 3 | 24 |
|
21
|
+
| W0628 | 1 | 14 |
|
22
|
+
|
23
|
+
Scenario: discarding 4 of zero bits in `unsigned int' constant
|
24
|
+
Given a target source named "W0719.c" with:
|
25
|
+
"""
|
26
|
+
unsigned int foo(void)
|
27
|
+
{
|
28
|
+
return 0x08000000U << 4; /* OK */
|
29
|
+
}
|
30
|
+
"""
|
31
|
+
When I successfully run `adlint W0719.c` on noarch
|
32
|
+
Then the output should exactly match with:
|
33
|
+
| mesg | line | column |
|
34
|
+
| W0117 | 1 | 14 |
|
35
|
+
| W0628 | 1 | 14 |
|
36
|
+
|
37
|
+
Scenario: discarding 3 of zero bits and 1 of non-zero bit in `unsigned long'
|
38
|
+
constant
|
39
|
+
Given a target source named "W0719.c" with:
|
40
|
+
"""
|
41
|
+
unsigned long foo(void)
|
42
|
+
{
|
43
|
+
return 0x08000000UL << 5; /* W0780 */
|
44
|
+
}
|
45
|
+
"""
|
46
|
+
When I successfully run `adlint W0719.c` on noarch
|
47
|
+
Then the output should exactly match with:
|
48
|
+
| mesg | line | column |
|
49
|
+
| W0117 | 1 | 15 |
|
50
|
+
| W0115 | 3 | 25 |
|
51
|
+
| W0780 | 3 | 25 |
|
52
|
+
| W0628 | 1 | 15 |
|
53
|
+
|
54
|
+
Scenario: discarding 4 of zero bits in `unsigned int' constant
|
55
|
+
Given a target source named "W0719.c" with:
|
56
|
+
"""
|
57
|
+
unsigned long foo(void)
|
58
|
+
{
|
59
|
+
return 0x08000000UL << 4; /* OK */
|
60
|
+
}
|
61
|
+
"""
|
62
|
+
When I successfully run `adlint W0719.c` on noarch
|
63
|
+
Then the output should exactly match with:
|
64
|
+
| mesg | line | column |
|
65
|
+
| W0117 | 1 | 15 |
|
66
|
+
| W0628 | 1 | 15 |
|
67
|
+
|
68
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,95 @@
|
|
1
|
+
Feature: W0783
|
2
|
+
|
3
|
+
W0783 detects that a cast-expression contains a pointer type of an incomplete
|
4
|
+
type.
|
5
|
+
|
6
|
+
Scenario: casting to a pointer of an incomplete struct
|
7
|
+
Given a target source named "W0783.c" with:
|
8
|
+
"""
|
9
|
+
extern struct Foo *gp;
|
10
|
+
|
11
|
+
void foo(int *p)
|
12
|
+
{
|
13
|
+
gp = (struct Foo *) p; /* W0783 */
|
14
|
+
}
|
15
|
+
"""
|
16
|
+
When I successfully run `adlint W0783.c` on noarch
|
17
|
+
Then the output should exactly match with:
|
18
|
+
| mesg | line | column |
|
19
|
+
| W0118 | 1 | 20 |
|
20
|
+
| W0117 | 3 | 6 |
|
21
|
+
| W0783 | 5 | 10 |
|
22
|
+
| W0104 | 3 | 15 |
|
23
|
+
| W0105 | 3 | 15 |
|
24
|
+
| W0628 | 3 | 6 |
|
25
|
+
|
26
|
+
Scenario: casting from a pointer of an incomplete struct
|
27
|
+
Given a target source named "W0783.c" with:
|
28
|
+
"""
|
29
|
+
extern struct Foo *gp;
|
30
|
+
|
31
|
+
void foo(void)
|
32
|
+
{
|
33
|
+
int *p = (int *) gp; /* W0783 */
|
34
|
+
}
|
35
|
+
"""
|
36
|
+
When I successfully run `adlint W0783.c` on noarch
|
37
|
+
Then the output should exactly match with:
|
38
|
+
| mesg | line | column |
|
39
|
+
| W0118 | 1 | 20 |
|
40
|
+
| W0117 | 3 | 6 |
|
41
|
+
| W0783 | 5 | 14 |
|
42
|
+
| W0100 | 5 | 10 |
|
43
|
+
| W0628 | 3 | 6 |
|
44
|
+
|
45
|
+
Scenario: casting from and to a pointer of an incomplete struct
|
46
|
+
Given a target source named "W0783.c" with:
|
47
|
+
"""
|
48
|
+
extern struct Foo *p1;
|
49
|
+
extern union Bar *p2;
|
50
|
+
|
51
|
+
void foo(void)
|
52
|
+
{
|
53
|
+
p2 = (union Bar *) p1; /* W0783 */
|
54
|
+
}
|
55
|
+
"""
|
56
|
+
When I successfully run `adlint W0783.c` on noarch
|
57
|
+
Then the output should exactly match with:
|
58
|
+
| mesg | line | column |
|
59
|
+
| W0118 | 1 | 20 |
|
60
|
+
| W0118 | 2 | 19 |
|
61
|
+
| W0117 | 4 | 6 |
|
62
|
+
| W0783 | 6 | 10 |
|
63
|
+
| W0628 | 4 | 6 |
|
64
|
+
|
65
|
+
Scenario: casting from and to a pointer of an complete type
|
66
|
+
Given a target source named "W0783.c" with:
|
67
|
+
"""
|
68
|
+
struct Foo {
|
69
|
+
int i;
|
70
|
+
} *p1;
|
71
|
+
|
72
|
+
union Bar {
|
73
|
+
int i;
|
74
|
+
char c;
|
75
|
+
} *p2;
|
76
|
+
|
77
|
+
void foo(void)
|
78
|
+
{
|
79
|
+
p2 = (union Bar *) p1; /* OK */
|
80
|
+
}
|
81
|
+
"""
|
82
|
+
When I successfully run `adlint W0783.c` on noarch
|
83
|
+
Then the output should exactly match with:
|
84
|
+
| mesg | line | column |
|
85
|
+
| W0117 | 3 | 4 |
|
86
|
+
| W0117 | 8 | 4 |
|
87
|
+
| W0117 | 10 | 6 |
|
88
|
+
| W0551 | 5 | 7 |
|
89
|
+
| W0628 | 10 | 6 |
|
90
|
+
| W0589 | 3 | 4 |
|
91
|
+
| W0593 | 3 | 4 |
|
92
|
+
| W0589 | 8 | 4 |
|
93
|
+
| W0593 | 8 | 4 |
|
94
|
+
|
95
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,124 @@
|
|
1
|
+
Feature: W0792
|
2
|
+
|
3
|
+
W0792 detects that an explicit conversion between variable of floating point
|
4
|
+
number and pointer to a function is found.
|
5
|
+
|
6
|
+
Scenario: converting `float' to function pointer
|
7
|
+
Given a target source named "W0792.c" with:
|
8
|
+
"""
|
9
|
+
int (*foo(const float f))(void)
|
10
|
+
{
|
11
|
+
return (int (*)(void)) f; /* W0792 */
|
12
|
+
}
|
13
|
+
"""
|
14
|
+
When I successfully run `adlint W0792.c` on noarch
|
15
|
+
Then the output should exactly match with:
|
16
|
+
| mesg | line | column |
|
17
|
+
| W0117 | 1 | 7 |
|
18
|
+
| W0792 | 3 | 12 |
|
19
|
+
| W0628 | 1 | 7 |
|
20
|
+
|
21
|
+
Scenario: converting `double' to function pointer
|
22
|
+
Given a target source named "W0792.c" with:
|
23
|
+
"""
|
24
|
+
int (*foo(const double f))(void)
|
25
|
+
{
|
26
|
+
return (int (*)(void)) f; /* W0792 */
|
27
|
+
}
|
28
|
+
"""
|
29
|
+
When I successfully run `adlint W0792.c` on noarch
|
30
|
+
Then the output should exactly match with:
|
31
|
+
| mesg | line | column |
|
32
|
+
| W0117 | 1 | 7 |
|
33
|
+
| W0792 | 3 | 12 |
|
34
|
+
| W0628 | 1 | 7 |
|
35
|
+
|
36
|
+
Scenario: converting `long double' to function pointer
|
37
|
+
Given a target source named "W0792.c" with:
|
38
|
+
"""
|
39
|
+
int (*foo(const long double f))(void)
|
40
|
+
{
|
41
|
+
return (int (*)(void)) f; /* W0792 */
|
42
|
+
}
|
43
|
+
"""
|
44
|
+
When I successfully run `adlint W0792.c` on noarch
|
45
|
+
Then the output should exactly match with:
|
46
|
+
| mesg | line | column |
|
47
|
+
| W0117 | 1 | 7 |
|
48
|
+
| W0792 | 3 | 12 |
|
49
|
+
| W0628 | 1 | 7 |
|
50
|
+
|
51
|
+
Scenario: converting function pointer to `float'
|
52
|
+
Given a target source named "W0792.c" with:
|
53
|
+
"""
|
54
|
+
float foo(int (* const p)(void))
|
55
|
+
{
|
56
|
+
return (float) p; /* W0792 */
|
57
|
+
}
|
58
|
+
"""
|
59
|
+
When I successfully run `adlint W0792.c` on noarch
|
60
|
+
Then the output should exactly match with:
|
61
|
+
| mesg | line | column |
|
62
|
+
| W0117 | 1 | 7 |
|
63
|
+
| W0792 | 3 | 12 |
|
64
|
+
| W0628 | 1 | 7 |
|
65
|
+
|
66
|
+
Scenario: converting function pointer to `double'
|
67
|
+
Given a target source named "W0792.c" with:
|
68
|
+
"""
|
69
|
+
double foo(int (* const p)(void))
|
70
|
+
{
|
71
|
+
return (double) p; /* W0792 */
|
72
|
+
}
|
73
|
+
"""
|
74
|
+
When I successfully run `adlint W0792.c` on noarch
|
75
|
+
Then the output should exactly match with:
|
76
|
+
| mesg | line | column |
|
77
|
+
| W0117 | 1 | 8 |
|
78
|
+
| W0792 | 3 | 12 |
|
79
|
+
| W0628 | 1 | 8 |
|
80
|
+
|
81
|
+
Scenario: converting function pointer to `long double'
|
82
|
+
Given a target source named "W0792.c" with:
|
83
|
+
"""
|
84
|
+
long double foo(int (* const p)(void))
|
85
|
+
{
|
86
|
+
return (long double) p; /* W0792 */
|
87
|
+
}
|
88
|
+
"""
|
89
|
+
When I successfully run `adlint W0792.c` on noarch
|
90
|
+
Then the output should exactly match with:
|
91
|
+
| mesg | line | column |
|
92
|
+
| W0117 | 1 | 13 |
|
93
|
+
| W0792 | 3 | 12 |
|
94
|
+
| W0628 | 1 | 13 |
|
95
|
+
|
96
|
+
Scenario: converting `float' to `int'
|
97
|
+
Given a target source named "W0792.c" with:
|
98
|
+
"""
|
99
|
+
int foo(const float f)
|
100
|
+
{
|
101
|
+
return (int) f; /* OK */
|
102
|
+
}
|
103
|
+
"""
|
104
|
+
When I successfully run `adlint W0792.c` on noarch
|
105
|
+
Then the output should exactly match with:
|
106
|
+
| mesg | line | column |
|
107
|
+
| W0117 | 1 | 5 |
|
108
|
+
| W0628 | 1 | 5 |
|
109
|
+
|
110
|
+
Scenario: converting function pointer to `void *'
|
111
|
+
Given a target source named "W0792.c" with:
|
112
|
+
"""
|
113
|
+
void *foo(int (* const p)(void))
|
114
|
+
{
|
115
|
+
return (void *) p; /* OK */
|
116
|
+
}
|
117
|
+
"""
|
118
|
+
When I successfully run `adlint W0792.c` on noarch
|
119
|
+
Then the output should exactly match with:
|
120
|
+
| mesg | line | column |
|
121
|
+
| W0117 | 1 | 7 |
|
122
|
+
| W0628 | 1 | 7 |
|
123
|
+
|
124
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,153 @@
|
|
1
|
+
Feature: W0793
|
2
|
+
|
3
|
+
W0793 detects that an explicit conversion between pointer to variable and
|
4
|
+
pointer to function is found.
|
5
|
+
|
6
|
+
Scenario: converting `float *' to function pointer
|
7
|
+
Given a target source named "W0793.c" with:
|
8
|
+
"""
|
9
|
+
typedef int (*funptr_t)(void);
|
10
|
+
|
11
|
+
funptr_t foo(float *p)
|
12
|
+
{
|
13
|
+
return (funptr_t) p; /* W0793 */
|
14
|
+
}
|
15
|
+
"""
|
16
|
+
When I successfully run `adlint W0793.c` on noarch
|
17
|
+
Then the output should exactly match with:
|
18
|
+
| mesg | line | column |
|
19
|
+
| W0117 | 3 | 10 |
|
20
|
+
| W0625 | 1 | 15 |
|
21
|
+
| W0793 | 5 | 12 |
|
22
|
+
| W0104 | 3 | 21 |
|
23
|
+
| W0105 | 3 | 21 |
|
24
|
+
| W0628 | 3 | 10 |
|
25
|
+
|
26
|
+
Scenario: converting `double *' to function pointer
|
27
|
+
Given a target source named "W0793.c" with:
|
28
|
+
"""
|
29
|
+
typedef int (*funptr_t)(void);
|
30
|
+
|
31
|
+
funptr_t foo(double *p)
|
32
|
+
{
|
33
|
+
return (funptr_t) p; /* W0793 */
|
34
|
+
}
|
35
|
+
"""
|
36
|
+
When I successfully run `adlint W0793.c` on noarch
|
37
|
+
Then the output should exactly match with:
|
38
|
+
| mesg | line | column |
|
39
|
+
| W0117 | 3 | 10 |
|
40
|
+
| W0625 | 1 | 15 |
|
41
|
+
| W0793 | 5 | 12 |
|
42
|
+
| W0104 | 3 | 22 |
|
43
|
+
| W0105 | 3 | 22 |
|
44
|
+
| W0628 | 3 | 10 |
|
45
|
+
|
46
|
+
Scenario: converting `long double *' to function pointer
|
47
|
+
Given a target source named "W0793.c" with:
|
48
|
+
"""
|
49
|
+
typedef int (*funptr_t)(void);
|
50
|
+
|
51
|
+
funptr_t foo(long double *p)
|
52
|
+
{
|
53
|
+
return (funptr_t) p; /* W0793 */
|
54
|
+
}
|
55
|
+
"""
|
56
|
+
When I successfully run `adlint W0793.c` on noarch
|
57
|
+
Then the output should exactly match with:
|
58
|
+
| mesg | line | column |
|
59
|
+
| W0117 | 3 | 10 |
|
60
|
+
| W0625 | 1 | 15 |
|
61
|
+
| W0793 | 5 | 12 |
|
62
|
+
| W0104 | 3 | 27 |
|
63
|
+
| W0105 | 3 | 27 |
|
64
|
+
| W0628 | 3 | 10 |
|
65
|
+
|
66
|
+
Scenario: converting function pointer to `float *'
|
67
|
+
Given a target source named "W0793.c" with:
|
68
|
+
"""
|
69
|
+
typedef int (*funptr_t)(void);
|
70
|
+
|
71
|
+
float *foo(funptr_t p)
|
72
|
+
{
|
73
|
+
return (float *) p; /* W0793 */
|
74
|
+
}
|
75
|
+
"""
|
76
|
+
When I successfully run `adlint W0793.c` on noarch
|
77
|
+
Then the output should exactly match with:
|
78
|
+
| mesg | line | column |
|
79
|
+
| W0117 | 3 | 8 |
|
80
|
+
| W0793 | 5 | 12 |
|
81
|
+
| W0104 | 3 | 21 |
|
82
|
+
| W0628 | 3 | 8 |
|
83
|
+
|
84
|
+
Scenario: converting function pointer to `double *'
|
85
|
+
Given a target source named "W0793.c" with:
|
86
|
+
"""
|
87
|
+
typedef int (*funptr_t)(void);
|
88
|
+
|
89
|
+
double *foo(funptr_t p)
|
90
|
+
{
|
91
|
+
return (double *) p; /* W0793 */
|
92
|
+
}
|
93
|
+
"""
|
94
|
+
When I successfully run `adlint W0793.c` on noarch
|
95
|
+
Then the output should exactly match with:
|
96
|
+
| mesg | line | column |
|
97
|
+
| W0117 | 3 | 9 |
|
98
|
+
| W0793 | 5 | 12 |
|
99
|
+
| W0104 | 3 | 22 |
|
100
|
+
| W0628 | 3 | 9 |
|
101
|
+
|
102
|
+
Scenario: converting function pointer to `long double *'
|
103
|
+
Given a target source named "W0793.c" with:
|
104
|
+
"""
|
105
|
+
typedef int (*funptr_t)(void);
|
106
|
+
|
107
|
+
long double *foo(funptr_t p)
|
108
|
+
{
|
109
|
+
return (long double *) p; /* W0793 */
|
110
|
+
}
|
111
|
+
"""
|
112
|
+
When I successfully run `adlint W0793.c` on noarch
|
113
|
+
Then the output should exactly match with:
|
114
|
+
| mesg | line | column |
|
115
|
+
| W0117 | 3 | 14 |
|
116
|
+
| W0793 | 5 | 12 |
|
117
|
+
| W0104 | 3 | 27 |
|
118
|
+
| W0628 | 3 | 14 |
|
119
|
+
|
120
|
+
Scenario: converting `float *' to `int *'
|
121
|
+
Given a target source named "W0793.c" with:
|
122
|
+
"""
|
123
|
+
int *foo(float *p)
|
124
|
+
{
|
125
|
+
return (int *) p; /* OK */
|
126
|
+
}
|
127
|
+
"""
|
128
|
+
When I successfully run `adlint W0793.c` on noarch
|
129
|
+
Then the output should exactly match with:
|
130
|
+
| mesg | line | column |
|
131
|
+
| W0117 | 1 | 6 |
|
132
|
+
| W0104 | 1 | 17 |
|
133
|
+
| W0105 | 1 | 17 |
|
134
|
+
| W0628 | 1 | 6 |
|
135
|
+
|
136
|
+
Scenario: converting function pointer to `void *'
|
137
|
+
Given a target source named "W0793.c" with:
|
138
|
+
"""
|
139
|
+
typedef int (*funptr_t)(void);
|
140
|
+
|
141
|
+
void *foo(funptr_t p)
|
142
|
+
{
|
143
|
+
return (void *) p; /* OK */
|
144
|
+
}
|
145
|
+
"""
|
146
|
+
When I successfully run `adlint W0793.c` on noarch
|
147
|
+
Then the output should exactly match with:
|
148
|
+
| mesg | line | column |
|
149
|
+
| W0117 | 3 | 7 |
|
150
|
+
| W0104 | 3 | 20 |
|
151
|
+
| W0628 | 3 | 7 |
|
152
|
+
|
153
|
+
# vim:ts=2:sw=2:sts=2:et:
|
@@ -0,0 +1,90 @@
|
|
1
|
+
Feature: W0794
|
2
|
+
|
3
|
+
W0794 detects that a value of the signed integer variable is shifted to left.
|
4
|
+
|
5
|
+
Scenario: left shifting a `signed int' value
|
6
|
+
Given a target source named "W0794.c" with:
|
7
|
+
"""
|
8
|
+
int func(int i)
|
9
|
+
{
|
10
|
+
return i << 1; /* W0794 */
|
11
|
+
}
|
12
|
+
"""
|
13
|
+
When I successfully run `adlint W0794.c` on noarch
|
14
|
+
Then the output should exactly match with:
|
15
|
+
| mesg | line | column |
|
16
|
+
| W0117 | 1 | 5 |
|
17
|
+
| W0570 | 3 | 14 |
|
18
|
+
| W0572 | 3 | 14 |
|
19
|
+
| W0794 | 3 | 14 |
|
20
|
+
| W0104 | 1 | 14 |
|
21
|
+
| W0628 | 1 | 5 |
|
22
|
+
|
23
|
+
Scenario: right shifting a `signed int' value
|
24
|
+
Given a target source named "W0794.c" with:
|
25
|
+
"""
|
26
|
+
int func(int i)
|
27
|
+
{
|
28
|
+
return i >> 1; /* OK */
|
29
|
+
}
|
30
|
+
"""
|
31
|
+
When I successfully run `adlint W0794.c` on noarch
|
32
|
+
Then the output should exactly match with:
|
33
|
+
| mesg | line | column |
|
34
|
+
| W0117 | 1 | 5 |
|
35
|
+
| W0571 | 3 | 14 |
|
36
|
+
| W0572 | 3 | 14 |
|
37
|
+
| W0104 | 1 | 14 |
|
38
|
+
| W0628 | 1 | 5 |
|
39
|
+
|
40
|
+
Scenario: left shifting an `unsigned int' value
|
41
|
+
Given a target source named "W0794.c" with:
|
42
|
+
"""
|
43
|
+
unsigned int func(unsigned int ui)
|
44
|
+
{
|
45
|
+
return ui << 1; /* OK */
|
46
|
+
}
|
47
|
+
"""
|
48
|
+
When I successfully run `adlint W0794.c` on noarch
|
49
|
+
Then the output should exactly match with:
|
50
|
+
| mesg | line | column |
|
51
|
+
| W0117 | 1 | 14 |
|
52
|
+
| W0116 | 3 | 15 |
|
53
|
+
| W0104 | 1 | 32 |
|
54
|
+
| W0628 | 1 | 14 |
|
55
|
+
|
56
|
+
Scenario: left shifting a `signed int' constant
|
57
|
+
Given a target source named "W0794.c" with:
|
58
|
+
"""
|
59
|
+
int func(void)
|
60
|
+
{
|
61
|
+
return 123 << 1; /* OK */
|
62
|
+
}
|
63
|
+
"""
|
64
|
+
When I successfully run `adlint W0794.c` on noarch
|
65
|
+
Then the output should exactly match with:
|
66
|
+
| mesg | line | column |
|
67
|
+
| W0117 | 1 | 5 |
|
68
|
+
| W0572 | 3 | 16 |
|
69
|
+
| W0628 | 1 | 5 |
|
70
|
+
|
71
|
+
Scenario: left shifting an `unsigned char' value which will be
|
72
|
+
integer-promoted to `signed int'
|
73
|
+
Given a target source named "W0794.c" with:
|
74
|
+
"""
|
75
|
+
int func(unsigned char uc)
|
76
|
+
{
|
77
|
+
return uc << 1; /* OK */
|
78
|
+
}
|
79
|
+
"""
|
80
|
+
When I successfully run `adlint W0794.c` on noarch
|
81
|
+
Then the output should exactly match with:
|
82
|
+
| mesg | line | column |
|
83
|
+
| W0117 | 1 | 5 |
|
84
|
+
| W0123 | 3 | 12 |
|
85
|
+
| W0246 | 3 | 12 |
|
86
|
+
| W0116 | 3 | 15 |
|
87
|
+
| W0104 | 1 | 24 |
|
88
|
+
| W0628 | 1 | 5 |
|
89
|
+
|
90
|
+
# vim:ts=2:sw=2:sts=2:et:
|