annotate test/fact.c @ 572:388baa7d4bee

more strict errors. Undeclared identifier Goto to function, calling code segement
author kono
date Fri, 13 Jan 2006 01:51:39 +0900
parents 0c256ea2a97e
children 682c8ec38d45
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1 #include "stdio.h"
572
388baa7d4bee more strict errors.
kono
parents: 427
diff changeset
2 code print();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3 int
d35df41eac69 Initial revision
kono
parents:
diff changeset
4 main(ac,av)
d35df41eac69 Initial revision
kono
parents:
diff changeset
5 int ac;
d35df41eac69 Initial revision
kono
parents:
diff changeset
6 char *av[];
d35df41eac69 Initial revision
kono
parents:
diff changeset
7 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
8 int n;
172
096559f07a70 some check
kono
parents: 7
diff changeset
9 // n = atoi(av[1]);
096559f07a70 some check
kono
parents: 7
diff changeset
10 n = 10;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
11 goto factorial(n,1,n,print,return,environment);
d35df41eac69 Initial revision
kono
parents:
diff changeset
12 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
13
d35df41eac69 Initial revision
kono
parents:
diff changeset
14 code print(n,result,orig,print,exit1,exit1env)
d35df41eac69 Initial revision
kono
parents:
diff changeset
15 int n,result,orig;
d35df41eac69 Initial revision
kono
parents:
diff changeset
16 code (*print)(),(*exit1)();
d35df41eac69 Initial revision
kono
parents:
diff changeset
17 void *exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
18 {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 172
diff changeset
19 printf("#0018:%d! = %d\n",n, result);
172
096559f07a70 some check
kono
parents: 7
diff changeset
20 goto (*exit1)(0),exit1env;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
21 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
22
d35df41eac69 Initial revision
kono
parents:
diff changeset
23 code factorial(n,result,orig,print,exit1,exit1env)
d35df41eac69 Initial revision
kono
parents:
diff changeset
24 int n,result,orig;
d35df41eac69 Initial revision
kono
parents:
diff changeset
25 code (*print)();
d35df41eac69 Initial revision
kono
parents:
diff changeset
26 code (*exit1)();
d35df41eac69 Initial revision
kono
parents:
diff changeset
27 void *exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
28 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
29 if (n<0) {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 172
diff changeset
30 printf("#0029:err %d!\n",n);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
31 goto (*exit1)(0),exit1env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
32 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
33 if (n==0)
7
e2c2c0fe0785 function type definition should be in global heap
kono
parents: 0
diff changeset
34 goto (*print)(n,result,orig,print,exit1,exit1env);
e2c2c0fe0785 function type definition should be in global heap
kono
parents: 0
diff changeset
35 /* goto print(n,result,orig,print,exit1,exit1env); */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
36 else {
d35df41eac69 Initial revision
kono
parents:
diff changeset
37 result *= n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
38 n--;
d35df41eac69 Initial revision
kono
parents:
diff changeset
39 goto factorial(n,result,orig,print,exit1,exit1env);
d35df41eac69 Initial revision
kono
parents:
diff changeset
40 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
41 }