Merge pull request #476 from geoffw0/av_165

CPP: Fix AV Rule 165
This commit is contained in:
Jonas Jensen
2018-11-19 14:32:02 +01:00
committed by GitHub
4 changed files with 38 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
| 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:16:6:16:21 | - ... | 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: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. |

View File

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

View File

@@ -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
i = -(signed int)i;
ui = -(int)ui;
ui = -(unsigned int)ui; // BAD
ui = -(signed int)ui;
tui = -tui; // BAD
vui = -vui; // BAD
u = -u; // BAD
us = -us; // BAD
ui = -(5U); // BAD [NOT DETECTED]
}