C++: Range analysis: support casts from/to typedef

This commit is contained in:
Jonas Jensen
2019-03-27 09:29:26 +01:00
parent 1c71c74ce5
commit 1ffeebcfea
3 changed files with 16 additions and 12 deletions

View File

@@ -270,7 +270,7 @@ typedef unsigned char u8;
int widening_cast1(u8 c) {
if (c == 0) {
if ((int)c > 0) { // BAD [NOT DETECTED]
if ((int)c > 0) { // BAD
return 1;
}
}
@@ -280,7 +280,7 @@ int widening_cast1(u8 c) {
int widening_cast2(u8 c) {
if (c <= 10)
return -1;
else if ((c >= 11) /* BAD [NOT DETECTED] */ && (c <= 47))
else if ((c >= 11) /* BAD */ && (c <= 47))
return 0;
else
return 1;

View File

@@ -33,5 +33,7 @@
| PointlessComparison.c:197:7:197:11 | ... < ... | Comparison is always false because x >= 0. |
| PointlessComparison.c:210:6:210:10 | ... < ... | Comparison is always false because e >= 0. |
| PointlessComparison.c:264:12:264:22 | ... >= ... | Comparison is always true because dbl >= 0 and -0 >= - .... |
| PointlessComparison.c:273:9:273:18 | ... > ... | Comparison is always false because c <= 0. |
| PointlessComparison.c:283:13:283:19 | ... >= ... | Comparison is always true because c >= 11. |
| RegressionTests.cpp:57:7:57:22 | ... <= ... | Comparison is always true because * ... <= 4294967295. |
| Templates.cpp:9:10:9:24 | ... <= ... | Comparison is always true because local <= 32767. |