Mercurial > hg > CbC > old > device
view 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 |
line wrap: on
line source
int k=3; struct aa { int a[100]; } aaa,bbb; struct bb { int b[2]; } aaa1,bbb1; void tmp(void); struct aa main0(int); struct aa main0(int k) { int i; struct aa ccc; for(i=0;i<100;i++) ccc.a[i]=i; ccc.a[55]=k; return ccc; } struct aa main3(struct aa arg) { int j=++arg.a[55]; return main0(j); } void main2(struct aa a1) { /* main2 a1.a[99] 0 */ /* main2 a1.a[55] 0 */ /* main2 a1.a[99] 55 */ /* main2 a1.a[55] 44 */ printf("#0037:main2 a1.a[99] %d\n",a1.a[99]); printf("#0038:main2 a1.a[55] %d\n",a1.a[55]); } struct bb main5(struct aa a1,struct bb a2) { printf("#0044:main5 a1.a[99] %d\n",a1.a[99]); printf("#0045:main5 a1.a[55] %d\n",a1.a[55]); printf("#0046:main5 a2.b[0] %d\n",a2.b[0]); printf("#0047:main5 a2.b[1] %d\n",a2.b[1]); a2.b[0]=333; a2.b[1]=555; return a2; } void main1(struct aa a1) { /* main1 a1.a[0] 0 */ /* main1 a1.a[0] 44 */ printf("#0059:main1 a1.a[0] %d\n",a1.a[0]); a1.a[55]=44; if (a1.a[0]) main2(a1); else main2(aaa); } main(ac,av) int ac; char *av[]; { register int i; register char *p; int j = 3; struct { int b; void (*c)(struct aa); } q = {3,main1},r; struct aa *aap[3]; j = 3; bbb = main0(123); printf("#0081:copied main0 ccc.a[55] %d==123\n",bbb.a[55]); aap[2] = &bbb; *aap[2] = main0(123); printf("#0084:complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]); bbb.a[55]=0; j = main0(123).a[55]; printf("#0087:new main0 ccc.a[55] in temporal copy %d==123\n",j); j = 552; bbb = main3(bbb); printf("#0091:main3 bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]); j = main3(bbb).a[55]; printf("#0093:main3 bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]); j = main3(bbb).a[53]; printf("#0095:main3 bbb.a[55] in temporal copy %d==53 %d\n",j,bbb.a[53]); printf("#0097:%d==3\n",q.b); /* 3==3 */ r = q; printf("#0100:%d==3\n",r.b); /* 3==3 */ (*r.c)(aaa); printf("#0103:main aaa.a[55] %d\n",aaa.a[55]); /* main aaa.a[55] 123 */ bbb.a[0]=44; aaa = bbb; aaa.a[99]=55; /* core dump? */ (*r.c)(aaa); /* main aaa.a[55] 0 */ printf("#0110:main aaa.a[55] %d\n",aaa.a[55]); p = av[0]; if (!p) return; i = p[1]; p = p+i; /* 47 ./a.out */ printf("#0116:%d %s\n",i,p-i+3); aaa1.b[0]=33; aaa1.b[1]=55; bbb1 = main5(aaa,aaa1); printf("#0120:main5-2 %d\n", main5(bbb,bbb1).b[0]); printf("#0122:main5-1 %d\n", main5(bbb,main5(aaa,aaa1)).b[0]); return 0; } void tmp() { }