mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
CPP: Add test case.
This commit is contained in:
@@ -3,3 +3,4 @@
|
||||
| test.cpp:83:10:83:15 | ... == ... | Self comparison. |
|
||||
| test.cpp:90:10:90:15 | ... == ... | Self comparison. |
|
||||
| test.cpp:118:7:118:32 | ... != ... | Self comparison. |
|
||||
| test.cpp:145:2:145:30 | ... == ... | Self comparison. |
|
||||
|
||||
@@ -123,3 +123,24 @@ int isSmallEnough(unsigned long long x) {
|
||||
// get compiled away on others.
|
||||
return x == (size_t)x && x == (u64)x; // GOOD
|
||||
}
|
||||
|
||||
#define markRange(str, x, y) \
|
||||
if ((x) == (y)) { \
|
||||
str[x] = '^'; \
|
||||
} else { \
|
||||
int i; \
|
||||
str[x] = '<'; \
|
||||
for (i = x + 1; i < y; i++) { \
|
||||
str[i] = '-'; \
|
||||
} \
|
||||
str[y] = '>'; \
|
||||
}
|
||||
|
||||
void useMarkRange(int offs) {
|
||||
char buffer[100];
|
||||
|
||||
markRange(buffer, 10, 20);
|
||||
markRange(buffer, 30, 30);
|
||||
markRange(buffer, offs, offs + 10);
|
||||
markRange(buffer, offs, offs); // GOOD (comparison is in the macro) [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user