Skip to content

Commit 3eca60c

Browse files
committed
C++: Add static local testcases.
1 parent ce64408 commit 3eca60c

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ postWithInFlow
115115
| test.cpp:602:3:602:7 | access to array [post update] | PostUpdateNode should not be the target of local flow. |
116116
| test.cpp:608:3:608:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
117117
| test.cpp:608:4:608:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
118+
| test.cpp:639:3:639:3 | x [post update] | PostUpdateNode should not be the target of local flow. |
119+
| test.cpp:646:3:646:3 | x [post update] | PostUpdateNode should not be the target of local flow. |
120+
| test.cpp:652:3:652:3 | x [post update] | PostUpdateNode should not be the target of local flow. |
121+
| test.cpp:653:3:653:3 | x [post update] | PostUpdateNode should not be the target of local flow. |
122+
| test.cpp:659:3:659:3 | x [post update] | PostUpdateNode should not be the target of local flow. |
123+
| test.cpp:660:3:660:3 | x [post update] | PostUpdateNode should not be the target of local flow. |
124+
| test.cpp:671:3:671:3 | s [post update] | PostUpdateNode should not be the target of local flow. |
125+
| test.cpp:681:3:681:3 | s [post update] | PostUpdateNode should not be the target of local flow. |
126+
| test.cpp:689:3:689:3 | s [post update] | PostUpdateNode should not be the target of local flow. |
127+
| test.cpp:690:3:690:3 | s [post update] | PostUpdateNode should not be the target of local flow. |
118128
viableImplInCallContextTooLarge
119129
uniqueParameterNodeAtPosition
120130
uniqueParameterNodePosition

cpp/ql/test/library-tests/dataflow/dataflow-tests/test.cpp

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,66 @@ void test_def_via_phi_read(bool b)
627627
}
628628
intPointerSource(buffer);
629629
sink(buffer); // $ ast,ir
630-
}
630+
}
631+
632+
void test_static_local_1() {
633+
static int x = source();
634+
sink(x); // $ ast,ir
635+
}
636+
637+
void test_static_local_2() {
638+
static int x = source();
639+
x = 0;
640+
sink(x); // clean
641+
}
642+
643+
void test_static_local_3() {
644+
static int x = 0;
645+
sink(x); // $ MISSING: ast, ir
646+
x = source();
647+
}
648+
649+
void test_static_local_4() {
650+
static int x = 0;
651+
sink(x); // clean
652+
x = source();
653+
x = 0;
654+
}
655+
656+
void test_static_local_5() {
657+
static int x = 0;
658+
sink(x); // $ MISSING: ast,ir
659+
x = 0;
660+
x = source();
661+
}
662+
663+
void test_static_local_6() {
664+
static int s = source();
665+
static int* ptr_to_s = &s;
666+
sink(*ptr_to_s); // $ MISSING: ast,ir
667+
}
668+
669+
void test_static_local_7() {
670+
static int s = source();
671+
s = 0;
672+
static int* ptr_to_s = &s;
673+
sink(*ptr_to_s); // clean
674+
}
675+
676+
void test_static_local_8() {
677+
static int s;
678+
static int* ptr_to_s = &s;
679+
sink(*ptr_to_s); // $ MISSING: ast,ir
680+
681+
s = source();
682+
}
683+
684+
void test_static_local_9() {
685+
static int s;
686+
static int* ptr_to_s = &s;
687+
sink(*ptr_to_s); // clean
688+
689+
s = source();
690+
s = 0;
691+
}
692+

0 commit comments

Comments
 (0)