annotate test/tmp7.c @ 417:98888da30b35

code jump fixes (not finished)
author kono
date Mon, 25 Oct 2004 01:16:28 +0900
parents 22949117768f
children 0c256ea2a97e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1
d35df41eac69 Initial revision
kono
parents:
diff changeset
2
13
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
3 int k=3;
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
4
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
5 struct aa { int a[100]; } aaa,bbb;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
6 struct bb { int b[2]; } aaa1,bbb1;
13
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
7
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
8 void tmp(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
9
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
10 struct aa
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
11 main0(int);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
12
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
13 struct aa
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
14 main0(int k)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
15 {
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
16 int i;
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
17 struct aa ccc;
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
18
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
19 for(i=0;i<100;i++) ccc.a[i]=i;
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
20 ccc.a[55]=k;
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
21 return ccc;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
22 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
23
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
24 struct aa
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
25 main3(struct aa arg)
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
26 {
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
27 int j=++arg.a[55];
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
28 return main0(j);
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
29 }
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
30
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
31 void
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
32 main2(struct aa a1)
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
33 {
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
34 /* main2 a1.a[99] 0 */
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
35 /* main2 a1.a[55] 0 */
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
36 /* main2 a1.a[99] 55 */
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
37 /* main2 a1.a[55] 44 */
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
38 printf("main2 a1.a[99] %d\n",a1.a[99]);
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
39 printf("main2 a1.a[55] %d\n",a1.a[55]);
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
40 }
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
41
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
42 struct bb
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
43 main5(struct aa a1,struct bb a2)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
44 {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
45 printf("main5 a1.a[99] %d\n",a1.a[99]);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
46 printf("main5 a1.a[55] %d\n",a1.a[55]);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
47 printf("main5 a2.b[0] %d\n",a2.b[0]);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
48 printf("main5 a2.b[1] %d\n",a2.b[1]);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
49 a2.b[0]=333;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
50 a2.b[1]=555;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
51 return a2;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
52 }
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
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
55 void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
56 main1(struct aa a1)
d35df41eac69 Initial revision
kono
parents:
diff changeset
57 {
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
58 /* main1 a1.a[0] 0 */
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
59 /* main1 a1.a[0] 44 */
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
60 printf("main1 a1.a[0] %d\n",a1.a[0]);
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
61 a1.a[55]=44;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
62 if (a1.a[0])
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
63 main2(a1);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
64 else
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
65 main2(aaa);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
66 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
67
13
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
68
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
69 main(ac,av)
d35df41eac69 Initial revision
kono
parents:
diff changeset
70 int ac;
d35df41eac69 Initial revision
kono
parents:
diff changeset
71 char *av[];
d35df41eac69 Initial revision
kono
parents:
diff changeset
72 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
73 register int i;
d35df41eac69 Initial revision
kono
parents:
diff changeset
74 register char *p;
d35df41eac69 Initial revision
kono
parents:
diff changeset
75 int j = 3;
16
ca0bce3b4810 struct copy
kono
parents: 15
diff changeset
76 struct { int b; void (*c)(struct aa); } q = {3,main1},r;
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
77 struct aa *aap[3];
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
78
d35df41eac69 Initial revision
kono
parents:
diff changeset
79 j = 3;
d35df41eac69 Initial revision
kono
parents:
diff changeset
80
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
81 bbb = main0(123);
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
82 printf("copied main0 ccc.a[55] %d==123\n",bbb.a[55]);
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
83 aap[2] = &bbb;
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
84 *aap[2] = main0(123);
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
85 printf("complex copied main0 ccc.a[55] %d==123\n",bbb.a[55]);
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
86 bbb.a[55]=0;
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
87 j = main0(123).a[55];
39
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
88 printf("new main0 ccc.a[55] in temporal copy %d==123\n",j);
c63c4fdeb9a7 struct done.
kono
parents: 37
diff changeset
89
45
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
90 j = 552;
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
91 bbb = main3(bbb);
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
92 printf("main3 bbb.a[55] in temporal copy %d==552 %d==1\n",j,bbb.a[55]);
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
93 j = main3(bbb).a[55];
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
94 printf("main3 bbb.a[55] in temporal copy %d==2 %d\n",j,bbb.a[53]);
b9266c88495c *** empty log message ***
kono
parents: 39
diff changeset
95 j = main3(bbb).a[53];
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
96 printf("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
97
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
98 printf("%d==3\n",q.b);
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
99 /* 3==3 */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
100 r = q;
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
101 printf("%d==3\n",r.b);
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
102 /* 3==3 */
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
103 (*r.c)(aaa);
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
104 printf("main aaa.a[55] %d\n",aaa.a[55]);
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
105 /* main aaa.a[55] 123 */
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
106 bbb.a[0]=44;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
107 aaa = bbb;
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
108 aaa.a[99]=55; /* core dump? */
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
109 (*r.c)(aaa);
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
110 /* main aaa.a[55] 0 */
15
6667dbd4f718 eax before function call
kono
parents: 13
diff changeset
111 printf("main aaa.a[55] %d\n",aaa.a[55]);
8
e714bcee688b *** empty log message ***
kono
parents: 0
diff changeset
112 p = av[0];
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
113 if (!p) return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
114 i = p[1];
d35df41eac69 Initial revision
kono
parents:
diff changeset
115 p = p+i;
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
116 /* 47 ./a.out */
172
096559f07a70 some check
kono
parents: 46
diff changeset
117 printf("%d %s\n",i,p-i+3);
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
118 aaa1.b[0]=33;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
119 aaa1.b[1]=55;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
120 bbb1 = main5(aaa,aaa1);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
121 printf("main5-2 %d\n",
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
122 main5(bbb,bbb1).b[0]);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
123 printf("main5-1 %d\n",
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 172
diff changeset
124 main5(bbb,main5(aaa,aaa1)).b[0]);
172
096559f07a70 some check
kono
parents: 46
diff changeset
125 return 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
126 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
127
13
a8a812dace23 struct local initialization
kono
parents: 8
diff changeset
128 void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
129 tmp()
d35df41eac69 Initial revision
kono
parents:
diff changeset
130 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
131 }
37
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
132
412ad2e6c2a2 struct copy
kono
parents: 16
diff changeset
133