Mercurial > hg > CbC > old > device
annotate test/tmp7.c @ 417:98888da30b35
code jump fixes (not finished)
author | kono |
---|---|
date | Mon, 25 Oct 2004 01:16:28 +0900 |
parents | 22949117768f |
children | 0c256ea2a97e |
rev | line source |
---|---|
0 | 1 |
2 | |
13 | 3 int k=3; |
4 | |
5 struct aa { int a[100]; } aaa,bbb; | |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
6 struct bb { int b[2]; } aaa1,bbb1; |
13 | 7 |
0 | 8 void tmp(void); |
9 | |
16 | 10 struct aa |
45 | 11 main0(int); |
0 | 12 |
16 | 13 struct aa |
45 | 14 main0(int k) |
0 | 15 { |
39 | 16 int i; |
16 | 17 struct aa ccc; |
39 | 18 |
19 for(i=0;i<100;i++) ccc.a[i]=i; | |
45 | 20 ccc.a[55]=k; |
16 | 21 return ccc; |
0 | 22 } |
23 | |
45 | 24 struct aa |
25 main3(struct aa arg) | |
26 { | |
27 int j=++arg.a[55]; | |
28 return main0(j); | |
29 } | |
30 | |
8 | 31 void |
32 main2(struct aa a1) | |
33 { | |
37 | 34 /* main2 a1.a[99] 0 */ |
35 /* main2 a1.a[55] 0 */ | |
36 /* main2 a1.a[99] 55 */ | |
37 /* main2 a1.a[55] 44 */ | |
15 | 38 printf("main2 a1.a[99] %d\n",a1.a[99]); |
39 printf("main2 a1.a[55] %d\n",a1.a[55]); | |
8 | 40 } |
41 | |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
42 struct bb |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
43 main5(struct aa a1,struct bb a2) |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
44 { |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
45 printf("main5 a1.a[99] %d\n",a1.a[99]); |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
46 printf("main5 a1.a[55] %d\n",a1.a[55]); |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
47 printf("main5 a2.b[0] %d\n",a2.b[0]); |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
48 printf("main5 a2.b[1] %d\n",a2.b[1]); |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
49 a2.b[0]=333; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
50 a2.b[1]=555; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
51 return a2; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
52 } |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
53 |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
54 |
16 | 55 void |
0 | 56 main1(struct aa a1) |
57 { | |
37 | 58 /* main1 a1.a[0] 0 */ |
59 /* main1 a1.a[0] 44 */ | |
15 | 60 printf("main1 a1.a[0] %d\n",a1.a[0]); |
61 a1.a[55]=44; | |
0 | 62 if (a1.a[0]) |
8 | 63 main2(a1); |
0 | 64 else |
8 | 65 main2(aaa); |
0 | 66 } |
67 | |
13 | 68 |
0 | 69 main(ac,av) |
70 int ac; | |
71 char *av[]; | |
72 { | |
73 register int i; | |
74 register char *p; | |
75 int j = 3; | |
16 | 76 struct { int b; void (*c)(struct aa); } q = {3,main1},r; |
39 | 77 struct aa *aap[3]; |
0 | 78 |
79 j = 3; | |
80 | |
45 | 81 bbb = main0(123); |
39 | 82 printf("copied main0 ccc.a[55] %d==123\n",bbb.a[55]); |
83 aap[2] = &bbb; | |
45 | 84 *aap[2] = main0(123); |
39 | 85 printf("complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]); |
86 bbb.a[55]=0; | |
45 | 87 j = main0(123).a[55]; |
39 | 88 printf("new main0 ccc.a[55] in temporal copy %d==123\n",j); |
89 | |
45 | 90 j = 552; |
91 bbb = main3(bbb); | |
92 printf("main3 bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]); | |
93 j = main3(bbb).a[55]; | |
94 printf("main3 bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]); | |
95 j = main3(bbb).a[53]; | |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
45
diff
changeset
|
96 printf("main3 bbb.a[55] in temporal copy %d==53 %d\n",j,bbb.a[53]); |
45 | 97 |
15 | 98 printf("%d==3\n",q.b); |
37 | 99 /* 3==3 */ |
0 | 100 r = q; |
15 | 101 printf("%d==3\n",r.b); |
37 | 102 /* 3==3 */ |
15 | 103 (*r.c)(aaa); |
104 printf("main aaa.a[55] %d\n",aaa.a[55]); | |
37 | 105 /* main aaa.a[55] 123 */ |
15 | 106 bbb.a[0]=44; |
0 | 107 aaa = bbb; |
15 | 108 aaa.a[99]=55; /* core dump? */ |
109 (*r.c)(aaa); | |
37 | 110 /* main aaa.a[55] 0 */ |
15 | 111 printf("main aaa.a[55] %d\n",aaa.a[55]); |
8 | 112 p = av[0]; |
0 | 113 if (!p) return; |
114 i = p[1]; | |
115 p = p+i; | |
37 | 116 /* 47 ./a.out */ |
172 | 117 printf("%d %s\n",i,p-i+3); |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
118 aaa1.b[0]=33; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
119 aaa1.b[1]=55; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
120 bbb1 = main5(aaa,aaa1); |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
121 printf("main5-2 %d\n", |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
122 main5(bbb,bbb1).b[0]); |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
123 printf("main5-1 %d\n", |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
124 main5(bbb,main5(aaa,aaa1)).b[0]); |
172 | 125 return 0; |
0 | 126 } |
127 | |
13 | 128 void |
0 | 129 tmp() |
130 { | |
131 } | |
37 | 132 |
133 |