C++: Correct UnsignedBitwiseAndExpr.

This commit is contained in:
Geoffrey White
2020-04-17 17:10:59 +01:00
parent 01d3257d72
commit de751b0b75
3 changed files with 3 additions and 4 deletions

View File

@@ -125,11 +125,11 @@ private string getValue(Expr e) {
private class UnsignedBitwiseAndExpr extends BitwiseAndExpr {
UnsignedBitwiseAndExpr() {
(
getLeftOperand().getType().getUnderlyingType().(IntegralType).isUnsigned() or
getLeftOperand().getFullyConverted().getType().getUnderlyingType().(IntegralType).isUnsigned() or
getLeftOperand().getValue().toInt() >= 0
) and
(
getRightOperand().getType().getUnderlyingType().(IntegralType).isUnsigned() or
getRightOperand().getFullyConverted().getType().getUnderlyingType().(IntegralType).isUnsigned() or
getRightOperand().getValue().toInt() >= 0
)
}

View File

@@ -13,4 +13,3 @@
| test.c:107:14:107:26 | ... < ... | Comparison between $@ of type unsigned char and $@ of wider type unsigned int. | test.c:83:16:83:16 | c | c | test.c:107:19:107:25 | ... >> ... | ... >> ... |
| test.c:128:15:128:21 | ... < ... | Comparison between $@ of type unsigned char and $@ of wider type unsigned int. | test.c:121:16:121:17 | uc | uc | test.c:123:19:123:20 | sz | sz |
| test.c:139:15:139:21 | ... < ... | Comparison between $@ of type unsigned char and $@ of wider type unsigned int. | test.c:121:16:121:17 | uc | uc | test.c:123:19:123:20 | sz | sz |
| test.c:146:15:146:21 | ... < ... | Comparison between $@ of type unsigned char and $@ of wider type unsigned int. | test.c:121:16:121:17 | uc | uc | test.c:123:19:123:20 | sz | sz |

View File

@@ -143,5 +143,5 @@ void test13() {
if (sx < 0) {sx = 0;}
if (sx > 128) {sx = 128;}
sz = (unsigned)sx & (unsigned)sy;
for (uc = 0; uc < sz; uc++) {} // GOOD [FALSE POSITIVE]
for (uc = 0; uc < sz; uc++) {} // GOOD
}