Skip to content

Commit 5cddabb

Browse files
committed
CPP: Add a test of AV Rule 165.
1 parent bc06831 commit 5cddabb

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| test.c:6:6:6:8 | - ... | The unary minus operator should not be applied to an unsigned expression. |
2+
| test.c:9:7:9:9 | - ... | The unary minus operator should not be applied to an unsigned expression. |
3+
| test.c:12:7:12:9 | - ... | The unary minus operator should not be applied to an unsigned expression. |
4+
| test.c:18:7:18:14 | - ... | The unary minus operator should not be applied to an unsigned expression. |
5+
| test.c:19:7:19:23 | - ... | The unary minus operator should not be applied to an unsigned expression. |
6+
| test.c:20:7:20:21 | - ... | The unary minus operator should not be applied to an unsigned expression. |
7+
| test.c:22:8:22:11 | - ... | The unary minus operator should not be applied to an unsigned expression. |
8+
| test.c:23:8:23:11 | - ... | The unary minus operator should not be applied to an unsigned expression. |
9+
| test.c:24:6:24:7 | - ... | The unary minus operator should not be applied to an unsigned expression. |
10+
| test.c:25:7:25:9 | - ... | The unary minus operator should not be applied to an unsigned expression. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jsf/4.21 Operators/AV Rule 165.ql
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
typedef unsigned int TUI;
3+
4+
void f(int i, unsigned int ui, signed int si, TUI tui, volatile unsigned int vui, unsigned u, unsigned short us) {
5+
i = -i;
6+
i = -ui; // BAD
7+
i = -si;
8+
ui = -i;
9+
ui = -ui; // BAD
10+
ui = -si;
11+
si = -i;
12+
si = -ui; // BAD
13+
si = -si;
14+
15+
i = -(int)i;
16+
i = -(unsigned int)i; // BAD [NOT DETECTED]
17+
i = -(signed int)i;
18+
ui = -(int)ui; // [FALSE POSITIVE]
19+
ui = -(unsigned int)ui; // BAD
20+
ui = -(signed int)ui; // [FALSE POSITIVE]
21+
22+
tui = -tui; // BAD
23+
vui = -vui; // BAD
24+
u = -u; // BAD
25+
us = -us; // BAD
26+
ui = -(5U); // BAD [NOT DETECTED]
27+
}

0 commit comments

Comments
 (0)