adlint 1.10.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/ChangeLog +197 -4
  2. data/MANIFEST +17 -0
  3. data/NEWS +23 -4
  4. data/etc/mesg.d/en_US/messages.yml +14 -1
  5. data/etc/mesg.d/ja_JP/messages.yml +14 -1
  6. data/features/message_detection/W0093.feature +87 -0
  7. data/features/message_detection/W0687.feature +25 -0
  8. data/features/message_detection/W0688.feature +63 -0
  9. data/features/message_detection/W0689.feature +46 -0
  10. data/features/message_detection/W0690.feature +35 -0
  11. data/features/message_detection/W0698.feature +3 -2
  12. data/features/message_detection/W0703.feature +1 -0
  13. data/features/message_detection/W0723.feature +34 -0
  14. data/features/message_detection/W0732.feature +158 -0
  15. data/features/message_detection/W0733.feature +158 -0
  16. data/features/message_detection/W0734.feature +322 -0
  17. data/features/message_detection/W0735.feature +322 -0
  18. data/features/message_detection/W1052.feature +66 -0
  19. data/features/message_detection/W9001.feature +33 -0
  20. data/features/message_detection/W9003.feature +131 -0
  21. data/lib/adlint/c/ctrlexpr.rb +51 -50
  22. data/lib/adlint/c/domain.rb +237 -223
  23. data/lib/adlint/c/expr.rb +6 -8
  24. data/lib/adlint/c/interp.rb +8 -11
  25. data/lib/adlint/c/message.rb +20 -0
  26. data/lib/adlint/c/message_shima.rb +63 -0
  27. data/lib/adlint/c/object.rb +5 -4
  28. data/lib/adlint/c/operator.rb +99 -0
  29. data/lib/adlint/c/parser.rb +2 -2
  30. data/lib/adlint/c/parser.y +2 -2
  31. data/lib/adlint/c/phase.rb +6 -1
  32. data/lib/adlint/c/syntax.rb +442 -30
  33. data/lib/adlint/c/type.rb +449 -363
  34. data/lib/adlint/c/value.rb +96 -25
  35. data/lib/adlint/c.rb +1 -0
  36. data/lib/adlint/prelude.rb +16 -18
  37. data/lib/adlint/version.rb +2 -2
  38. data/share/doc/developers_guide_ja.html +11 -5
  39. data/share/doc/developers_guide_ja.texi +9 -3
  40. data/share/doc/users_guide_en.html +697 -131
  41. data/share/doc/users_guide_en.texi +491 -41
  42. data/share/doc/users_guide_ja.html +709 -139
  43. data/share/doc/users_guide_ja.texi +499 -45
  44. data/spec/adlint/c/ctrlexpr_spec.rb +168 -0
  45. data/spec/adlint/c/domain_spec.rb +835 -0
  46. data/spec/adlint/c/operator_spec.rb +406 -0
  47. data/spec/adlint/c/syntax_spec.rb +717 -0
  48. data/spec/adlint/c/type_spec.rb +55 -30
  49. metadata +19 -2
@@ -14,5 +14,39 @@ Feature: W0723
14
14
  | mesg | line | column |
15
15
  | W0567 | 2 | 25 |
16
16
  | W0167 | 2 | 45 |
17
+ | W9003 | 2 | 45 |
18
+
19
+ Scenario: multiplication of two arbitrary `signed short' values
20
+ Given a target source named "W0723.c" with:
21
+ """
22
+ static int foo(short a, short b)
23
+ {
24
+ return a * b; /* W0723 should not be output */
25
+ }
26
+ """
27
+ When I successfully run `adlint W0723.c` on noarch
28
+ Then the output should exactly match with:
29
+ | mesg | line | column |
30
+ | W0104 | 1 | 22 |
31
+ | W0104 | 1 | 31 |
32
+ | W0629 | 1 | 12 |
33
+ | W0628 | 1 | 12 |
34
+
35
+ Scenario: multiplication of two arbitrary `signed int' values
36
+ Given a target source named "W0723.c" with:
37
+ """
38
+ static int foo(int a, int b)
39
+ {
40
+ return a * b; /* W0723 */
41
+ }
42
+ """
43
+ When I successfully run `adlint W0723.c` on noarch
44
+ Then the output should exactly match with:
45
+ | mesg | line | column |
46
+ | W0723 | 3 | 14 |
47
+ | W0104 | 1 | 20 |
48
+ | W0104 | 1 | 27 |
49
+ | W0629 | 1 | 12 |
50
+ | W0628 | 1 | 12 |
17
51
 
