mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
CPP: Fix for explicitly cast expressions.
This commit is contained in:
@@ -11,6 +11,6 @@ import cpp
|
||||
// see MISRA Rule 5-3-2
|
||||
|
||||
from UnaryMinusExpr ume
|
||||
where ume.getOperand().getUnderlyingType().(IntegralType).isUnsigned()
|
||||
where ume.getOperand().getExplicitlyConverted().getUnderlyingType().(IntegralType).isUnsigned()
|
||||
and not ume.getOperand() instanceof Literal
|
||||
select ume, "The unary minus operator should not be applied to an unsigned expression."
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
| 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: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: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. |
|
||||
|
||||
@@ -13,11 +13,11 @@ void f(int i, unsigned int ui, signed int si, TUI tui, volatile unsigned int vui
|
||||
si = -si;
|
||||
|
||||
i = -(int)i;
|
||||
i = -(unsigned int)i; // BAD [NOT DETECTED]
|
||||
i = -(unsigned int)i; // BAD
|
||||
i = -(signed int)i;
|
||||
ui = -(int)ui; // [FALSE POSITIVE]
|
||||
ui = -(int)ui;
|
||||
ui = -(unsigned int)ui; // BAD
|
||||
ui = -(signed int)ui; // [FALSE POSITIVE]
|
||||
ui = -(signed int)ui;
|
||||
|
||||
tui = -tui; // BAD
|
||||
vui = -vui; // BAD
|
||||
|
||||
Reference in New Issue
Block a user