C++: Add a test that demonstrate missing asExpr for aggregate literals.

This commit is contained in:
Mathias Vorreiter Pedersen
2025-05-14 17:59:01 +01:00
parent 8a1987ab71
commit 0f21075722

View File

@@ -21,3 +21,20 @@ A& get_ref();
void test2() {
take_ref(get_ref()); // $ asExpr="call to get_ref" asIndirectExpr="call to get_ref"
}
struct S {
int a;
int b;
};
void test_aggregate_literal() {
S s1 = {1, 2}; // $ asExpr=1 asExpr=2
const S s2 = {3, 4}; // $ asExpr=3 asExpr=4
S s3 = (S){5, 6}; // $ asExpr=5 asExpr=6
const S s4 = (S){7, 8}; // $ asExpr=7 asExpr=8
S s5 = {.a = 1, .b = 2}; // $ asExpr=1 asExpr=2
int xs[] = {1, 2, 3}; // $ asExpr=1 asExpr=2 asExpr=3
const int ys[] = {[0] = 4, [1] = 5, [0] = 6}; // $ asExpr=4 asExpr=5 asExpr=6
}