Skip to content

Commit 3028e85

Browse files
committed
CPP: Add a test of AV Rule 164.
1 parent bc06831 commit 3028e85

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
| test.c:3:2:3:9 | ... >> ... | AV Rule 164: The right-hand operand (here a value is -1) of this shift shall lie between 0 and 7. |
2+
| test.c:6:2:6:8 | ... >> ... | AV Rule 164: The right-hand operand (here a value is 8) of this shift shall lie between 0 and 7. |
3+
| test.c:8:2:8:9 | ... << ... | AV Rule 164: The right-hand operand (here a value is -1) of this shift shall lie between 0 and 7. |
4+
| test.c:11:2:11:8 | ... << ... | AV Rule 164: The right-hand operand (here a value is 8) of this shift shall lie between 0 and 7. |
5+
| test.c:18:2:18:9 | ... >> ... | AV Rule 164: The right-hand operand (here a value is -1) of this shift shall lie between 0 and 7. |
6+
| test.c:21:2:21:8 | ... >> ... | AV Rule 164: The right-hand operand (here a value is 8) of this shift shall lie between 0 and 7. |
7+
| test.c:23:2:23:25 | ... >> ... | AV Rule 164: The right-hand operand (here a value is -1) of this shift shall lie between 0 and 31. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jsf/4.21 Operators/AV Rule 164.ql
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
void f(unsigned char uc, signed char sc, int i) {
3+
uc >> -1; // BAD
4+
uc >> 0;
5+
uc >> 7;
6+
uc >> 8; // BAD
7+
8+
uc << -1; // BAD
9+
uc << 0;
10+
uc << 7;
11+
uc << 8; // BAD
12+
13+
uc >>= -1; // BAD [NOT DETECTED]
14+
uc >>= 0; // BAD [NOT DETECTED]
15+
uc >>= 7;
16+
uc >>= 8; // BAD [NOT DETECTED]
17+
18+
sc >> -1; // BAD
19+
sc >> 0;
20+
sc >> 7;
21+
sc >> 8; // BAD
22+
23+
((unsigned char)i) >> -1; // BAD
24+
((unsigned char)i) >> 0;
25+
((unsigned char)i) >> 7;
26+
((unsigned char)i) >> 8; // BAD [NOT DETECTED]
27+
}
28+

0 commit comments

Comments
 (0)