18
52
  # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,158 @@
1
+ Feature: W0732
2
+
3
+ W0732 detects that both sides of `&&' operator are bitwise expression or
4
+ arithmetic expression.
5
+
6
+ Scenario: both sides of `&&' operator are arithmetic expressions
7
+ Given a target source named "W0732.c" with:
8
+ """
9
+ static void func(int a, int b, int c, int d)
10
+ {
11
+ int r;
12
+
13
+ r = (a + b) && (c + d); /* W0732 */
14
+ r = (a - b) && (c - d); /* W0732 */
15
+ r = (a * b) && (c * d); /* W0732 */
16
+ r = (a / b) && (c / d); /* W0732 */
17
+ r = (a % b) && (c % d); /* W0732 */
18
+
19
+ r = (a += b) && (c -= d); /* W0732 */
20
+ r = (a *= b) && (c /= d); /* W0732 */
21
+ }
22
+ """
23
+ When I successfully run `adlint W0732.c` on noarch
24
+ Then the output should exactly match with:
25
+ | mesg | line | column |
26
+ | W0723 | 5 | 12 |
27
+ | W0723 | 5 | 23 |
28
+ | W0723 | 6 | 12 |
29
+ | W0723 | 6 | 23 |
30
+ | W0723 | 7 | 12 |
31
+ | W0723 | 7 | 23 |
32
+ | W0093 | 8 | 12 |
33
+ | W0093 | 8 | 23 |
34
+ | W0093 | 9 | 12 |
35
+ | W0093 | 9 | 23 |
36
+ | W0093 | 12 | 12 |
37
+ | W0093 | 12 | 24 |
38
+ | W0104 | 1 | 29 |
39
+ | W0104 | 1 | 43 |
40
+ | W0629 | 1 | 13 |
41
+ | W0088 | 5 | 17 |
42
+ | W0732 | 5 | 17 |
43
+ | W0088 | 6 | 17 |
44
+ | W0732 | 6 | 17 |
45
+ | W0088 | 7 | 17 |
46
+ | W0732 | 7 | 17 |
47
+ | W0088 | 8 | 17 |
48
+ | W0732 | 8 | 17 |
49
+ | W0088 | 9 | 17 |
50
+ | W0732 | 9 | 17 |
51
+ | W0508 | 11 | 18 |
52
+ | W0732 | 11 | 18 |
53
+ | W0508 | 12 | 18 |
54
+ | W0732 | 12 | 18 |
55
+ | W0108 | 11 | 12 |
56
+ | W0108 | 11 | 24 |
57
+ | W0108 | 12 | 12 |
58
+ | W0108 | 12 | 24 |
59
+ | W0628 | 1 | 13 |
60
+
61
+ Scenario: both sides of `&&' operator are bitwise expressions
62
+ Given a target source named "W0732.c" with:
63
+ """
64
+ static void func(int a, int b, int c, int d)
65
+ {
66
+ int r;
67
+
68
+ r = (a << b) && (c << d); /* W0732 */
69
+ r = (a >> b) && (c >> d); /* W0732 */
70
+ r = (a & b) && (c & d); /* W0732 */
71
+ r = (a ^ b) && (c ^ d); /* W0732 */
72
+ r = (a | b) && (c | d); /* W0732 */
73
+
74
+ r = (a &= b) && (c ^= d); /* W0732 */
75
+ r = (a <<= b) && (c >>= d); /* W0732 */
76
+ }
77
+ """
78
+ When I successfully run `adlint W0732.c` on noarch
79
+ Then the output should exactly match with:
80
+ | mesg | line | column |
81
+ | W0570 | 5 | 12 |
82
+ | W0572 | 5 | 12 |
83
+ | W0570 | 5 | 24 |
84
+ | W0572 | 5 | 24 |
85
+ | W0571 | 6 | 12 |
86
+ | W0572 | 6 | 12 |
87
+ | W0571 | 6 | 24 |
88
+ | W0572 | 6 | 24 |
89
+ | W0572 | 7 | 12 |
90
+ | W0572 | 7 | 23 |
91
+ | W0572 | 8 | 12 |
92
+ | W0572 | 8 | 23 |
93
+ | W0572 | 9 | 12 |
94
+ | W0572 | 9 | 23 |
95
+ | W0572 | 11 | 12 |
96
+ | W0572 | 11 | 24 |
97
+ | W0570 | 12 | 12 |
98
+ | W0572 | 12 | 12 |
99
+ | W0571 | 12 | 25 |
100
+ | W0572 | 12 | 25 |
101
+ | W0104 | 1 | 29 |
102
+ | W0104 | 1 | 43 |
103
+ | W0629 | 1 | 13 |
104
+ | W0088 | 5 | 18 |
105
+ | W0732 | 5 | 18 |
106
+ | W0088 | 6 | 18 |
107
+ | W0732 | 6 | 18 |
108
+ | W0088 | 7 | 17 |
109
+ | W0732 | 7 | 17 |
110
+ | W0088 | 8 | 17 |
111
+ | W0732 | 8 | 17 |
112
+ | W0088 | 9 | 17 |
113
+ | W0732 | 9 | 17 |
114
+ | W0508 | 11 | 18 |
115
+ | W0732 | 11 | 18 |
116
+ | W0508 | 12 | 19 |
117
+ | W0732 | 12 | 19 |
118
+ | W0108 | 11 | 12 |
119
+ | W0108 | 11 | 24 |
120
+ | W0108 | 12 | 12 |
121
+ | W0108 | 12 | 25 |
122
+ | W0628 | 1 | 13 |
123
+
124
+ Scenario: both sides of `&&' operator are neither arithmetic nor bitwise
125
+ Given a target source named "W0732.c" with:
126
+ """
127
+ static void func(int a, int b, int c, int d)
128
+ {
129
+ int r;
130
+
131
+ /* equality expression */
132
+ r = (a == b) && (c != d); /* OK */
133
+
134
+ /* relational expression */
135
+ r = (a < b) && (c > d); /* OK */
136
+ r = (a <= b) && (c >= d); /* OK */
137
+
138
+ /* logical expression */
139
+ r = (a && b) && (c && d); /* OK */
140
+ r = (a || b) && (c || d); /* OK */
141
+ }
142
+ """
143
+ When I successfully run `adlint W0732.c` on noarch
144
+ Then the output should exactly match with:
145
+ | mesg | line | column |
146
+ | W0104 | 1 | 22 |
147
+ | W0104 | 1 | 29 |
148
+ | W0104 | 1 | 36 |
149
+ | W0104 | 1 | 43 |
150
+ | W0629 | 1 | 13 |
151
+ | W0088 | 6 | 18 |
152
+ | W0088 | 9 | 17 |
153
+ | W0088 | 10 | 18 |
154
+ | W0088 | 13 | 18 |
155
+ | W0088 | 14 | 18 |
156
+ | W0628 | 1 | 13 |
157
+
158
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,158 @@
1
+ Feature: W0733
2
+
3
+ W0733 detects that both sides of `||' operator are bitwise expression or
4
+ arithmetic expression.
5
+
6
+ Scenario: both sides of `||' operator are arithmetic expressions
7
+ Given a target source named "W0733.c" with:
8
+ """
9
+ static void func(int a, int b, int c, int d)
10
+ {
11
+ int r;
12
+
13
+ r = (a + b) || (c + d); /* W0733 */
14
+ r = (a - b) || (c - d); /* W0733 */
15
+ r = (a * b) || (c * d); /* W0733 */
16
+ r = (a / b) || (c / d); /* W0733 */
17
+ r = (a % b) || (c % d); /* W0733 */
18
+
19
+ r = (a += b) || (c -= d); /* W0733 */
20
+ r = (a *= b) || (c /= d); /* W0733 */
21
+ }
22
+ """
23
+ When I successfully run `adlint W0733.c` on noarch
24
+ Then the output should exactly match with:
25
+ | mesg | line | column |
26
+ | W0723 | 5 | 12 |
27
+ | W0723 | 5 | 23 |
28
+ | W0723 | 6 | 12 |
29
+ | W0723 | 6 | 23 |
30
+ | W0723 | 7 | 12 |
31
+ | W0723 | 7 | 23 |
32
+ | W0093 | 8 | 12 |
33
+ | W0093 | 8 | 23 |
34
+ | W0093 | 9 | 12 |
35
+ | W0093 | 9 | 23 |
36
+ | W0093 | 12 | 12 |
37
+ | W0093 | 12 | 24 |
38
+ | W0104 | 1 | 29 |
39
+ | W0104 | 1 | 43 |
40
+ | W0629 | 1 | 13 |
41
+ | W0088 | 5 | 17 |
42
+ | W0733 | 5 | 17 |
43
+ | W0088 | 6 | 17 |
44
+ | W0733 | 6 | 17 |
45
+ | W0088 | 7 | 17 |
46
+ | W0733 | 7 | 17 |
47
+ | W0088 | 8 | 17 |
48
+ | W0733 | 8 | 17 |
49
+ | W0088 | 9 | 17 |
50
+ | W0733 | 9 | 17 |
51
+ | W0508 | 11 | 18 |
52
+ | W0733 | 11 | 18 |
53
+ | W0508 | 12 | 18 |
54
+ | W0733 | 12 | 18 |
55
+ | W0108 | 11 | 12 |
56
+ | W0108 | 11 | 24 |
57
+ | W0108 | 12 | 12 |
58
+ | W0108 | 12 | 24 |
59
+ | W0628 | 1 | 13 |
60
+
61
+ Scenario: both sides of `&&' operator are bitwise expressions
62
+ Given a target source named "W0733.c" with:
63
+ """
64
+ static void func(int a, int b, int c, int d)
65
+ {
66
+ int r;
67
+
68
+ r = (a << b) || (c << d); /* W0733 */
69
+ r = (a >> b) || (c >> d); /* W0733 */
70
+ r = (a & b) || (c & d); /* W0733 */
71
+ r = (a ^ b) || (c ^ d); /* W0733 */
72
+ r = (a | b) || (c | d); /* W0733 */
73
+
74
+ r = (a &= b) || (c ^= d); /* W0733 */
75
+ r = (a <<= b) || (c >>= d); /* W0733 */
76
+ }
77
+ """
78
+ When I successfully run `adlint W0733.c` on noarch
79
+ Then the output should exactly match with:
80
+ | mesg | line | column |
81
+ | W0570 | 5 | 12 |
82
+ | W0572 | 5 | 12 |
83
+ | W0570 | 5 | 24 |
84
+ | W0572 | 5 | 24 |
85
+ | W0571 | 6 | 12 |
86
+ | W0572 | 6 | 12 |
87
+ | W0571 | 6 | 24 |
88
+ | W0572 | 6 | 24 |
89
+ | W0572 | 7 | 12 |
90
+ | W0572 | 7 | 23 |
91
+ | W0572 | 8 | 12 |
92
+ | W0572 | 8 | 23 |
93
+ | W0572 | 9 | 12 |
94
+ | W0572 | 9 | 23 |
95
+ | W0572 | 11 | 12 |
96
+ | W0572 | 11 | 24 |
97
+ | W0570 | 12 | 12 |
98
+ | W0572 | 12 | 12 |
99
+ | W0571 | 12 | 25 |
100
+ | W0572 | 12 | 25 |
101
+ | W0104 | 1 | 29 |
102
+ | W0104 | 1 | 43 |
103
+ | W0629 | 1 | 13 |
104
+ | W0088 | 5 | 18 |
105
+ | W0733 | 5 | 18 |
106
+ | W0088 | 6 | 18 |
107
+ | W0733 | 6 | 18 |
108
+ | W0088 | 7 | 17 |
109
+ | W0733 | 7 | 17 |
110
+ | W0088 | 8 | 17 |
111
+ | W0733 | 8 | 17 |
112
+ | W0088 | 9 | 17 |
113
+ | W0733 | 9 | 17 |
114
+ | W0508 | 11 | 18 |
115
+ | W0733 | 11 | 18 |
116
+ | W0508 | 12 | 19 |
117
+ | W0733 | 12 | 19 |
118
+ | W0108 | 11 | 12 |
119
+ | W0108 | 11 | 24 |
120
+ | W0108 | 12 | 12 |
121
+ | W0108 | 12 | 25 |
122
+ | W0628 | 1 | 13 |
123
+
124
+ Scenario: both sides of `||' operator are neither arithmetic nor bitwise
125
+ Given a target source named "W0733.c" with:
126
+ """
127
+ static void func(int a, int b, int c, int d)
128
+ {
129
+ int r;
130
+
131
+ /* equality expression */
132
+ r = (a == b) || (c != d); /* OK */
133
+
134
+ /* relational expression */
135
+ r = (a < b) || (c > d); /* OK */
136
+ r = (a <= b) || (c >= d); /* OK */
137
+
138
+ /* logical expression */
139
+ r = (a && b) || (c && d); /* OK */
140
+ r = (a || b) || (c || d); /* OK */
141
+ }
142
+ """
143
+ When I successfully run `adlint W0733.c` on noarch
144
+ Then the output should exactly match with:
145
+ | mesg | line | column |
146
+ | W0104 | 1 | 22 |
147
+ | W0104 | 1 | 29 |
148
+ | W0104 | 1 | 36 |
149
+ | W0104 | 1 | 43 |
150
+ | W0629 | 1 | 13 |
151
+ | W0088 | 6 | 18 |
152
+ | W0088 | 9 | 17 |
153
+ | W0088 | 10 | 18 |
154
+ | W0088 | 13 | 18 |
155
+ | W0088 | 14 | 18 |
156
+ | W0628 | 1 | 13 |
157
+
158
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,322 @@
1
+ Feature: W0734
2
+
3
+ W0734 detects that left side of logical expression is bitwise expression or
4
+ arithmetic expression.
5
+
6
+ Scenario: left side of `&&' operator is an arithmetic expression
7
+ Given a target source named "W0734.c" with:
8
+ """
9
+ static void func(int a, int b, int c)
10
+ {
11
+ int r;
12
+
13
+ r = (a + b) && c; /* W0734 */
14
+ r = (a - b) && c; /* W0734 */
15
+ r = (a * b) && c; /* W0734 */
16
+ r = (a / b) && c; /* W0734 */
17
+ r = (a % b) && c; /* W0734 */
18
+ }
19
+ """
20
+ When I successfully run `adlint W0734.c` on noarch
21
+ Then the output should exactly match with:
22
+ | mesg | line | column |
23
+ | W0723 | 5 | 12 |
24
+ | W0723 | 6 | 12 |
25
+ | W0723 | 7 | 12 |
26
+ | W0093 | 8 | 12 |
27
+ | W0093 | 9 | 12 |
28
+ | W0104 | 1 | 22 |
29
+ | W0104 | 1 | 29 |
30
+ | W0104 | 1 | 36 |
31
+ | W0629 | 1 | 13 |
32
+ | W0088 | 5 | 17 |
33
+ | W0734 | 5 | 9 |
34
+ | W0088 | 6 | 17 |
35
+ | W0734 | 6 | 9 |
36
+ | W0088 | 7 | 17 |
37
+ | W0734 | 7 | 9 |
38
+ | W0088 | 8 | 17 |
39
+ | W0734 | 8 | 9 |
40
+ | W0088 | 9 | 17 |
41
+ | W0734 | 9 | 9 |
42
+ | W0628 | 1 | 13 |
43
+
44
+ Scenario: left side of `&&' operator is an arithmetic expression
45
+ Given a target source named "W0734.c" with:
46
+ """
47
+ static void func(int a, int b, int c, int d)
48
+ {
49
+ int r;
50
+
51
+ r = (a + b) && (c == d); /* W0734 */
52
+ r = (a - b) && (c = d); /* W0734 */
53
+ r = (a * b) && (c && d); /* W0734 */
54
+ r = (a / b) && (c < d); /* W0734 */
55
+ r = (a / b) && (c != d); /* W0734 */
56
+ }
57
+ """
58
+ When I successfully run `adlint W0734.c` on noarch
59
+ Then the output should exactly match with:
60
+ | mesg | line | column |
61
+ | W0723 | 5 | 12 |
62
+ | W0723 | 6 | 12 |
63
+ | W0723 | 7 | 12 |
64
+ | W0093 | 8 | 12 |
65
+ | W0093 | 9 | 12 |
66
+ | W0104 | 1 | 22 |
67
+ | W0104 | 1 | 29 |
68
+ | W0104 | 1 | 43 |
69
+ | W0629 | 1 | 13 |
70
+ | W0088 | 5 | 17 |
71
+ | W0734 | 5 | 9 |
72
+ | W0508 | 6 | 17 |
73
+ | W0734 | 6 | 9 |
74
+ | W0088 | 7 | 17 |
75
+ | W0734 | 7 | 9 |
76
+ | W0088 | 8 | 17 |
77
+ | W0734 | 8 | 9 |
78
+ | W0088 | 9 | 17 |
79
+ | W0734 | 9 | 9 |
80
+ | W0108 | 6 | 23 |
81
+ | W0628 | 1 | 13 |
82
+
83
+ Scenario: left side of `||' operator is an arithmetic expression
84
+ Given a target source named "W0734.c" with:
85
+ """
86
+ static void func(int a, int b, int c)
87
+ {
88
+ int r;
89
+
90
+ r = (a + b) || c; /* W0734 */
91
+ r = (a - b) || c; /* W0734 */
92
+ r = (a * b) || c; /* W0734 */
93
+ r = (a / b) || c; /* W0734 */
94
+ r = (a % b) || c; /* W0734 */
95
+ }
96
+ """
97
+ When I successfully run `adlint W0734.c` on noarch
98
+ Then the output should exactly match with:
99
+ | mesg | line | column |
100
+ | W0723 | 5 | 12 |
101
+ | W0723 | 6 | 12 |
102
+ | W0723 | 7 | 12 |
103
+ | W0093 | 8 | 12 |
104
+ | W0093 | 9 | 12 |
105
+ | W0104 | 1 | 22 |
106
+ | W0104 | 1 | 29 |
107
+ | W0104 | 1 | 36 |
108
+ | W0629 | 1 | 13 |
109
+ | W0088 | 5 | 17 |
110
+ | W0734 | 5 | 9 |
111
+ | W0088 | 6 | 17 |
112
+ | W0734 | 6 | 9 |
113
+ | W0088 | 7 | 17 |
114
+ | W0734 | 7 | 9 |
115
+ | W0088 | 8 | 17 |
116
+ | W0734 | 8 | 9 |
117
+ | W0088 | 9 | 17 |
118
+ | W0734 | 9 | 9 |
119
+ | W0628 | 1 | 13 |
120
+
121
+ Scenario: left side of `||' operator is an arithmetic expression
122
+ Given a target source named "W0734.c" with:
123
+ """
124
+ static void func(int a, int b, int c, int d)
125
+ {
126
+ int r;
127
+
128
+ r = (a + b) || (c == d); /* W0734 */
129
+ r = (a - b) || (c = d); /* W0734 */
130
+ r = (a * b) || (c || d); /* W0734 */
131
+ r = (a / b) || (c < d); /* W0734 */
132
+ r = (a / b) || (c != d); /* W0734 */
133
+ }
134
+ """
135
+ When I successfully run `adlint W0734.c` on noarch
136
+ Then the output should exactly match with:
137
+ | mesg | line | column |
138
+ | W0723 | 5 | 12 |
139
+ | W0723 | 6 | 12 |
140
+ | W0723 | 7 | 12 |
141
+ | W0093 | 8 | 12 |
142
+ | W0093 | 9 | 12 |
143
+ | W0104 | 1 | 22 |
144
+ | W0104 | 1 | 29 |
145
+ | W0104 | 1 | 43 |
146
+ | W0629 | 1 | 13 |
147
+ | W0088 | 5 | 17 |
148
+ | W0734 | 5 | 9 |
149
+ | W0508 | 6 | 17 |
150
+ | W0734 | 6 | 9 |
151
+ | W0088 | 7 | 17 |
152
+ | W0734 | 7 | 9 |
153
+ | W0088 | 8 | 17 |
154
+ | W0734 | 8 | 9 |
155
+ | W0088 | 9 | 17 |
156
+ | W0734 | 9 | 9 |
157
+ | W0108 | 6 | 23 |
158
+ | W0628 | 1 | 13 |
159
+
160
+ Scenario: left side of `&&' operator is a bitwise expression
161
+ Given a target source named "W0734.c" with:
162
+ """
163
+ static void func(int a, int b, int c)
164
+ {
165
+ int r;
166
+
167
+ r = (a << b) && c; /* W0734 */
168
+ r = (a >> b) && c; /* W0734 */
169
+ r = (a & b) && c; /* W0734 */
170
+ r = (a ^ b) && c; /* W0734 */
171
+ r = (a | b) && c; /* W0734 */
172
+ }
173
+ """
174
+ When I successfully run `adlint W0734.c` on noarch
175
+ Then the output should exactly match with:
176
+ | mesg | line | column |
177
+ | W0570 | 5 | 12 |
178
+ | W0572 | 5 | 12 |
179
+ | W0571 | 6 | 12 |
180
+ | W0572 | 6 | 12 |
181
+ | W0572 | 7 | 12 |
182
+ | W0572 | 8 | 12 |
183
+ | W0572 | 9 | 12 |
184
+ | W0104 | 1 | 22 |
185
+ | W0104 | 1 | 29 |
186
+ | W0104 | 1 | 36 |
187
+ | W0629 | 1 | 13 |
188
+ | W0088 | 5 | 18 |
189
+ | W0734 | 5 | 9 |
190
+ | W0088 | 6 | 18 |
191
+ | W0734 | 6 | 9 |
192
+ | W0088 | 7 | 17 |
193
+ | W0734 | 7 | 9 |
194
+ | W0088 | 8 | 17 |
195
+ | W0734 | 8 | 9 |
196
+ | W0088 | 9 | 17 |
197
+ | W0734 | 9 | 9 |
198
+ | W0628 | 1 | 13 |
199
+
200
+ Scenario: left side of `||' operator is a bitwise expression
201
+ Given a target source named "W0734.c" with:
202
+ """
203
+ static void func(int a, int b, int c)
204
+ {
205
+ int r;
206
+
207
+ r = (a << b) || c; /* W0734 */
208
+ r = (a >> b) || c; /* W0734 */
209
+ r = (a & b) || c; /* W0734 */
210
+ r = (a ^ b) || c; /* W0734 */
211
+ r = (a | b) || c; /* W0734 */
212
+ }
213
+ """
214
+ When I successfully run `adlint W0734.c` on noarch
215
+ Then the output should exactly match with:
216
+ | mesg | line | column |
217
+ | W0570 | 5 | 12 |
218
+ | W0572 | 5 | 12 |
219
+ | W0571 | 6 | 12 |
220
+ | W0572 | 6 | 12 |
221
+ | W0572 | 7 | 12 |
222
+ | W0572 | 8 | 12 |
223
+ | W0572 | 9 | 12 |
224
+ | W0104 | 1 | 22 |
225
+ | W0104 | 1 | 29 |
226
+ | W0104 | 1 | 36 |
227
+ | W0629 | 1 | 13 |
228
+ | W0088 | 5 | 18 |
229
+ | W0734 | 5 | 9 |
230
+ | W0088 | 6 | 18 |
231
+ | W0734 | 6 | 9 |
232
+ | W0088 | 7 | 17 |
233
+ | W0734 | 7 | 9 |
234
+ | W0088 | 8 | 17 |
235
+ | W0734 | 8 | 9 |
236
+ | W0088 | 9 | 17 |
237
+ | W0734 | 9 | 9 |
238
+ | W0628 | 1 | 13 |
239
+
240
+ Scenario: left side of `&&' operator is a bitwise expression
241
+ Given a target source named "W0734.c" with:
242
+ """
243
+ static void func(int a, int b, int c, int d)
244
+ {
245
+ int r;
246
+
247
+ r = (a << b) && (c == d); /* W0734 */
248
+ r = (a >> b) && (c = d); /* W0734 */
249
+ r = (a & b) && (c && d); /* W0734 */
250
+ r = (a ^ b) && (c < d); /* W0734 */
251
+ r = (a | b) && (c != d); /* W0734 */
252
+ }
253
+ """
254
+ When I successfully run `adlint W0734.c` on noarch
255
+ Then the output should exactly match with:
256
+ | mesg | line | column |
257
+ | W0570 | 5 | 12 |
258
+ | W0572 | 5 | 12 |
259
+ | W0571 | 6 | 12 |
260
+ | W0572 | 6 | 12 |
261
+ | W0572 | 7 | 12 |
262
+ | W0572 | 8 | 12 |
263
+ | W0572 | 9 | 12 |
264
+ | W0104 | 1 | 22 |
265
+ | W0104 | 1 | 29 |
266
+ | W0104 | 1 | 43 |
267
+ | W0629 | 1 | 13 |
268
+ | W0088 | 5 | 18 |
269
+ | W0734 | 5 | 9 |
270
+ | W0508 | 6 | 18 |
271
+ | W0734 | 6 | 9 |
272
+ | W0088 | 7 | 17 |
273
+ | W0734 | 7 | 9 |
274
+ | W0088 | 8 | 17 |
275
+ | W0734 | 8 | 9 |
276
+ | W0088 | 9 | 17 |
277
+ | W0734 | 9 | 9 |
278
+ | W0108 | 6 | 24 |
279
+ | W0628 | 1 | 13 |
280
+
281
+ Scenario: left side of `||' operator is a bitwise expression
282
+ Given a target source named "W0734.c" with:
283
+ """
284
+ static void func(int a, int b, int c, int d)
285
+ {
286
+ int r;
287
+
288
+ r = (a << b) || (c == d); /* W0734 */
289
+ r = (a >> b) || (c = d); /* W0734 */
290
+ r = (a & b) || (c && d); /* W0734 */
291
+ r = (a ^ b) || (c < d); /* W0734 */
292
+ r = (a | b) || (c != d); /* W0734 */
293
+ }
294
+ """
295
+ When I successfully run `adlint W0734.c` on noarch
296
+ Then the output should exactly match with:
297
+ | mesg | line | column |
298
+ | W0570 | 5 | 12 |
299
+ | W0572 | 5 | 12 |
300
+ | W0571 | 6 | 12 |
301
+ | W0572 | 6 | 12 |
302
+ | W0572 | 7 | 12 |
303
+ | W0572 | 8 | 12 |
304
+ | W0572 | 9 | 12 |
305
+ | W0104 | 1 | 22 |
306
+ | W0104 | 1 | 29 |
307
+ | W0104 | 1 | 43 |
308
+ | W0629 | 1 | 13 |
309
+ | W0088 | 5 | 18 |
310
+ | W0734 | 5 | 9 |
311
+ | W0508 | 6 | 18 |
312
+ | W0734 | 6 | 9 |
313
+ | W0088 | 7 | 17 |
314
+ | W0734 | 7 | 9 |
315
+ | W0088 | 8 | 17 |
316
+ | W0734 | 8 | 9 |
317
+ | W0088 | 9 | 17 |
318
+ | W0734 | 9 | 9 |
319
+ | W0108 | 6 | 24 |
320
+ | W0628 | 1 | 13 |
321
+
322
+ # vim:ts=2:sw=2:sts=2:et: