mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++: Add testcase demonstrating that a ConstantValue IPA branch representing a gcc case range is a bad idea.
This commit is contained in:
@@ -1296,3 +1296,15 @@
|
||||
| test.cpp:318:7:318:12 | ... < ... | a < 42+0 when ... < ... is true |
|
||||
| test.cpp:318:7:318:12 | ... < ... | a >= 42 when ... < ... is false |
|
||||
| test.cpp:318:7:318:12 | ... < ... | a >= 42+0 when ... < ... is false |
|
||||
| test.cpp:327:46:327:46 | b | b != 0 when b is true |
|
||||
| test.cpp:327:46:327:46 | b | b != 1 when b is false |
|
||||
| test.cpp:327:46:327:46 | b | b == 0 when b is false |
|
||||
| test.cpp:327:46:327:46 | b | b == 1 when b is true |
|
||||
| test.cpp:330:7:330:7 | b | b != 0 when b is true |
|
||||
| test.cpp:330:7:330:7 | b | b != 1 when b is false |
|
||||
| test.cpp:330:7:330:7 | b | b == 0 when b is false |
|
||||
| test.cpp:330:7:330:7 | b | b == 1 when b is true |
|
||||
| test.cpp:334:11:334:11 | x | x < 51 when x is 40..50 |
|
||||
| test.cpp:334:11:334:11 | x | x >= 40 when x is 40..50 |
|
||||
| test.cpp:338:9:338:9 | x | x < 51 when x is 40..50 |
|
||||
| test.cpp:338:9:338:9 | x | x >= 40 when x is 40..50 |
|
||||
|
||||
@@ -328,3 +328,9 @@
|
||||
| test.cpp:318:6:318:18 | ... != ... | true | test.cpp:318:21:320:3 | { ... } |
|
||||
| test.cpp:318:7:318:12 | ... < ... | 0 | test.cpp:320:10:322:3 | { ... } |
|
||||
| test.cpp:318:7:318:12 | ... < ... | not 0 | test.cpp:318:21:320:3 | { ... } |
|
||||
| test.cpp:327:46:327:46 | b | false | test.cpp:336:3:338:7 | case ...: |
|
||||
| test.cpp:327:46:327:46 | b | true | test.cpp:331:3:332:10 | { ... } |
|
||||
| test.cpp:329:11:329:13 | call to foo | 40..50 | test.cpp:336:3:338:7 | case ...: |
|
||||
| test.cpp:330:7:330:7 | b | false | test.cpp:336:3:338:7 | case ...: |
|
||||
| test.cpp:330:7:330:7 | b | true | test.cpp:331:3:332:10 | { ... } |
|
||||
| test.cpp:334:11:334:11 | x | 40..50 | test.cpp:336:3:338:7 | case ...: |
|
||||
|
||||
@@ -1294,3 +1294,13 @@ unary
|
||||
| test.cpp:318:6:318:18 | ... != ... | test.cpp:318:7:318:7 | a | >= | 42 | test.cpp:320:10:322:3 | { ... } |
|
||||
| test.cpp:318:6:318:18 | ... != ... | test.cpp:318:7:318:12 | ... < ... | != | 0 | test.cpp:318:21:320:3 | { ... } |
|
||||
| test.cpp:318:6:318:18 | ... != ... | test.cpp:318:7:318:12 | ... < ... | == | 0 | test.cpp:320:10:322:3 | { ... } |
|
||||
| test.cpp:327:46:327:46 | b | test.cpp:330:7:330:7 | b | != | 0 | test.cpp:331:3:332:10 | { ... } |
|
||||
| test.cpp:327:46:327:46 | b | test.cpp:330:7:330:7 | b | != | 1 | test.cpp:336:3:338:7 | case ...: |
|
||||
| test.cpp:327:46:327:46 | b | test.cpp:330:7:330:7 | b | == | 0 | test.cpp:336:3:338:7 | case ...: |
|
||||
| test.cpp:327:46:327:46 | b | test.cpp:330:7:330:7 | b | == | 1 | test.cpp:331:3:332:10 | { ... } |
|
||||
| test.cpp:330:7:330:7 | b | test.cpp:330:7:330:7 | b | != | 0 | test.cpp:331:3:332:10 | { ... } |
|
||||
| test.cpp:330:7:330:7 | b | test.cpp:330:7:330:7 | b | != | 1 | test.cpp:336:3:338:7 | case ...: |
|
||||
| test.cpp:330:7:330:7 | b | test.cpp:330:7:330:7 | b | == | 0 | test.cpp:336:3:338:7 | case ...: |
|
||||
| test.cpp:330:7:330:7 | b | test.cpp:330:7:330:7 | b | == | 1 | test.cpp:331:3:332:10 | { ... } |
|
||||
| test.cpp:334:11:334:11 | x | test.cpp:334:11:334:11 | x | < | 51 | test.cpp:336:3:338:7 | case ...: |
|
||||
| test.cpp:334:11:334:11 | x | test.cpp:334:11:334:11 | x | >= | 40 | test.cpp:336:3:338:7 | case ...: |
|
||||
|
||||
@@ -320,4 +320,21 @@ void test_cmp_implies_unary(int a) {
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int foo();
|
||||
|
||||
void test_constant_value_and_case_range(bool b)
|
||||
{
|
||||
int x = foo();
|
||||
if (b)
|
||||
{
|
||||
x = 42;
|
||||
}
|
||||
switch (x)
|
||||
{
|
||||
case 40 ... 50:
|
||||
// should not be guarded by `foo() = 40..50`
|
||||
use(x);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user