Mercurial > hg > CbC > old > device
view test/tmp7.c @ 275:8f09f8bbc494
MIPS switch statement. basic.c passed.
author | kono |
---|---|
date | Fri, 21 May 2004 14:00:02 +0900 |
parents | 22949117768f |
children | 0c256ea2a97e |
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("main2 a1.a[99] %d\n",a1.a[99]); printf("main2 a1.a[55] %d\n",a1.a[55]); } struct bb main5(struct aa a1,struct bb a2) { printf("main5 a1.a[99] %d\n",a1.a[99]); printf("main5 a1.a[55] %d\n",a1.a[55]); printf("main5 a2.b[0] %d\n",a2.b[0]); printf("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("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("copied main0 ccc.a[55] %d==123\n",bbb.a[55]); aap[2] = &bbb; *aap[2] = main0(123); printf("complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]); bbb.a[55]=0; j = main0(123).a[55]; printf("new main0 ccc.a[55] in temporal copy %d==123\n",j); j = 552; bbb = main3(bbb); printf("main3 bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]); j = main3(bbb).a[55]; printf("main3 bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]); j = main3(bbb).a[53]; printf("main3 bbb.a[55] in temporal copy %d==53 %d\n",j,bbb.a[53]); printf("%d==3\n",q.b); /* 3==3 */ r = q; printf("%d==3\n",r.b); /* 3==3 */ (*r.c)(aaa); printf("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("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("%d %s\n",i,p-i+3); aaa1.b[0]=33; aaa1.b[1]=55; bbb1 = main5(aaa,aaa1); printf("main5-2 %d\n", main5(bbb,bbb1).b[0]); printf("main5-1 %d\n", main5(bbb,main5(aaa,aaa1)).b[0]); return 0; } void tmp() { }