diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected index d1a3f22d766..cb18638c71e 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsCompare.expected @@ -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 | diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected index 078d8aeea08..b35ec323266 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected @@ -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 ...: | diff --git a/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected b/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected index da36308f878..fdbdca43184 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected +++ b/cpp/ql/test/library-tests/controlflow/guards/GuardsEnsure.expected @@ -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 ...: | diff --git a/cpp/ql/test/library-tests/controlflow/guards/test.cpp b/cpp/ql/test/library-tests/controlflow/guards/test.cpp index 2ef61734e69..bb0fe83c7c7 100644 --- a/cpp/ql/test/library-tests/controlflow/guards/test.cpp +++ b/cpp/ql/test/library-tests/controlflow/guards/test.cpp @@ -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); + } } \ No newline at end of file