annotate test/tmp7.c @ 492:cc1a5f764782

*** empty log message ***
author kono
date Wed, 21 Dec 2005 12:10:43 +0900
parents a379da780856
children aad312f61654
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
467
32737bad7489 fix list/tag interference
kono
parents: 427
diff changeset
1 int printf(const char *format, ...);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2
d35df41eac69 Initial revision
kono
parents:
diff changeset
3
13
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
4 int k=3;
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
5
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
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
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
8
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
9 void tmp(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
10
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
11 struct aa
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
12 main0(int);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
13
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
14 struct aa
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
15 main0(int k)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
16 {
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
17 int i;
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
18 struct aa ccc;
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
19
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
20 for(i=0;i<100;i++) ccc.a[i]=i;
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
21 ccc.a[55]=k;
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
22 return ccc;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
23 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
24
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
25 struct aa
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
26 main3(struct aa arg)
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
27 {
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
28 int j=++arg.a[55];
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
29 return main0(j);
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
30 }
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
31
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
32 void
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
33 main2(struct aa a1)
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
34 {
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
35 /* main2 a1.a[99] 0 */
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
36 /* main2 a1.a[55] 0 */
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
37 /* main2 a1.a[99] 55 */
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
38 /* main2 a1.a[55] 44 */
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
39 printf("#0038:main2 a1.a[99] %d\n",a1.a[99]);
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
40 printf("#0039:main2 a1.a[55] %d\n",a1.a[55]);
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
41 }
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
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
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
46 printf("#0045:main5 a1.a[99] %d\n",a1.a[99]);
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
47 printf("#0046:main5 a1.a[55] %d\n",a1.a[55]);
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
48 printf("#0047:main5 a2.b[0] %d\n",a2.b[0]);
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
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
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
56 void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
57 main1(struct aa a1)
d35df41eac69 Initial revision
kono
parents:
diff changeset
58 {
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
59 /* main1 a1.a[0] 0 */
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
60 /* main1 a1.a[0] 44 */
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
61 printf("#0060:main1 a1.a[0] %d\n",a1.a[0]);
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
62 a1.a[55]=44;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
63 if (a1.a[0])
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
64 main2(a1);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
65 else
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
66 main2(aaa);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
67 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
68
487
b4d9809d6ee2 type attribute (half done)
kono
parents: 467
diff changeset
69 int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
70 main(ac,av)
d35df41eac69 Initial revision
kono
parents:
diff changeset
71 int ac;
d35df41eac69 Initial revision
kono
parents:
diff changeset
72 char *av[];
d35df41eac69 Initial revision
kono
parents:
diff changeset
73 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
74 register int i;
d35df41eac69 Initial revision
kono
parents:
diff changeset
75 register char *p;
d35df41eac69 Initial revision
kono
parents:
diff changeset
76 int j = 3;
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
77 struct { int b; void (*c)(struct aa); } q = {3,main1},r;
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
78 struct aa *aap[3];
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
79
d35df41eac69 Initial revision
kono
parents:
diff changeset
80 j = 3;
d35df41eac69 Initial revision
kono
parents:
diff changeset
81
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
82 bbb = main0(123);
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
83 printf("#0082:copied main0 ccc.a[55] %d==123\n",bbb.a[55]);
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
84 aap[2] = &bbb;
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
85 *aap[2] = main0(123);
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
86 printf("#0085:complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]);
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
87 bbb.a[55]=0;
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
88 j = main0(123).a[55];
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
89 printf("#0088:new main0 ccc.a[55] in temporal copy %d==123\n",j);
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
90
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
91 j = 552;
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
92 bbb = main3(bbb);
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
93 printf("#0092:main3 bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]);
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
94 j = main3(bbb).a[55];
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
95 printf("#0094:main3 bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]);
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
96 j = main3(bbb).a[53];
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
97 printf("#0096:main3 bbb.a[55] in temporal copy %d==53 %d\n",j,bbb.a[53]);
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
98
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
99 printf("#0098:%d==3\n",q.b);
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
100 /* 3==3 */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
101 r = q;
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
102 printf("#0101:%d==3\n",r.b);
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
103 /* 3==3 */
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
104 (*r.c)(aaa);
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
105 printf("#0104:main aaa.a[55] %d\n",aaa.a[55]);
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
106 /* main aaa.a[55] 123 */
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
107 bbb.a[0]=44;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
108 aaa = bbb;
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
109 aaa.a[99]=55; /* core dump? */
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
110 (*r.c)(aaa);
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
111 /* main aaa.a[55] 0 */
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
112 printf("#0111:main aaa.a[55] %d\n",aaa.a[55]);
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
113 p = av[0];
487
b4d9809d6ee2 type attribute (half done)
kono
parents: 467
diff changeset
114 if (!p) return 55;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
115 i = p[1];
d35df41eac69 Initial revision
kono
parents:
diff changeset
116 p = p+i;
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
117 /* 47 ./a.out */
491
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
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
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
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
a379da780856 cond signed/unsigned
kono
parents: 487
diff changeset
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
096559f07a70 some check
kono
parents: 46
diff changeset
126 return 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
127 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
128
13
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
129 void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
130 tmp()
d35df41eac69 Initial revision
kono
parents:
diff changeset
131 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
132 }
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
133
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
134