Mercurial > hg > CbC > old > device
annotate test/tmp7.c @ 449:c55363eff5e5
parallel assignment (modify not completed)
author | kono |
---|---|
date | Thu, 25 Nov 2004 16:56:26 +0900 |
parents | 0c256ea2a97e |
children | 32737bad7489 |
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 */ | |
427 | 38 printf("#0037:main2 a1.a[99] %d\n",a1.a[99]); |
39 printf("#0038: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 { |
427 | 45 printf("#0044:main5 a1.a[99] %d\n",a1.a[99]); |
46 printf("#0045:main5 a1.a[55] %d\n",a1.a[55]); | |
47 printf("#0046:main5 a2.b[0] %d\n",a2.b[0]); | |
48 printf("#0047:main5 a2.b[1] %d\n",a2.b[1]); | |
258
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 */ | |
427 | 60 printf("#0059:main1 a1.a[0] %d\n",a1.a[0]); |
15 | 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); |
427 | 82 printf("#0081:copied main0 ccc.a[55] %d==123\n",bbb.a[55]); |
39 | 83 aap[2] = &bbb; |
45 | 84 *aap[2] = main0(123); |
427 | 85 printf("#0084:complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]); |
39 | 86 bbb.a[55]=0; |
45 | 87 j = main0(123).a[55]; |
427 | 88 printf("#0087:new main0 ccc.a[55] in temporal copy %d==123\n",j); |
39 | 89 |
45 | 90 j = 552; |
91 bbb = main3(bbb); | |
427 | 92 printf("#0091:main3 bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]); |
45 | 93 j = main3(bbb).a[55]; |
427 | 94 printf("#0093:main3 bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]); |
45 | 95 j = main3(bbb).a[53]; |
427 | 96 printf("#0095:main3 bbb.a[55] in temporal copy %d==53 %d\n",j,bbb.a[53]); |
45 | 97 |
427 | 98 printf("#0097:%d==3\n",q.b); |
37 | 99 /* 3==3 */ |
0 | 100 r = q; |
427 | 101 printf("#0100:%d==3\n",r.b); |
37 | 102 /* 3==3 */ |
15 | 103 (*r.c)(aaa); |
427 | 104 printf("#0103: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 */ |
427 | 111 printf("#0110: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 */ |
427 | 117 printf("#0116:%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); |
427 | 121 printf("#0120:main5-2 %d\n", |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
122 main5(bbb,bbb1).b[0]); |
427 | 123 printf("#0122:main5-1 %d\n", |
258
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 |