From 3eca60cc4081b65f7ca8724ef7caa6a900c55c16 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Fri, 28 Apr 2023 10:23:36 +0100 Subject: [PATCH] C++: Add static local testcases. --- .../dataflow-consistency.expected | 10 +++ .../dataflow/dataflow-tests/test.cpp | 64 ++++++++++++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected b/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected index 0750c1af392..e913ac5e0fa 100644 --- a/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected +++ b/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected @@ -115,6 +115,16 @@ postWithInFlow | test.cpp:602:3:602:7 | access to array [post update] | PostUpdateNode should not be the target of local flow. | | test.cpp:608:3:608:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. | | test.cpp:608:4:608:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:639:3:639:3 | x [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:646:3:646:3 | x [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:652:3:652:3 | x [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:653:3:653:3 | x [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:659:3:659:3 | x [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:660:3:660:3 | x [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:671:3:671:3 | s [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:681:3:681:3 | s [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:689:3:689:3 | s [post update] | PostUpdateNode should not be the target of local flow. | +| test.cpp:690:3:690:3 | s [post update] | PostUpdateNode should not be the target of local flow. | viableImplInCallContextTooLarge uniqueParameterNodeAtPosition uniqueParameterNodePosition diff --git a/cpp/ql/test/library-tests/dataflow/dataflow-tests/test.cpp b/cpp/ql/test/library-tests/dataflow/dataflow-tests/test.cpp index 36b78896179..3e846882b0d 100644 --- a/cpp/ql/test/library-tests/dataflow/dataflow-tests/test.cpp +++ b/cpp/ql/test/library-tests/dataflow/dataflow-tests/test.cpp @@ -627,4 +627,66 @@ void test_def_via_phi_read(bool b) } intPointerSource(buffer); sink(buffer); // $ ast,ir -} \ No newline at end of file +} + +void test_static_local_1() { + static int x = source(); + sink(x); // $ ast,ir +} + +void test_static_local_2() { + static int x = source(); + x = 0; + sink(x); // clean +} + +void test_static_local_3() { + static int x = 0; + sink(x); // $ MISSING: ast, ir + x = source(); +} + +void test_static_local_4() { + static int x = 0; + sink(x); // clean + x = source(); + x = 0; +} + +void test_static_local_5() { + static int x = 0; + sink(x); // $ MISSING: ast,ir + x = 0; + x = source(); +} + +void test_static_local_6() { + static int s = source(); + static int* ptr_to_s = &s; + sink(*ptr_to_s); // $ MISSING: ast,ir +} + +void test_static_local_7() { + static int s = source(); + s = 0; + static int* ptr_to_s = &s; + sink(*ptr_to_s); // clean +} + +void test_static_local_8() { + static int s; + static int* ptr_to_s = &s; + sink(*ptr_to_s); // $ MISSING: ast,ir + + s = source(); +} + +void test_static_local_9() { + static int s; + static int* ptr_to_s = &s; + sink(*ptr_to_s); // clean + + s = source(); + s = 0; +} +