Commit | Line | Data |
---|---|---|
ef44eed1 SS |
1 | /* |
2 | * Test file with lots of different types, for testing the | |
3 | * "whatis" command. | |
4 | */ | |
5 | ||
6 | /* | |
7 | * First the basic C types. | |
8 | */ | |
9 | ||
10 | #if !(defined (__STDC__) || defined (_AIX)) | |
11 | #define signed /**/ | |
12 | #endif | |
13 | ||
14 | char v_char; | |
15 | signed char v_signed_char; | |
16 | unsigned char v_unsigned_char; | |
17 | ||
18 | short v_short; | |
19 | signed short v_signed_short; | |
20 | unsigned short v_unsigned_short; | |
21 | ||
22 | int v_int; | |
23 | signed int v_signed_int; | |
24 | unsigned int v_unsigned_int; | |
25 | ||
26 | long v_long; | |
27 | signed long v_signed_long; | |
28 | unsigned long v_unsigned_long; | |
29 | ||
30 | float v_float; | |
31 | double v_double; | |
32 | ||
33 | /* | |
34 | * Now some derived types, which are arrays, functions-returning, | |
35 | * pointers, structures, unions, and enumerations. | |
36 | */ | |
37 | ||
38 | /**** arrays *******/ | |
39 | ||
40 | char v_char_array[2]; | |
41 | signed char v_signed_char_array[2]; | |
42 | unsigned char v_unsigned_char_array[2]; | |
43 | ||
44 | short v_short_array[2]; | |
45 | signed short v_signed_short_array[2]; | |
46 | unsigned short v_unsigned_short_array[2]; | |
47 | ||
48 | int v_int_array[2]; | |
49 | signed int v_signed_int_array[2]; | |
50 | unsigned int v_unsigned_int_array[2]; | |
51 | ||
52 | long v_long_array[2]; | |
53 | signed long v_signed_long_array[2]; | |
54 | unsigned long v_unsigned_long_array[2]; | |
55 | ||
56 | float v_float_array[2]; | |
57 | double v_double_array[2]; | |
58 | ||
59 | /**** pointers *******/ | |
60 | ||
61 | /* Make sure they still print as pointer to foo even there is a typedef | |
62 | for that type. Test this not just for char *, which might be | |
63 | a special case kludge in GDB (Unix system include files like to define | |
64 | caddr_t), but for a variety of types. */ | |
65 | typedef char *char_addr; | |
66 | typedef unsigned short *ushort_addr; | |
67 | typedef signed long *slong_addr; | |
68 | ||
69 | char *v_char_pointer; | |
70 | signed char *v_signed_char_pointer; | |
71 | unsigned char *v_unsigned_char_pointer; | |
72 | ||
73 | short *v_short_pointer; | |
74 | signed short *v_signed_short_pointer; | |
75 | unsigned short *v_unsigned_short_pointer; | |
76 | ||
77 | int *v_int_pointer; | |
78 | signed int *v_signed_int_pointer; | |
79 | unsigned int *v_unsigned_int_pointer; | |
80 | ||
81 | long *v_long_pointer; | |
82 | signed long *v_signed_long_pointer; | |
83 | unsigned long *v_unsigned_long_pointer; | |
84 | ||
85 | float *v_float_pointer; | |
86 | double *v_double_pointer; | |
87 | ||
88 | /**** structs *******/ | |
89 | ||
90 | struct t_struct { | |
91 | char v_char_member; | |
92 | short v_short_member; | |
93 | int v_int_member; | |
94 | long v_long_member; | |
95 | float v_float_member; | |
96 | double v_double_member; | |
97 | } v_struct1; | |
98 | ||
99 | struct { | |
100 | char v_char_member; | |
101 | short v_short_member; | |
102 | int v_int_member; | |
103 | long v_long_member; | |
104 | float v_float_member; | |
105 | double v_double_member; | |
106 | } v_struct2; | |
107 | ||
108 | /**** unions *******/ | |
109 | ||
110 | union t_union { | |
111 | char v_char_member; | |
112 | short v_short_member; | |
113 | int v_int_member; | |
114 | long v_long_member; | |
115 | float v_float_member; | |
116 | double v_double_member; | |
117 | } v_union; | |
118 | ||
119 | union { | |
120 | char v_char_member; | |
121 | short v_short_member; | |
122 | int v_int_member; | |
123 | long v_long_member; | |
124 | float v_float_member; | |
125 | double v_double_member; | |
126 | } v_union2; | |
127 | ||
128 | /*** Functions returning type ********/ | |
129 | ||
130 | char v_char_func () { return(0); } | |
131 | signed char v_signed_char_func () { return (0); } | |
132 | unsigned char v_unsigned_char_func () { return (0); } | |
133 | ||
134 | short v_short_func () { return (0); } | |
135 | signed short v_signed_short_func () { return (0); } | |
136 | unsigned short v_unsigned_short_func () { return (0); } | |
137 | ||
138 | int v_int_func () { return (0); } | |
139 | signed int v_signed_int_func () { return (0); } | |
140 | unsigned int v_unsigned_int_func () { return (0); } | |
141 | ||
142 | long v_long_func () { return (0); } | |
143 | signed long v_signed_long_func () { return (0); } | |
144 | unsigned long v_unsigned_long_func () { return (0); } | |
145 | ||
146 | float v_float_func () { return (0.0); } | |
147 | double v_double_func () { return (0.0); } | |
148 | ||
149 | /**** Some misc more complicated things *******/ | |
150 | ||
151 | struct link { | |
152 | struct link *next; | |
153 | #ifdef __STDC__ | |
154 | struct link *(*linkfunc) (struct link *this, int flags); | |
155 | #else | |
156 | struct link *(*linkfunc) (); | |
157 | #endif | |
158 | struct t_struct stuff[1][2][3]; | |
159 | } *s_link; | |
160 | ||
161 | union tu_link { | |
162 | struct link *next; | |
163 | #ifdef __STDC__ | |
164 | struct link *(*linkfunc) (struct link *this, int flags); | |
165 | #else | |
166 | struct link *(*linkfunc) (); | |
167 | #endif | |
168 | struct t_struct stuff[1][2][3]; | |
169 | } u_link; | |
170 | ||
171 | struct outer_struct { | |
172 | int outer_int; | |
173 | struct inner_struct { | |
174 | int inner_int; | |
175 | long inner_long; | |
176 | }inner_struct_instance; | |
177 | union inner_union { | |
178 | int inner_union_int; | |
179 | long inner_union_long; | |
180 | }inner_union_instance; | |
181 | long outer_long; | |
182 | } nested_su; | |
183 | ||
184 | /**** Enumerations *******/ | |
185 | ||
186 | enum colors {red, green, blue} color; | |
187 | enum cars {chevy, ford, porsche} clunker; | |
188 | ||
189 | /***********/ | |
190 | ||
191 | main () | |
192 | { | |
193 | /* Some linkers (e.g. on AIX) remove unreferenced variables, | |
194 | so make sure to reference them. */ | |
195 | v_char = 0; | |
196 | v_signed_char = 1; | |
197 | v_unsigned_char = 2; | |
198 | ||
199 | v_short = 3; | |
200 | v_signed_short = 4; | |
201 | v_unsigned_short = 5; | |
202 | ||
203 | v_int = 6; | |
204 | v_signed_int = 7; | |
205 | v_unsigned_int = 8; | |
206 | ||
207 | v_long = 9; | |
208 | v_signed_long = 10; | |
209 | v_unsigned_long = 11; | |
210 | ||
211 | v_float = 100.0; | |
212 | v_double = 200.0; | |
213 | ||
214 | ||
215 | v_char_array[0] = v_char; | |
216 | v_signed_char_array[0] = v_signed_char; | |
217 | v_unsigned_char_array[0] = v_unsigned_char; | |
218 | ||
219 | v_short_array[0] = v_short; | |
220 | v_signed_short_array[0] = v_signed_short; | |
221 | v_unsigned_short_array[0] = v_unsigned_short; | |
222 | ||
223 | v_int_array[0] = v_int; | |
224 | v_signed_int_array[0] = v_signed_int; | |
225 | v_unsigned_int_array[0] = v_unsigned_int; | |
226 | ||
227 | v_long_array[0] = v_long; | |
228 | v_signed_long_array[0] = v_signed_long; | |
229 | v_unsigned_long_array[0] = v_unsigned_long; | |
230 | ||
231 | v_float_array[0] = v_float; | |
232 | v_double_array[0] = v_double; | |
233 | ||
234 | v_char_pointer = &v_char; | |
235 | v_signed_char_pointer = &v_signed_char; | |
236 | v_unsigned_char_pointer = &v_unsigned_char; | |
237 | ||
238 | v_short_pointer = &v_short; | |
239 | v_signed_short_pointer = &v_signed_short; | |
240 | v_unsigned_short_pointer = &v_unsigned_short; | |
241 | ||
242 | v_int_pointer = &v_int; | |
243 | v_signed_int_pointer = &v_signed_int; | |
244 | v_unsigned_int_pointer = &v_unsigned_int; | |
245 | ||
246 | v_long_pointer = &v_long; | |
247 | v_signed_long_pointer = &v_signed_long; | |
248 | v_unsigned_long_pointer = &v_unsigned_long; | |
249 | ||
250 | v_float_pointer = &v_float; | |
251 | v_double_pointer = &v_double; | |
252 | ||
253 | color = red; | |
254 | clunker = porsche; | |
255 | ||
256 | u_link.next = s_link; | |
257 | ||
258 | v_union2.v_short_member = v_union.v_short_member; | |
259 | ||
260 | v_struct1.v_char_member = 0; | |
261 | v_struct2.v_char_member = 0; | |
262 | ||
263 | nested_su.outer_int = 0; | |
264 | return 0; | |
265 | } |