annotate test/tmp11.c @ 896:d712ee10feb7

local_nptr for locally defined struct
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 06 Apr 2014 19:20:58 +0900
parents bc919d849346
children
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, ...);
32737bad7489 fix list/tag interference
kono
parents: 427
diff changeset
2
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
3 typedef struct nametable {
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
4 char *nm;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
5 int sc,ty,dsp; } NMTBL;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
6 NMTBL *a;
832
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
7 NMTBL f;
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
8
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
9 NMTBL *
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
10 test2(char *n) {
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
11 printf("#0010:s %s\n",n);
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
12 return a;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
13 }
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
14
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
15 int
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
16 test0(int a,int b,int c) {
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
17 printf("#0016:a %d b %d c %d\n",a,b,c);
172
096559f07a70 some check
kono
parents: 46
diff changeset
18 return 0;
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
19 }
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
20
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
21 int
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
22 test1(a,b,c)
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
23 int a,b;int c;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
24 {
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
25 return test0(a,b,c);
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
26 }
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
27
832
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
28 int heap[10];
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
29
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
30 #define ncaddr(e) (*(NMTBL**)&heap[e+2])
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
31
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
32 int
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
33 main()
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
34 {
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
35 int d;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
36 NMTBL *b;
832
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
37 f.nm = "_name";
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
38 a = &f;
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
39 b = test2("test");
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
40 d = test1(1,2,3);
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
41 printf("#0040:return %d\n",d);
832
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
42
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
43 NMTBL **p = (NMTBL**)&heap[2];
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
44 *p = &f;
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
45 b = &f;
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
46 int e = 0;
896
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
47 printf("#0046:f.nm %s\n",f.nm);
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
48 printf("#0047:b->nm %s\n",b->nm);
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
49 printf("#0048:(*p)->nm %s\n",(*p)->nm);
d712ee10feb7 local_nptr for locally defined struct
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
50 printf("#0049:ncaddr(e)->nm %s\n",ncaddr(e)->nm);
832
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
51
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
52 return d;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents:
diff changeset
53 }
832
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
54
bc919d849346 arrow in parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 491
diff changeset
55 /* end */