mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
CPP: Add a test of AV Rule 165.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
| test.c:6:6:6:8 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:9:7:9:9 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:12:7:12:9 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:18:7:18:14 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:19:7:19:23 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:20:7:20:21 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:22:8:22:11 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:23:8:23:11 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:24:6:24:7 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
| test.c:25:7:25:9 | - ... | The unary minus operator should not be applied to an unsigned expression. |
|
||||
@@ -0,0 +1 @@
|
||||
jsf/4.21 Operators/AV Rule 165.ql
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
typedef unsigned int TUI;
|
||||
|
||||
void f(int i, unsigned int ui, signed int si, TUI tui, volatile unsigned int vui, unsigned u, unsigned short us) {
|
||||
i = -i;
|
||||
i = -ui; // BAD
|
||||
i = -si;
|
||||
ui = -i;
|
||||
ui = -ui; // BAD
|
||||
ui = -si;
|
||||
si = -i;
|
||||
si = -ui; // BAD
|
||||
si = -si;
|
||||
|
||||
i = -(int)i;
|
||||
i = -(unsigned int)i; // BAD [NOT DETECTED]
|
||||
i = -(signed int)i;
|
||||
ui = -(int)ui; // [FALSE POSITIVE]
|
||||
ui = -(unsigned int)ui; // BAD
|
||||
ui = -(signed int)ui; // [FALSE POSITIVE]
|
||||
|
||||
tui = -tui; // BAD
|
||||
vui = -vui; // BAD
|
||||
u = -u; // BAD
|
||||
us = -us; // BAD
|
||||
ui = -(5U); // BAD [NOT DETECTED]
|
||||
}
|
||||
Reference in New Issue
Block a user