CPP: Add a test of AV Rule 164.

This commit is contained in:
Geoffrey White
2018-11-14 19:37:25 +00:00
parent bc06831d01
commit 3028e85457
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |

View File

@@ -0,0 +1 @@
jsf/4.21 Operators/AV Rule 164.ql

View File

@@ -0,0 +1,28 @@
void f(unsigned char uc, signed char sc, int i) {
uc >> -1; // BAD
uc >> 0;
uc >> 7;
uc >> 8; // BAD
uc << -1; // BAD
uc << 0;
uc << 7;
uc << 8; // BAD
uc >>= -1; // BAD [NOT DETECTED]
uc >>= 0; // BAD [NOT DETECTED]
uc >>= 7;
uc >>= 8; // BAD [NOT DETECTED]
sc >> -1; // BAD
sc >> 0;
sc >> 7;
sc >> 8; // BAD
((unsigned char)i) >> -1; // BAD
((unsigned char)i) >> 0;
((unsigned char)i) >> 7;
((unsigned char)i) >> 8; // BAD [NOT DETECTED]
}