Mercurial > hg > CbC > old > device
annotate test/tmp7.c @ 496:5640fb7a270d
more bugs...
author | kono |
---|---|
date | Thu, 22 Dec 2005 00:20:09 +0900 |
parents | a379da780856 |
children | aad312f61654 |
rev | line source |
---|---|
467 | 1 int printf(const char *format, ...); |
0 | 2 |
3 | |
13 | 4 int k=3; |
5 | |
6 struct aa { int a[100]; } aaa,bbb; | |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
7 struct bb { int b[2]; } aaa1,bbb1; |
13 | 8 |
0 | 9 void tmp(void); |
10 | |
16 | 11 struct aa |
45 | 12 main0(int); |
0 | 13 |
16 | 14 struct aa |
45 | 15 main0(int k) |
0 | 16 { |
39 | 17 int i; |
16 | 18 struct aa ccc; |
39 | 19 |
20 for(i=0;i<100;i++) ccc.a[i]=i; | |
45 | 21 ccc.a[55]=k; |
16 | 22 return ccc; |
0 | 23 } |
24 | |
45 | 25 struct aa |
26 main3(struct aa arg) | |
27 { | |
28 int j=++arg.a[55]; | |
29 return main0(j); | |
30 } | |
31 | |
8 | 32 void |
33 main2(struct aa a1) | |
34 { | |
37 | 35 /* main2 a1.a[99] 0 */ |
36 /* main2 a1.a[55] 0 */ | |
37 /* main2 a1.a[99] 55 */ | |
38 /* main2 a1.a[55] 44 */ | |
491 | 39 printf("#0038:main2 a1.a[99] %d\n",a1.a[99]); |
40 printf("#0039:main2 a1.a[55] %d\n",a1.a[55]); | |
8 | 41 } |
42 | |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
43 struct bb |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
44 main5(struct aa a1,struct bb a2) |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
45 { |
491 | 46 printf("#0045:main5 a1.a[99] %d\n",a1.a[99]); |
47 printf("#0046:main5 a1.a[55] %d\n",a1.a[55]); | |
48 printf("#0047:main5 a2.b[0] %d\n",a2.b[0]); | |
49 printf("#0048: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
|
50 a2.b[0]=333; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
51 a2.b[1]=555; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
52 return a2; |
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 |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
55 |
16 | 56 void |
0 | 57 main1(struct aa a1) |
58 { | |
37 | 59 /* main1 a1.a[0] 0 */ |
60 /* main1 a1.a[0] 44 */ | |
491 | 61 printf("#0060:main1 a1.a[0] %d\n",a1.a[0]); |
15 | 62 a1.a[55]=44; |
0 | 63 if (a1.a[0]) |
8 | 64 main2(a1); |
0 | 65 else |
8 | 66 main2(aaa); |
0 | 67 } |
68 | |
487 | 69 int |
0 | 70 main(ac,av) |
71 int ac; | |
72 char *av[]; | |
73 { | |
74 register int i; | |
75 register char *p; | |
76 int j = 3; | |
16 | 77 struct { int b; void (*c)(struct aa); } q = {3,main1},r; |
39 | 78 struct aa *aap[3]; |
0 | 79 |
80 j = 3; | |
81 | |
45 | 82 bbb = main0(123); |
491 | 83 printf("#0082:copied main0 ccc.a[55] %d==123\n",bbb.a[55]); |
39 | 84 aap[2] = &bbb; |
45 | 85 *aap[2] = main0(123); |
491 | 86 printf("#0085:complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]); |
39 | 87 bbb.a[55]=0; |
45 | 88 j = main0(123).a[55]; |
491 | 89 printf("#0088:new main0 ccc.a[55] in temporal copy %d==123\n",j); |
39 | 90 |
45 | 91 j = 552; |
92 bbb = main3(bbb); | |
491 | 93 printf("#0092:main3 bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]); |
45 | 94 j = main3(bbb).a[55]; |
491 | 95 printf("#0094:main3 bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]); |
45 | 96 j = main3(bbb).a[53]; |
491 | 97 printf("#0096:main3 bbb.a[55] in temporal copy %d==53 %d\n",j,bbb.a[53]); |
45 | 98 |
491 | 99 printf("#0098:%d==3\n",q.b); |
37 | 100 /* 3==3 */ |
0 | 101 r = q; |
491 | 102 printf("#0101:%d==3\n",r.b); |
37 | 103 /* 3==3 */ |
15 | 104 (*r.c)(aaa); |
491 | 105 printf("#0104:main aaa.a[55] %d\n",aaa.a[55]); |
37 | 106 /* main aaa.a[55] 123 */ |
15 | 107 bbb.a[0]=44; |
0 | 108 aaa = bbb; |
15 | 109 aaa.a[99]=55; /* core dump? */ |
110 (*r.c)(aaa); | |
37 | 111 /* main aaa.a[55] 0 */ |
491 | 112 printf("#0111:main aaa.a[55] %d\n",aaa.a[55]); |
8 | 113 p = av[0]; |
487 | 114 if (!p) return 55; |
0 | 115 i = p[1]; |
116 p = p+i; | |
37 | 117 /* 47 ./a.out */ |
491 | 118 printf("#0117:%d %s\n",i,p-i+3); |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
119 aaa1.b[0]=33; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
120 aaa1.b[1]=55; |
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
121 bbb1 = main5(aaa,aaa1); |
491 | 122 printf("#0121:main5-2 %d\n", |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
123 main5(bbb,bbb1).b[0]); |
491 | 124 printf("#0123:main5-1 %d\n", |
258
22949117768f
Complex function argments. Struct is done. Long long is odd.
kono
parents:
172
diff
changeset
|
125 main5(bbb,main5(aaa,aaa1)).b[0]); |
172 | 126 return 0; |
0 | 127 } |
128 | |
13 | 129 void |
0 | 130 tmp() |
131 { | |
132 } | |
37 | 133 |
134 |