aboutsummaryrefslogtreecommitdiff
path: root/gcc/cil/tests/struct_op.c
blob: e89587664b4e58d6846f1217007feead093f7c98 (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
/*
 * This example tests operations on elements of type struct.
 */

typedef struct {
    int    a;
    double d;
} foo;

typedef struct {
    short s;
    foo   f;
} foo2;

int main()
{
    int one = 1;
    int three = 3;
    foo  f1[3] = {{one, 2.0}, {three, 4.0}, {5, 6.0}};
    foo2 f2 = {13, {8, 9.0}};

    f1[2] = f1[1];
    f2.f = f1[0];

    if (f1[2].a == 3 && f2.f.a == 1)
        return 0;
    else
        return 1;
}