adlint 2.4.6 → 2.4.10
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 +163 -0
- data/MANIFEST +12 -0
- data/NEWS +20 -4
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +2 -2
- data/etc/mesg.d/c_builtin/en_US/messages.yml +1 -1
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +1 -1
- data/etc/mesg.d/core/en_US/messages.yml +1 -1
- data/etc/mesg.d/core/ja_JP/messages.yml +1 -1
- data/features/code_check/E0013.feature +0 -2
- data/features/code_check/W0001.feature +0 -2
- data/features/code_check/W0002.feature +0 -2
- data/features/code_check/W0003.feature +0 -2
- data/features/code_check/W0007.feature +0 -2
- data/features/code_check/W0010.feature +1 -3
- data/features/code_check/W0013.feature +0 -2
- data/features/code_check/W0016.feature +0 -2
- data/features/code_check/W0017.feature +0 -2
- data/features/code_check/W0025.feature +0 -2
- data/features/code_check/W0026.feature +0 -2
- data/features/code_check/W0070.feature +0 -2
- data/features/code_check/W0071.feature +0 -2
- data/features/code_check/W0093.feature +0 -2
- data/features/code_check/W0104.feature +0 -2
- data/features/code_check/W0109.feature +0 -2
- data/features/code_check/W0119.feature +0 -2
- data/features/code_check/W0120.feature +0 -2
- data/features/code_check/W0121.feature +0 -2
- data/features/code_check/W0122.feature +0 -2
- data/features/code_check/W0123.feature +0 -2
- data/features/code_check/W0124.feature +0 -2
- data/features/code_check/W0125.feature +0 -2
- data/features/code_check/W0126.feature +0 -2
- data/features/code_check/W0127.feature +0 -2
- data/features/code_check/W0128.feature +0 -2
- data/features/code_check/W0129.feature +0 -2
- data/features/code_check/W0130.feature +0 -2
- data/features/code_check/W0131.feature +0 -2
- data/features/code_check/W0132.feature +0 -2
- data/features/code_check/W0133.feature +0 -2
- data/features/code_check/W0134.feature +0 -2
- data/features/code_check/W0135.feature +0 -2
- data/features/code_check/W0136.feature +0 -2
- data/features/code_check/W0137.feature +0 -2
- data/features/code_check/W0138.feature +0 -2
- data/features/code_check/W0139.feature +0 -2
- data/features/code_check/W0140.feature +0 -2
- data/features/code_check/W0141.feature +0 -2
- data/features/code_check/W0142.feature +0 -2
- data/features/code_check/W0143.feature +0 -2
- data/features/code_check/W0144.feature +0 -2
- data/features/code_check/W0145.feature +0 -2
- data/features/code_check/W0146.feature +0 -2
- data/features/code_check/W0147.feature +0 -2
- data/features/code_check/W0148.feature +0 -2
- data/features/code_check/W0149.feature +0 -2
- data/features/code_check/W0150.feature +0 -2
- data/features/code_check/W0151.feature +0 -2
- data/features/code_check/W0152.feature +0 -2
- data/features/code_check/W0153.feature +0 -2
- data/features/code_check/W0154.feature +0 -2
- data/features/code_check/W0155.feature +0 -2
- data/features/code_check/W0156.feature +0 -2
- data/features/code_check/W0157.feature +0 -2
- data/features/code_check/W0158.feature +0 -2
- data/features/code_check/W0159.feature +0 -2
- data/features/code_check/W0160.feature +0 -2
- data/features/code_check/W0161.feature +0 -2
- data/features/code_check/W0162.feature +0 -2
- data/features/code_check/W0163.feature +0 -2
- data/features/code_check/W0164.feature +0 -2
- data/features/code_check/W0165.feature +0 -2
- data/features/code_check/W0166.feature +0 -2
- data/features/code_check/W0167.feature +0 -2
- data/features/code_check/W0168.feature +0 -2
- data/features/code_check/W0169.feature +0 -2
- data/features/code_check/W0170.feature +0 -2
- data/features/code_check/W0171.feature +0 -2
- data/features/code_check/W0172.feature +0 -2
- data/features/code_check/W0173.feature +0 -2
- data/features/code_check/W0174.feature +0 -2
- data/features/code_check/W0175.feature +0 -2
- data/features/code_check/W0176.feature +0 -2
- data/features/code_check/W0177.feature +0 -2
- data/features/code_check/W0178.feature +0 -2
- data/features/code_check/W0179.feature +0 -2
- data/features/code_check/W0180.feature +0 -2
- data/features/code_check/W0181.feature +0 -2
- data/features/code_check/W0182.feature +0 -2
- data/features/code_check/W0183.feature +0 -2
- data/features/code_check/W0184.feature +0 -2
- data/features/code_check/W0185.feature +0 -2
- data/features/code_check/W0186.feature +0 -2
- data/features/code_check/W0187.feature +0 -2
- data/features/code_check/W0188.feature +0 -2
- data/features/code_check/W0189.feature +0 -2
- data/features/code_check/W0190.feature +0 -2
- data/features/code_check/W0191.feature +0 -2
- data/features/code_check/W0192.feature +0 -2
- data/features/code_check/W0193.feature +0 -2
- data/features/code_check/W0194.feature +0 -2
- data/features/code_check/W0195.feature +0 -2
- data/features/code_check/W0196.feature +0 -2
- data/features/code_check/W0197.feature +0 -2
- data/features/code_check/W0198.feature +0 -2
- data/features/code_check/W0199.feature +0 -2
- data/features/code_check/W0200.feature +0 -2
- data/features/code_check/W0201.feature +0 -2
- data/features/code_check/W0202.feature +0 -2
- data/features/code_check/W0203.feature +0 -2
- data/features/code_check/W0204.feature +0 -2
- data/features/code_check/W0205.feature +0 -2
- data/features/code_check/W0206.feature +0 -2
- data/features/code_check/W0207.feature +0 -2
- data/features/code_check/W0208.feature +0 -2
- data/features/code_check/W0209.feature +0 -2
- data/features/code_check/W0210.feature +0 -2
- data/features/code_check/W0211.feature +0 -2
- data/features/code_check/W0212.feature +0 -2
- data/features/code_check/W0213.feature +0 -2
- data/features/code_check/W0214.feature +0 -2
- data/features/code_check/W0215.feature +0 -2
- data/features/code_check/W0216.feature +0 -2
- data/features/code_check/W0217.feature +0 -2
- data/features/code_check/W0218.feature +0 -2
- data/features/code_check/W0219.feature +0 -2
- data/features/code_check/W0220.feature +0 -2
- data/features/code_check/W0221.feature +0 -2
- data/features/code_check/W0222.feature +0 -2
- data/features/code_check/W0223.feature +0 -2
- data/features/code_check/W0224.feature +0 -2
- data/features/code_check/W0225.feature +0 -2
- data/features/code_check/W0226.feature +0 -2
- data/features/code_check/W0227.feature +0 -2
- data/features/code_check/W0228.feature +0 -2
- data/features/code_check/W0229.feature +0 -2
- data/features/code_check/W0230.feature +0 -2
- data/features/code_check/W0231.feature +0 -2
- data/features/code_check/W0232.feature +0 -2
- data/features/code_check/W0233.feature +0 -2
- data/features/code_check/W0234.feature +0 -2
- data/features/code_check/W0235.feature +0 -2
- data/features/code_check/W0236.feature +0 -2
- data/features/code_check/W0237.feature +0 -2
- data/features/code_check/W0238.feature +0 -2
- data/features/code_check/W0239.feature +0 -2
- data/features/code_check/W0240.feature +0 -2
- data/features/code_check/W0241.feature +0 -2
- data/features/code_check/W0242.feature +0 -2
- data/features/code_check/W0243.feature +0 -2
- data/features/code_check/W0244.feature +0 -2
- data/features/code_check/W0245.feature +0 -2
- data/features/code_check/W0246.feature +0 -2
- data/features/code_check/W0247.feature +0 -2
- data/features/code_check/W0248.feature +0 -2
- data/features/code_check/W0249.feature +0 -2
- data/features/code_check/W0250.feature +0 -2
- data/features/code_check/W0251.feature +0 -2
- data/features/code_check/W0252.feature +0 -2
- data/features/code_check/W0253.feature +0 -2
- data/features/code_check/W0254.feature +0 -2
- data/features/code_check/W0425.feature +0 -2
- data/features/code_check/W0431.feature +0 -2
- data/features/code_check/W0432.feature +0 -2
- data/features/code_check/W0477.feature +0 -2
- data/features/code_check/W0478.feature +0 -2
- data/features/code_check/W0479.feature +0 -2
- data/features/code_check/W0480.feature +0 -2
- data/features/code_check/W0481.feature +0 -2
- data/features/code_check/W0482.feature +0 -2
- data/features/code_check/W0483.feature +0 -2
- data/features/code_check/W0488.feature +132 -0
- data/features/code_check/W0489.feature +78 -0
- data/features/code_check/W0490.feature +83 -0
- data/features/code_check/W0495.feature +60 -0
- data/features/code_check/W0496.feature +63 -0
- data/features/code_check/W0497.feature +65 -0
- data/features/code_check/W0498.feature +120 -0
- data/features/code_check/W0499.feature +63 -0
- data/features/code_check/W0500.feature +66 -0
- data/features/code_check/W0501.feature +69 -0
- data/features/code_check/W0502.feature +64 -0
- data/features/code_check/W0573.feature +0 -2
- data/features/code_check/W0583.feature +0 -2
- data/features/code_check/W0606.feature +0 -2
- data/features/code_check/W0635.feature +0 -2
- data/features/code_check/W0641.feature +0 -2
- data/features/code_check/W0643.feature +0 -2
- data/features/code_check/W0644.feature +0 -2
- data/features/code_check/W0645.feature +0 -2
- data/features/code_check/W0646.feature +0 -2
- data/features/code_check/W0649.feature +0 -2
- data/features/code_check/W0650.feature +0 -2
- data/features/code_check/W0655.feature +43 -0
- data/features/code_check/W0685.feature +0 -2
- data/features/code_check/W0686.feature +0 -2
- data/features/code_check/W0687.feature +0 -2
- data/features/code_check/W0688.feature +0 -2
- data/features/code_check/W0689.feature +0 -2
- data/features/code_check/W0690.feature +0 -2
- data/features/code_check/W0691.feature +0 -2
- data/features/code_check/W0692.feature +0 -2
- data/features/code_check/W0694.feature +0 -2
- data/features/code_check/W0695.feature +0 -2
- data/features/code_check/W0697.feature +0 -2
- data/features/code_check/W0698.feature +0 -2
- data/features/code_check/W0699.feature +0 -2
- data/features/code_check/W0700.feature +0 -2
- data/features/code_check/W0703.feature +0 -2
- data/features/code_check/W0705.feature +6 -2
- data/features/code_check/W0707.feature +4 -2
- data/features/code_check/W0711.feature +0 -2
- data/features/code_check/W0712.feature +0 -2
- data/features/code_check/W0713.feature +0 -2
- data/features/code_check/W0714.feature +0 -2
- data/features/code_check/W0715.feature +0 -2
- data/features/code_check/W0716.feature +0 -2
- data/features/code_check/W0717.feature +0 -2
- data/features/code_check/W0718.feature +0 -2
- data/features/code_check/W0719.feature +0 -2
- data/features/code_check/W0723.feature +0 -2
- data/features/code_check/W0726.feature +0 -2
- data/features/code_check/W0732.feature +0 -2
- data/features/code_check/W0733.feature +0 -2
- data/features/code_check/W0734.feature +0 -2
- data/features/code_check/W0735.feature +0 -2
- data/features/code_check/W0745.feature +1 -2
- data/features/code_check/W0747.feature +0 -2
- data/features/code_check/W0748.feature +0 -2
- data/features/code_check/W0749.feature +0 -2
- data/features/code_check/W0750.feature +0 -2
- data/features/code_check/W0751.feature +0 -2
- data/features/code_check/W0752.feature +0 -2
- data/features/code_check/W0753.feature +0 -2
- data/features/code_check/W0754.feature +0 -2
- data/features/code_check/W0755.feature +0 -2
- data/features/code_check/W0756.feature +0 -2
- data/features/code_check/W0757.feature +0 -2
- data/features/code_check/W0758.feature +0 -2
- data/features/code_check/W0759.feature +0 -2
- data/features/code_check/W0760.feature +0 -2
- data/features/code_check/W0761.feature +0 -2
- data/features/code_check/W0762.feature +0 -2
- data/features/code_check/W0763.feature +0 -2
- data/features/code_check/W0764.feature +0 -2
- data/features/code_check/W0765.feature +0 -2
- data/features/code_check/W0766.feature +0 -2
- data/features/code_check/W0767.feature +0 -2
- data/features/code_check/W0768.feature +0 -2
- data/features/code_check/W0769.feature +0 -2
- data/features/code_check/W0780.feature +0 -2
- data/features/code_check/W0781.feature +0 -2
- data/features/code_check/W0783.feature +0 -2
- data/features/code_check/W0787.feature +0 -2
- data/features/code_check/W0792.feature +0 -2
- data/features/code_check/W0793.feature +0 -2
- data/features/code_check/W0794.feature +0 -2
- data/features/code_check/W0801.feature +0 -2
- data/features/code_check/W0805.feature +0 -2
- data/features/code_check/W0806.feature +0 -2
- data/features/code_check/W0807.feature +0 -2
- data/features/code_check/W0808.feature +0 -2
- data/features/code_check/W0809.feature +0 -2
- data/features/code_check/W0811.feature +0 -2
- data/features/code_check/W0830.feature +0 -2
- data/features/code_check/W0833.feature +0 -2
- data/features/code_check/W0834.feature +1 -3
- data/features/code_check/W1026.feature +0 -2
- data/features/code_check/W1030.feature +0 -2
- data/features/code_check/W1031.feature +0 -2
- data/features/code_check/W1039.feature +0 -2
- data/features/code_check/W1040.feature +0 -2
- data/features/code_check/W1041.feature +0 -2
- data/features/code_check/W1046.feature +0 -2
- data/features/code_check/W1047.feature +0 -2
- data/features/code_check/W1052.feature +0 -2
- data/features/code_check/W1066.feature +0 -2
- data/features/code_check/W1067.feature +0 -2
- data/features/code_check/W1068.feature +0 -2
- data/features/code_check/W1069.feature +0 -2
- data/features/code_check/W1070.feature +0 -2
- data/features/code_check/W1071.feature +0 -2
- data/features/code_check/W1072.feature +0 -2
- data/features/code_check/W1073.feature +1 -3
- data/features/code_check/W1074.feature +3 -4
- data/features/code_check/W1075.feature +0 -2
- data/features/code_check/W1076.feature +0 -2
- data/features/code_check/W1077.feature +0 -2
- data/features/code_check/W9001.feature +0 -2
- data/features/code_check/W9003.feature +3 -3
- data/lib/adlint/c/branch.rb +2 -2
- data/lib/adlint/c/environ.rb +3 -3
- data/lib/adlint/c/expr.rb +67 -39
- data/lib/adlint/c/interp.rb +10 -1
- data/lib/adlint/c/object.rb +6 -4
- data/lib/adlint/c/parser.rb +1 -1
- data/lib/adlint/c/value.rb +27 -10
- data/lib/adlint/cpp/constexpr.rb +1 -1
- data/lib/adlint/exam/c_builtin/c_check.rb +502 -420
- 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 +10 -10
- data/share/doc/users_guide_en.texi +8 -8
- data/share/doc/users_guide_ja.html +10 -10
- data/share/doc/users_guide_ja.texi +8 -8
- metadata +15 -3
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Feature: W0498
|
|
2
|
+
|
|
3
|
+
W0498 detects that different operators of the same priority appear in an
|
|
4
|
+
expression without appropriate grouping.
|
|
5
|
+
|
|
6
|
+
Scenario: multiple additive-expressions in an expression
|
|
7
|
+
Given a target source named "fixture.c" with:
|
|
8
|
+
"""
|
|
9
|
+
static int foo(int a, int b)
|
|
10
|
+
{
|
|
11
|
+
return a + b - 5; /* W0498 */
|
|
12
|
+
}
|
|
13
|
+
"""
|
|
14
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
15
|
+
Then the output should exactly match with:
|
|
16
|
+
| mesg | line | column |
|
|
17
|
+
| W1076 | 1 | 12 |
|
|
18
|
+
| W0723 | 3 | 14 |
|
|
19
|
+
| W0723 | 3 | 18 |
|
|
20
|
+
| W0104 | 1 | 20 |
|
|
21
|
+
| W0104 | 1 | 27 |
|
|
22
|
+
| W0629 | 1 | 12 |
|
|
23
|
+
| W0498 | 3 | 12 |
|
|
24
|
+
| W0628 | 1 | 12 |
|
|
25
|
+
|
|
26
|
+
Scenario: multiple additive-expressions in an expression with grouping
|
|
27
|
+
Given a target source named "fixture.c" with:
|
|
28
|
+
"""
|
|
29
|
+
static int foo(int a, int b)
|
|
30
|
+
{
|
|
31
|
+
return a + (b - 5); /* OK */
|
|
32
|
+
}
|
|
33
|
+
"""
|
|
34
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
35
|
+
Then the output should exactly match with:
|
|
36
|
+
| mesg | line | column |
|
|
37
|
+
| W1076 | 1 | 12 |
|
|
38
|
+
| W0723 | 3 | 19 |
|
|
39
|
+
| W0723 | 3 | 14 |
|
|
40
|
+
| W0104 | 1 | 20 |
|
|
41
|
+
| W0104 | 1 | 27 |
|
|
42
|
+
| W0629 | 1 | 12 |
|
|
43
|
+
| W0628 | 1 | 12 |
|
|
44
|
+
|
|
45
|
+
Scenario: multiple additive-expressions in an expression with large grouping
|
|
46
|
+
Given a target source named "fixture.c" with:
|
|
47
|
+
"""
|
|
48
|
+
static int foo(int a, int b)
|
|
49
|
+
{
|
|
50
|
+
return (a + b - 5); /* W0498 */
|
|
51
|
+
}
|
|
52
|
+
"""
|
|
53
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
54
|
+
Then the output should exactly match with:
|
|
55
|
+
| mesg | line | column |
|
|
56
|
+
| W1076 | 1 | 12 |
|
|
57
|
+
| W0723 | 3 | 15 |
|
|
58
|
+
| W0723 | 3 | 19 |
|
|
59
|
+
| W0104 | 1 | 20 |
|
|
60
|
+
| W0104 | 1 | 27 |
|
|
61
|
+
| W0629 | 1 | 12 |
|
|
62
|
+
| W0498 | 3 | 12 |
|
|
63
|
+
| W0628 | 1 | 12 |
|
|
64
|
+
|
|
65
|
+
Scenario: multiple multiplicative-expressions in an expression
|
|
66
|
+
Given a target source named "fixture.c" with:
|
|
67
|
+
"""
|
|
68
|
+
static int foo(int a, int b)
|
|
69
|
+
{
|
|
70
|
+
return a * b / 5; /* W0498 */
|
|
71
|
+
}
|
|
72
|
+
"""
|
|
73
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
74
|
+
Then the output should exactly match with:
|
|
75
|
+
| mesg | line | column |
|
|
76
|
+
| W1076 | 1 | 12 |
|
|
77
|
+
| W0723 | 3 | 14 |
|
|
78
|
+
| W0104 | 1 | 20 |
|
|
79
|
+
| W0104 | 1 | 27 |
|
|
80
|
+
| W0629 | 1 | 12 |
|
|
81
|
+
| W0498 | 3 | 12 |
|
|
82
|
+
| W0628 | 1 | 12 |
|
|
83
|
+
|
|
84
|
+
Scenario: multiple multiplicative-expressions in an expression with grouping
|
|
85
|
+
Given a target source named "fixture.c" with:
|
|
86
|
+
"""
|
|
87
|
+
static int foo(int a, int b)
|
|
88
|
+
{
|
|
89
|
+
return a * (b / 5); /* OK */
|
|
90
|
+
}
|
|
91
|
+
"""
|
|
92
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
93
|
+
Then the output should exactly match with:
|
|
94
|
+
| mesg | line | column |
|
|
95
|
+
| W1076 | 1 | 12 |
|
|
96
|
+
| W0723 | 3 | 14 |
|
|
97
|
+
| W0104 | 1 | 20 |
|
|
98
|
+
| W0104 | 1 | 27 |
|
|
99
|
+
| W0629 | 1 | 12 |
|
|
100
|
+
| W0628 | 1 | 12 |
|
|
101
|
+
|
|
102
|
+
Scenario: multiple multiplicative-expressions in an expression grouped
|
|
103
|
+
entirely
|
|
104
|
+
Given a target source named "fixture.c" with:
|
|
105
|
+
"""
|
|
106
|
+
static int foo(int a, int b)
|
|
107
|
+
{
|
|
108
|
+
return (a * b / 5); /* W0498 */
|
|
109
|
+
}
|
|
110
|
+
"""
|
|
111
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
112
|
+
Then the output should exactly match with:
|
|
113
|
+
| mesg | line | column |
|
|
114
|
+
| W1076 | 1 | 12 |
|
|
115
|
+
| W0723 | 3 | 15 |
|
|
116
|
+
| W0104 | 1 | 20 |
|
|
117
|
+
| W0104 | 1 | 27 |
|
|
118
|
+
| W0629 | 1 | 12 |
|
|
119
|
+
| W0498 | 3 | 12 |
|
|
120
|
+
| W0628 | 1 | 12 |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Feature: W0499
|
|
2
|
+
|
|
3
|
+
W0499 detects that different operators of the same priority except for `+',
|
|
4
|
+
`-', `*', `/' and `%' appear in an expression without appropriate grouping.
|
|
5
|
+
|
|
6
|
+
Scenario: multiple shift-expressions in an expression
|
|
7
|
+
Given a target source named "fixture.c" with:
|
|
8
|
+
"""
|
|
9
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
10
|
+
{
|
|
11
|
+
return a << b >> c; /* W0499 */
|
|
12
|
+
}
|
|
13
|
+
"""
|
|
14
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
15
|
+
Then the output should exactly match with:
|
|
16
|
+
| mesg | line | column |
|
|
17
|
+
| W1076 | 1 | 21 |
|
|
18
|
+
| W0116 | 3 | 14 |
|
|
19
|
+
| W0104 | 1 | 38 |
|
|
20
|
+
| W0104 | 1 | 54 |
|
|
21
|
+
| W0104 | 1 | 70 |
|
|
22
|
+
| W0629 | 1 | 21 |
|
|
23
|
+
| W0499 | 3 | 12 |
|
|
24
|
+
| W0628 | 1 | 21 |
|
|
25
|
+
|
|
26
|
+
Scenario: multiple shift-expressions in an expression with grouping
|
|
27
|
+
Given a target source named "fixture.c" with:
|
|
28
|
+
"""
|
|
29
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
30
|
+
{
|
|
31
|
+
return (a << b) >> c; /* OK */
|
|
32
|
+
}
|
|
33
|
+
"""
|
|
34
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
35
|
+
Then the output should exactly match with:
|
|
36
|
+
| mesg | line | column |
|
|
37
|
+
| W1076 | 1 | 21 |
|
|
38
|
+
| W0116 | 3 | 15 |
|
|
39
|
+
| W0104 | 1 | 38 |
|
|
40
|
+
| W0104 | 1 | 54 |
|
|
41
|
+
| W0104 | 1 | 70 |
|
|
42
|
+
| W0629 | 1 | 21 |
|
|
43
|
+
| W0628 | 1 | 21 |
|
|
44
|
+
|
|
45
|
+
Scenario: multiple shift-expressions in an expression with large grouping
|
|
46
|
+
Given a target source named "fixture.c" with:
|
|
47
|
+
"""
|
|
48
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
49
|
+
{
|
|
50
|
+
return (a << b >> c); /* W0499 */
|
|
51
|
+
}
|
|
52
|
+
"""
|
|
53
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
54
|
+
Then the output should exactly match with:
|
|
55
|
+
| mesg | line | column |
|
|
56
|
+
| W1076 | 1 | 21 |
|
|
57
|
+
| W0116 | 3 | 15 |
|
|
58
|
+
| W0104 | 1 | 38 |
|
|
59
|
+
| W0104 | 1 | 54 |
|
|
60
|
+
| W0104 | 1 | 70 |
|
|
61
|
+
| W0629 | 1 | 21 |
|
|
62
|
+
| W0499 | 3 | 12 |
|
|
63
|
+
| W0628 | 1 | 21 |
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Feature: W0500
|
|
2
|
+
|
|
3
|
+
W0500 detects that `+', `-', `*' and `%' operators of the different priority
|
|
4
|
+
appear in an expression without appropriate grouping.
|
|
5
|
+
|
|
6
|
+
Scenario: additives and multiplicatives in an expression
|
|
7
|
+
Given a target source named "fixture.c" with:
|
|
8
|
+
"""
|
|
9
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
10
|
+
{
|
|
11
|
+
return a + b * c; /* W0500 */
|
|
12
|
+
}
|
|
13
|
+
"""
|
|
14
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
15
|
+
Then the output should exactly match with:
|
|
16
|
+
| mesg | line | column |
|
|
17
|
+
| W1076 | 1 | 21 |
|
|
18
|
+
| W1052 | 3 | 18 |
|
|
19
|
+
| W1052 | 3 | 14 |
|
|
20
|
+
| W0104 | 1 | 38 |
|
|
21
|
+
| W0104 | 1 | 54 |
|
|
22
|
+
| W0104 | 1 | 70 |
|
|
23
|
+
| W0629 | 1 | 21 |
|
|
24
|
+
| W0500 | 3 | 12 |
|
|
25
|
+
| W0628 | 1 | 21 |
|
|
26
|
+
|
|
27
|
+
Scenario: additives and multiplicatives in an expression with grouping
|
|
28
|
+
Given a target source named "fixture.c" with:
|
|
29
|
+
"""
|
|
30
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
31
|
+
{
|
|
32
|
+
return a + (b * c); /* OK */
|
|
33
|
+
}
|
|
34
|
+
"""
|
|
35
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
36
|
+
Then the output should exactly match with:
|
|
37
|
+
| mesg | line | column |
|
|
38
|
+
| W1076 | 1 | 21 |
|
|
39
|
+
| W1052 | 3 | 19 |
|
|
40
|
+
| W1052 | 3 | 14 |
|
|
41
|
+
| W0104 | 1 | 38 |
|
|
42
|
+
| W0104 | 1 | 54 |
|
|
43
|
+
| W0104 | 1 | 70 |
|
|
44
|
+
| W0629 | 1 | 21 |
|
|
45
|
+
| W0628 | 1 | 21 |
|
|
46
|
+
|
|
47
|
+
Scenario: additives and multiplicatives in an expression with large grouping
|
|
48
|
+
Given a target source named "fixture.c" with:
|
|
49
|
+
"""
|
|
50
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
51
|
+
{
|
|
52
|
+
return (a + b * c); /* W0500 */
|
|
53
|
+
}
|
|
54
|
+
"""
|
|
55
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
56
|
+
Then the output should exactly match with:
|
|
57
|
+
| mesg | line | column |
|
|
58
|
+
| W1076 | 1 | 21 |
|
|
59
|
+
| W1052 | 3 | 19 |
|
|
60
|
+
| W1052 | 3 | 15 |
|
|
61
|
+
| W0104 | 1 | 38 |
|
|
62
|
+
| W0104 | 1 | 54 |
|
|
63
|
+
| W0104 | 1 | 70 |
|
|
64
|
+
| W0629 | 1 | 21 |
|
|
65
|
+
| W0500 | 3 | 12 |
|
|
66
|
+
| W0628 | 1 | 21 |
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
Feature: W0501
|
|
2
|
+
|
|
3
|
+
W0501 detects that a binary-expression appars in a conditional-expression
|
|
4
|
+
without appropriate grouping.
|
|
5
|
+
|
|
6
|
+
Scenario: binary-expressions in a conditional-expression
|
|
7
|
+
Given a target source named "fixture.c" with:
|
|
8
|
+
"""
|
|
9
|
+
static int foo(int a, int b, int c)
|
|
10
|
+
{
|
|
11
|
+
return a + b ? a + b : c; /* W0501 */
|
|
12
|
+
}
|
|
13
|
+
"""
|
|
14
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
15
|
+
Then the output should exactly match with:
|
|
16
|
+
| mesg | line | column |
|
|
17
|
+
| W1076 | 1 | 12 |
|
|
18
|
+
| W0723 | 3 | 14 |
|
|
19
|
+
| W0723 | 3 | 22 |
|
|
20
|
+
| W0104 | 1 | 20 |
|
|
21
|
+
| W0104 | 1 | 27 |
|
|
22
|
+
| W0104 | 1 | 34 |
|
|
23
|
+
| W0629 | 1 | 12 |
|
|
24
|
+
| W0501 | 3 | 18 |
|
|
25
|
+
| W0114 | 3 | 14 |
|
|
26
|
+
| W0628 | 1 | 12 |
|
|
27
|
+
|
|
28
|
+
Scenario: binary-expressions in a conditional-expression with grouping
|
|
29
|
+
Given a target source named "fixture.c" with:
|
|
30
|
+
"""
|
|
31
|
+
static int foo(int a, int b, int c)
|
|
32
|
+
{
|
|
33
|
+
return (a + b) ? (a + b) : c; /* OK */
|
|
34
|
+
}
|
|
35
|
+
"""
|
|
36
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
37
|
+
Then the output should exactly match with:
|
|
38
|
+
| mesg | line | column |
|
|
39
|
+
| W1076 | 1 | 12 |
|
|
40
|
+
| W0723 | 3 | 15 |
|
|
41
|
+
| W0723 | 3 | 25 |
|
|
42
|
+
| W0104 | 1 | 20 |
|
|
43
|
+
| W0104 | 1 | 27 |
|
|
44
|
+
| W0104 | 1 | 34 |
|
|
45
|
+
| W0629 | 1 | 12 |
|
|
46
|
+
| W0114 | 3 | 12 |
|
|
47
|
+
| W0628 | 1 | 12 |
|
|
48
|
+
|
|
49
|
+
Scenario: binary-expressions in a conditional-expression with large grouping
|
|
50
|
+
Given a target source named "fixture.c" with:
|
|
51
|
+
"""
|
|
52
|
+
static int foo(int a, int b, int c)
|
|
53
|
+
{
|
|
54
|
+
return (a + b ? a + b : c); /* W0501 */
|
|
55
|
+
}
|
|
56
|
+
"""
|
|
57
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
58
|
+
Then the output should exactly match with:
|
|
59
|
+
| mesg | line | column |
|
|
60
|
+
| W1076 | 1 | 12 |
|
|
61
|
+
| W0723 | 3 | 15 |
|
|
62
|
+
| W0723 | 3 | 23 |
|
|
63
|
+
| W0104 | 1 | 20 |
|
|
64
|
+
| W0104 | 1 | 27 |
|
|
65
|
+
| W0104 | 1 | 34 |
|
|
66
|
+
| W0629 | 1 | 12 |
|
|
67
|
+
| W0501 | 3 | 19 |
|
|
68
|
+
| W0114 | 3 | 15 |
|
|
69
|
+
| W0628 | 1 | 12 |
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Feature: W0502
|
|
2
|
+
|
|
3
|
+
W0502 detects that operators of the different priority except for `+', `-',
|
|
4
|
+
`*', `/' and `%' appear in an expression without appropriate grouping.
|
|
5
|
+
|
|
6
|
+
Scenario: shift-expression and and-expression in an expression
|
|
7
|
+
Given a target source named "fixture.c" with:
|
|
8
|
+
"""
|
|
9
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
10
|
+
{
|
|
11
|
+
return a << b & c; /* W0502 */
|
|
12
|
+
}
|
|
13
|
+
"""
|
|
14
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
15
|
+
Then the output should exactly match with:
|
|
16
|
+
| mesg | line | column |
|
|
17
|
+
| W1076 | 1 | 21 |
|
|
18
|
+
| W0116 | 3 | 14 |
|
|
19
|
+
| W0104 | 1 | 38 |
|
|
20
|
+
| W0104 | 1 | 54 |
|
|
21
|
+
| W0104 | 1 | 70 |
|
|
22
|
+
| W0629 | 1 | 21 |
|
|
23
|
+
| W0502 | 3 | 12 |
|
|
24
|
+
| W0628 | 1 | 21 |
|
|
25
|
+
|
|
26
|
+
Scenario: shift-expression and and-expression in an expression with grouping
|
|
27
|
+
Given a target source named "fixture.c" with:
|
|
28
|
+
"""
|
|
29
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
30
|
+
{
|
|
31
|
+
return a << (b & c); /* OK */
|
|
32
|
+
}
|
|
33
|
+
"""
|
|
34
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
35
|
+
Then the output should exactly match with:
|
|
36
|
+
| mesg | line | column |
|
|
37
|
+
| W1076 | 1 | 21 |
|
|
38
|
+
| W0116 | 3 | 14 |
|
|
39
|
+
| W0104 | 1 | 38 |
|
|
40
|
+
| W0104 | 1 | 54 |
|
|
41
|
+
| W0104 | 1 | 70 |
|
|
42
|
+
| W0629 | 1 | 21 |
|
|
43
|
+
| W0628 | 1 | 21 |
|
|
44
|
+
|
|
45
|
+
Scenario: shift-expression and and-expression in an expression with large
|
|
46
|
+
grouping
|
|
47
|
+
Given a target source named "fixture.c" with:
|
|
48
|
+
"""
|
|
49
|
+
static unsigned int foo(unsigned int a, unsigned int b, unsigned int c)
|
|
50
|
+
{
|
|
51
|
+
return (a << b & c); /* W0502 */
|
|
52
|
+
}
|
|
53
|
+
"""
|
|
54
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
55
|
+
Then the output should exactly match with:
|
|
56
|
+
| mesg | line | column |
|
|
57
|
+
| W1076 | 1 | 21 |
|
|
58
|
+
| W0116 | 3 | 15 |
|
|
59
|
+
| W0104 | 1 | 38 |
|
|
60
|
+
| W0104 | 1 | 54 |
|
|
61
|
+
| W0104 | 1 | 70 |
|
|
62
|
+
| W0629 | 1 | 21 |
|
|
63
|
+
| W0502 | 3 | 12 |
|
|
64
|
+
| W0628 | 1 | 21 |
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Feature: W0655
|
|
2
|
+
|
|
3
|
+
W0655 detects that a bit-field member appears as an operand of the
|
|
4
|
+
sizeof-expression.
|
|
5
|
+
|
|
6
|
+
Scenario: bit-field as an operand
|
|
7
|
+
Given a target source named "fixture.c" with:
|
|
8
|
+
"""
|
|
9
|
+
extern struct Foo { unsigned int b1:1, b2:1; } foo;
|
|
10
|
+
|
|
11
|
+
static unsigned long bar(void)
|
|
12
|
+
{
|
|
13
|
+
return sizeof(foo.b1); /* W0655 */
|
|
14
|
+
}
|
|
15
|
+
"""
|
|
16
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
17
|
+
Then the output should exactly match with:
|
|
18
|
+
| mesg | line | column |
|
|
19
|
+
| W0118 | 1 | 48 |
|
|
20
|
+
| W1076 | 3 | 22 |
|
|
21
|
+
| W0655 | 5 | 12 |
|
|
22
|
+
| W0629 | 3 | 22 |
|
|
23
|
+
| W0425 | 1 | 40 |
|
|
24
|
+
| W0628 | 3 | 22 |
|
|
25
|
+
|
|
26
|
+
Scenario: arithmetic expression of two bit-fields as an operand
|
|
27
|
+
Given a target source named "fixture.c" with:
|
|
28
|
+
"""
|
|
29
|
+
extern struct Foo { unsigned int b1:1, b2:1; } foo;
|
|
30
|
+
|
|
31
|
+
static unsigned long bar(void)
|
|
32
|
+
{
|
|
33
|
+
return sizeof(foo.b1 + foo.b2); /* OK */
|
|
34
|
+
}
|
|
35
|
+
"""
|
|
36
|
+
When I successfully run `adlint fixture.c` on noarch
|
|
37
|
+
Then the output should exactly match with:
|
|
38
|
+
| mesg | line | column |
|
|
39
|
+
| W0118 | 1 | 48 |
|
|
40
|
+
| W1076 | 3 | 22 |
|
|
41
|
+
| W0629 | 3 | 22 |
|
|
42
|
+
| W0425 | 1 | 40 |
|
|
43
|
+
| W0628 | 3 | 22 |
|
|
@@ -112,6 +112,7 @@ Feature: W0705
|
|
|
112
112
|
| W0490 | 6 | 9 |
|
|
113
113
|
| W0499 | 6 | 9 |
|
|
114
114
|
| W0502 | 6 | 9 |
|
|
115
|
+
| W0498 | 7 | 14 |
|
|
115
116
|
| W0628 | 3 | 5 |
|
|
116
117
|
|
|
117
118
|
Scenario: indirection-expression with non-constant subscript may cause OOB
|
|
@@ -142,6 +143,7 @@ Feature: W0705
|
|
|
142
143
|
| W0490 | 5 | 9 |
|
|
143
144
|
| W0499 | 5 | 9 |
|
|
144
145
|
| W0502 | 5 | 9 |
|
|
146
|
+
| W0498 | 6 | 10 |
|
|
145
147
|
| W0628 | 3 | 6 |
|
|
146
148
|
|
|
147
149
|
Scenario: array-subscript-expression with non-constant subscript must not
|
|
@@ -249,6 +251,7 @@ Feature: W0705
|
|
|
249
251
|
| W0490 | 6 | 9 |
|
|
250
252
|
| W0499 | 6 | 9 |
|
|
251
253
|
| W0502 | 6 | 9 |
|
|
254
|
+
| W0498 | 7 | 14 |
|
|
252
255
|
| W0628 | 3 | 5 |
|
|
253
256
|
|
|
254
257
|
Scenario: indirection-expression with non-constant subscript must not cause
|
|
@@ -278,6 +281,7 @@ Feature: W0705
|
|
|
278
281
|
| W0490 | 5 | 9 |
|
|
279
282
|
| W0499 | 5 | 9 |
|
|
280
283
|
| W0502 | 5 | 9 |
|
|
284
|
+
| W0498 | 6 | 10 |
|
|
281
285
|
| W0628 | 3 | 6 |
|
|
282
286
|
|
|
283
287
|
Scenario: indirection-expression with non-constant subscript should not cause
|
|
@@ -311,6 +315,7 @@ Feature: W0705
|
|
|
311
315
|
| W0490 | 5 | 9 |
|
|
312
316
|
| W0499 | 5 | 9 |
|
|
313
317
|
| W0502 | 5 | 9 |
|
|
318
|
+
| W0498 | 7 | 18 |
|
|
314
319
|
| W0628 | 3 | 5 |
|
|
315
320
|
|
|
316
321
|
Scenario: indirection-expression with non-constant subscript may and should
|
|
@@ -345,6 +350,5 @@ Feature: W0705
|
|
|
345
350
|
| W0490 | 5 | 9 |
|
|
346
351
|
| W0499 | 5 | 9 |
|
|
347
352
|
| W0502 | 5 | 9 |
|
|
353
|
+
| W0498 | 7 | 18 |
|
|
348
354
|
| W0628 | 3 | 5 |
|
|
349
|
-
|
|
350
|
-
# vim:ts=2:sw=2:sts=2:et:
|