Mercurial > hg > CbC > old > device
annotate test/tmp7.c @ 172:096559f07a70
some check
author | kono |
---|---|
date | Tue, 25 Nov 2003 11:47:41 +0900 |
parents | b1c8ac8c308d |
children | 22949117768f |
rev | line source |
---|---|
0 | 1 |
2 | |
13 | 3 int k=3; |
4 | |
5 struct aa { int a[100]; } aaa,bbb; | |
6 | |
0 | 7 void tmp(void); |
8 | |
16 | 9 struct aa |
45 | 10 main0(int); |
0 | 11 |
16 | 12 struct aa |
45 | 13 main0(int k) |
0 | 14 { |
39 | 15 int i; |
16 | 16 struct aa ccc; |
39 | 17 |
18 for(i=0;i<100;i++) ccc.a[i]=i; | |
45 | 19 ccc.a[55]=k; |
16 | 20 return ccc; |
0 | 21 } |
22 | |
45 | 23 struct aa |
24 main3(struct aa arg) | |
25 { | |
26 int j=++arg.a[55]; | |
27 return main0(j); | |
28 } | |
29 | |
8 | 30 void |
31 main2(struct aa a1) | |
32 { | |
37 | 33 /* main2 a1.a[99] 0 */ |
34 /* main2 a1.a[55] 0 */ | |
35 /* main2 a1.a[99] 55 */ | |
36 /* main2 a1.a[55] 44 */ | |
15 | 37 printf("main2 a1.a[99] %d\n",a1.a[99]); |
38 printf("main2 a1.a[55] %d\n",a1.a[55]); | |
8 | 39 } |
40 | |
16 | 41 void |
0 | 42 main1(struct aa a1) |
43 { | |
37 | 44 /* main1 a1.a[0] 0 */ |
45 /* main1 a1.a[0] 44 */ | |
15 | 46 printf("main1 a1.a[0] %d\n",a1.a[0]); |
47 a1.a[55]=44; | |
0 | 48 if (a1.a[0]) |
8 | 49 main2(a1); |
0 | 50 else |
8 | 51 main2(aaa); |
0 | 52 } |
53 | |
13 | 54 |
0 | 55 main(ac,av) |
56 int ac; | |
57 char *av[]; | |
58 { | |
59 register int i; | |
60 register char *p; | |
61 int j = 3; | |
16 | 62 struct { int b; void (*c)(struct aa); } q = {3,main1},r; |
39 | 63 struct aa *aap[3]; |
0 | 64 |
65 j = 3; | |
66 | |
45 | 67 bbb = main0(123); |
39 | 68 printf("copied main0 ccc.a[55] %d==123\n",bbb.a[55]); |
69 aap[2] = &bbb; | |
45 | 70 *aap[2] = main0(123); |
39 | 71 printf("complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]); |
72 bbb.a[55]=0; | |
45 | 73 j = main0(123).a[55]; |
39 | 74 printf("new main0 ccc.a[55] in temporal copy %d==123\n",j); |
75 | |
45 | 76 j = 552; |
77 bbb = main3(bbb); | |
78 printf("main3 bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]); | |
79 j = main3(bbb).a[55]; | |
80 printf("main3 bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]); | |
81 j = main3(bbb).a[53]; | |
46
b1c8ac8c308d
fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
45
diff
changeset
|
82 printf("main3 bbb.a[55] in temporal copy %d==53 %d\n",j,bbb.a[53]); |
45 | 83 |
15 | 84 printf("%d==3\n",q.b); |
37 | 85 /* 3==3 */ |
0 | 86 r = q; |
15 | 87 printf("%d==3\n",r.b); |
37 | 88 /* 3==3 */ |
15 | 89 (*r.c)(aaa); |
90 printf("main aaa.a[55] %d\n",aaa.a[55]); | |
37 | 91 /* main aaa.a[55] 123 */ |
15 | 92 bbb.a[0]=44; |
0 | 93 aaa = bbb; |
15 | 94 aaa.a[99]=55; /* core dump? */ |
95 (*r.c)(aaa); | |
37 | 96 /* main aaa.a[55] 0 */ |
15 | 97 printf("main aaa.a[55] %d\n",aaa.a[55]); |
8 | 98 p = av[0]; |
0 | 99 if (!p) return; |
100 i = p[1]; | |
101 p = p+i; | |
37 | 102 /* 47 ./a.out */ |
172 | 103 printf("%d %s\n",i,p-i+3); |
104 return 0; | |
0 | 105 } |
106 | |
13 | 107 void |
0 | 108 tmp() |
109 { | |
110 } | |
37 | 111 |
112 |