Skip to content

Commit 0f21075

Browse files
committed
C++: Add a test that demonstrate missing asExpr for aggregate literals.
1 parent 8a1987a commit 0f21075

File tree

1 file changed

+17
-0
lines changed
  • cpp/ql/test/library-tests/dataflow/asExpr

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,20 @@ A& get_ref();
2121
void test2() {
2222
take_ref(get_ref()); // $ asExpr="call to get_ref" asIndirectExpr="call to get_ref"
2323
}
24+
25+
struct S {
26+
int a;
27+
int b;
28+
};
29+
30+
void test_aggregate_literal() {
31+
S s1 = {1, 2}; // $ asExpr=1 asExpr=2
32+
const S s2 = {3, 4}; // $ asExpr=3 asExpr=4
33+
S s3 = (S){5, 6}; // $ asExpr=5 asExpr=6
34+
const S s4 = (S){7, 8}; // $ asExpr=7 asExpr=8
35+
36+
S s5 = {.a = 1, .b = 2}; // $ asExpr=1 asExpr=2
37+
38+
int xs[] = {1, 2, 3}; // $ asExpr=1 asExpr=2 asExpr=3
39+
const int ys[] = {[0] = 4, [1] = 5, [0] = 6}; // $ asExpr=4 asExpr=5 asExpr=6
40+
}

0 commit comments

Comments
 (0)