summaryrefslogtreecommitdiffstats
path: root/tests/byte-code/composite.slang
blob: 41729b6c284232891426d110d68c8b0970156a50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//TEST:INTERPRET(filecheck=CHECK):
struct Inner
{
    int header;
    int array[3];
}
struct MyType
{
    float3 value1;
    float3 value2;
    Inner inner;
}
MyType getValue()
{
    MyType t = { float3(1, 2, 3), float3(-1,-2, 3), { 4, { 5, 6, 7 } } };
    return t;
}
int main()
{
    var t = getValue();
    int sum = 0;
    for (int i = 0; i < 3; ++i)
    {
        sum += t.inner.array[i];
    }
    t.value1 += t.value2;
    for (int i = 0; i < 3; i++)
    {
        sum += (int)t.value1[i];
    }
    //CHECK: 24
    printf("%d\n", sum);
    return 0;
}