summaryrefslogtreecommitdiffstats
path: root/libacc/tests/data/assignmentop.c
blob: 649edf9b6f32b98f818db64d27f723cfb0e2fa93 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Test assignment operations

void testAssignment() {
    int a = 2;
    a *= 5;
    printf("2 *= 5  %d\n", a);
    a = 20;
    a /= 5;
    printf("20 /= 5  %d\n", a);
    a = 17;
    a %= 5;
    printf("17 %%= 5  %d\n", a);
    a = 17;
    a += 5;
    printf("17 += 5  %d\n", a);
    a = 17;
    a-=5;
    printf("17 -= 5  %d\n", a);
    a = 17;
    a<<=1;
    printf("17<<= 1  %d\n", a);
    a = 17;
    a>>=1;
    printf("17>>= 1  %d\n", a);
    a = 17;
    a&=1;
    printf("17&= 1  %d\n", a);
    a = 17;
    a^=1;
    printf("17^= 1  %d\n", a);
    a = 16;
    a^=1;
    printf("16|= 1  %d\n", a);
}

int a;

int* f() {
    printf("f()\n");
    return &a;
}

void testEval() {
    a = 0;
    printf("*f() = *f() + 10;\n");
    *f() = *f() + 10;
    printf("a = %d\n", a);
}

void testOpEval() {
    a = 0;
    printf("*f() += 10;\n");
    *f() += 10;
    printf("a = %d\n", a);
}

int main() {
    testAssignment();
    testEval();
    testOpEval();
    return 0;
}