Commit | Line | Data |
---|---|---|
ef44eed1 SS |
1 | /* |
2 | * Test file with lots of different types, for testing the | |
3 | * "ptype" 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 | char *v_char_pointer; | |
62 | signed char *v_signed_char_pointer; | |
63 | unsigned char *v_unsigned_char_pointer; | |
64 | ||
65 | short *v_short_pointer; | |
66 | signed short *v_signed_short_pointer; | |
67 | unsigned short *v_unsigned_short_pointer; | |
68 | ||
69 | int *v_int_pointer; | |
70 | signed int *v_signed_int_pointer; | |
71 | unsigned int *v_unsigned_int_pointer; | |
72 | ||
73 | long *v_long_pointer; | |
74 | signed long *v_signed_long_pointer; | |
75 | unsigned long *v_unsigned_long_pointer; | |
76 | ||
77 | float *v_float_pointer; | |
78 | double *v_double_pointer; | |
79 | ||
80 | /**** structs *******/ | |
81 | ||
82 | struct t_struct { | |
83 | char v_char_member; | |
84 | short v_short_member; | |
85 | int v_int_member; | |
86 | long v_long_member; | |
87 | float v_float_member; | |
88 | double v_double_member; | |
89 | } v_struct1; | |
90 | ||
91 | struct t_struct *v_t_struct_p; | |
92 | ||
93 | struct { | |
94 | char v_char_member; | |
95 | short v_short_member; | |
96 | int v_int_member; | |
97 | long v_long_member; | |
98 | float v_float_member; | |
99 | double v_double_member; | |
100 | } v_struct2; | |
101 | ||
102 | /* typedef'd struct without a tag. */ | |
103 | typedef struct { | |
104 | double v_double_member; | |
105 | int v_int_member; | |
106 | } t_struct3; | |
107 | /* GCC seems to want a variable of this type, or else it won't put out | |
108 | a symbol. */ | |
109 | t_struct3 v_struct3; | |
110 | ||
111 | /**** unions *******/ | |
112 | ||
113 | union t_union { | |
114 | char v_char_member; | |
115 | short v_short_member; | |
116 | int v_int_member; | |
117 | long v_long_member; | |
118 | float v_float_member; | |
119 | double v_double_member; | |
120 | } v_union; | |
121 | ||
122 | union { | |
123 | char v_char_member; | |
124 | short v_short_member; | |
125 | int v_int_member; | |
126 | long v_long_member; | |
127 | float v_float_member; | |
128 | double v_double_member; | |
129 | } v_union2; | |
130 | ||
131 | /* typedef'd union without a tag. */ | |
132 | typedef union { | |
133 | double v_double_member; | |
134 | int v_int_member; | |
135 | } t_union3; | |
136 | /* GCC seems to want a variable of this type, or else it won't put out | |
137 | a symbol. */ | |
138 | t_union3 v_union3; | |
139 | ||
140 | /*** Functions returning type ********/ | |
141 | ||
142 | char v_char_func () { return(0); } | |
143 | signed char v_signed_char_func () { return (0); } | |
144 | unsigned char v_unsigned_char_func () { return (0); } | |
145 | ||
146 | short v_short_func () { return (0); } | |
147 | signed short v_signed_short_func () { return (0); } | |
148 | unsigned short v_unsigned_short_func () { return (0); } | |
149 | ||
150 | int v_int_func () { return (0); } | |
151 | signed int v_signed_int_func () { return (0); } | |
152 | unsigned int v_unsigned_int_func () { return (0); } | |
153 | ||
154 | long v_long_func () { return (0); } | |
155 | signed long v_signed_long_func () { return (0); } | |
156 | unsigned long v_unsigned_long_func () { return (0); } | |
157 | ||
158 | float v_float_func () { return (0.0); } | |
159 | double v_double_func () { return (0.0); } | |
160 | ||
161 | /**** Some misc more complicated things *******/ | |
162 | ||
163 | struct link { | |
164 | struct link *next; | |
165 | #ifdef __STDC__ | |
166 | struct link *(*linkfunc) (struct link *this, int flags); | |
167 | #else | |
168 | struct link *(*linkfunc) (); | |
169 | #endif | |
170 | struct t_struct stuff[1][2][3]; | |
171 | } *s_link; | |
172 | ||
173 | union tu_link { | |
174 | struct link *next; | |
175 | #ifdef __STDC__ | |
176 | struct link *(*linkfunc) (struct link *this, int flags); | |
177 | #else | |
178 | struct link *(*linkfunc) (); | |
179 | #endif | |
180 | struct t_struct stuff[1][2][3]; | |
181 | } u_link; | |
182 | ||
183 | struct outer_struct { | |
184 | int outer_int; | |
185 | struct inner_struct { | |
186 | int inner_int; | |
187 | long inner_long; | |
188 | }inner_struct_instance; | |
189 | union inner_union { | |
190 | int inner_union_int; | |
191 | long inner_union_long; | |
192 | }inner_union_instance; | |
193 | long outer_long; | |
194 | } nested_su; | |
195 | ||
196 | /**** Enumerations *******/ | |
197 | ||
198 | enum | |
199 | /* Work around the bug for compilers which don't put out the right stabs. */ | |
200 | #if __GNUC__ < 2 && !defined (_AIX) | |
201 | primary1_tag | |
202 | #endif | |
203 | {red1, green1, blue1} primary1; | |
204 | ||
205 | enum {red, green, blue} primary; | |
206 | enum colors {yellow, purple, pink} nonprimary; | |
207 | ||
208 | enum {chevy, ford} clunker; | |
209 | enum cars {bmw, porsche} sportscar; | |
210 | ||
211 | typedef enum {FALSE, TRUE} boolean; | |
212 | boolean v_boolean; | |
213 | typedef enum bvals {false, true} boolean2; | |
214 | ||
215 | enum misordered {two = 2, one = 1, zero = 0, three = 3}; | |
216 | ||
217 | /***********/ | |
218 | ||
219 | main () | |
220 | { | |
221 | /* Seems like we need a variable of this type to get the type to be put | |
222 | in the executable, at least for AIX xlc. */ | |
223 | enum misordered v_misordered = three; | |
224 | ||
225 | /* Some of the tests in ptype.exp require invoking malloc, so make | |
226 | sure it is linked in to this program. */ | |
227 | v_char_pointer = (char *) malloc (1); | |
228 | ||
229 | /* Some linkers (e.g. on AIX) remove unreferenced variables, | |
230 | so make sure to reference them. */ | |
231 | primary = blue; | |
232 | primary1 = blue1; | |
233 | nonprimary = pink; | |
234 | sportscar = porsche; | |
235 | clunker = ford; | |
236 | v_struct1.v_int_member = 5; | |
237 | v_struct2.v_int_member = 6; | |
238 | v_struct3.v_int_member = 7; | |
239 | ||
240 | v_char = 0; | |
241 | v_signed_char = 0; | |
242 | v_unsigned_char = 0; | |
243 | ||
244 | v_short = 0; | |
245 | v_signed_short = 0; | |
246 | v_unsigned_short = 0; | |
247 | ||
248 | v_int = 0; | |
249 | v_signed_int = 0; | |
250 | v_unsigned_int = 0; | |
251 | ||
252 | v_long = 0; | |
253 | v_signed_long = 0; | |
254 | v_unsigned_long = 0; | |
255 | ||
256 | v_float = 0; | |
257 | v_double = 0; | |
258 | ||
259 | v_char_array[0] = 0; | |
260 | v_signed_char_array[0] = 0; | |
261 | v_unsigned_char_array[0] = 0; | |
262 | ||
263 | v_short_array[0] = 0; | |
264 | v_signed_short_array[0] = 0; | |
265 | v_unsigned_short_array[0] = 0; | |
266 | ||
267 | v_int_array[0] = 0; | |
268 | v_signed_int_array[0] = 0; | |
269 | v_unsigned_int_array[0] = 0; | |
270 | ||
271 | v_long_array[0] = 0; | |
272 | v_signed_long_array[0] = 0; | |
273 | v_unsigned_long_array[0] = 0; | |
274 | ||
275 | v_float_array[0] = 0; | |
276 | v_double_array[0] = 0; | |
277 | ||
278 | v_char_pointer = 0; | |
279 | v_signed_char_pointer = 0; | |
280 | v_unsigned_char_pointer = 0; | |
281 | ||
282 | v_short_pointer = 0; | |
283 | v_signed_short_pointer = 0; | |
284 | v_unsigned_short_pointer = 0; | |
285 | ||
286 | v_int_pointer = 0; | |
287 | v_signed_int_pointer = 0; | |
288 | v_unsigned_int_pointer = 0; | |
289 | ||
290 | v_long_pointer = 0; | |
291 | v_signed_long_pointer = 0; | |
292 | v_unsigned_long_pointer = 0; | |
293 | ||
294 | v_float_pointer = 0; | |
295 | v_double_pointer = 0; | |
296 | ||
297 | nested_su.outer_int = 0; | |
298 | v_t_struct_p = 0; | |
299 | ||
300 | v_boolean = FALSE; | |
301 | } |