]> git.sur5r.net Git - cc65/blob - test/val/computedgoto.c
again, some TABs slipped into the code...
[cc65] / test / val / computedgoto.c
1 static unsigned char val, val2;
2
3 static void act(const unsigned char op) {
4
5         static const void * const arr[] = {
6                 &&op0,
7                 &&op1,
8                 &&op2,
9                 &&op3,
10                 &&op4,
11                 &&op5,
12                 &&op6,
13         };
14
15         goto *arr[op];
16
17         op0:
18         val += 1;
19         return;
20
21         op1:
22         val += 2;
23         return;
24
25         op2:
26         val += 3;
27         return;
28
29         op3:
30         val2 += 1;
31         return;
32
33         op4:
34         val2 += 5;
35         return;
36
37         op5:
38         val2 += 7;
39         return;
40
41         op6:
42         val2 += 9;
43         return;
44 }
45
46 int main(void) {
47
48         val = val2 = 0;
49
50         act(1);
51         act(3);
52         act(5);
53
54         return val == 2 && val2 == 8 ? 0 : 1;
55 }