* gdb.base/help.exp: Replace most of docstrings for "info signals"
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ptype.c
CommitLineData
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
14char v_char;
15signed char v_signed_char;
16unsigned char v_unsigned_char;
17
18short v_short;
19signed short v_signed_short;
20unsigned short v_unsigned_short;
21
22int v_int;
23signed int v_signed_int;
24unsigned int v_unsigned_int;
25
26long v_long;
27signed long v_signed_long;
28unsigned long v_unsigned_long;
29
30float v_float;
31double 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
40char v_char_array[2];
41signed char v_signed_char_array[2];
42unsigned char v_unsigned_char_array[2];
43
44short v_short_array[2];
45signed short v_signed_short_array[2];
46unsigned short v_unsigned_short_array[2];
47
48int v_int_array[2];
49signed int v_signed_int_array[2];
50unsigned int v_unsigned_int_array[2];
51
52long v_long_array[2];
53signed long v_signed_long_array[2];
54unsigned long v_unsigned_long_array[2];
55
56float v_float_array[2];
57double v_double_array[2];
58
59/**** pointers *******/
60
61char *v_char_pointer;
62signed char *v_signed_char_pointer;
63unsigned char *v_unsigned_char_pointer;
64
65short *v_short_pointer;
66signed short *v_signed_short_pointer;
67unsigned short *v_unsigned_short_pointer;
68
69int *v_int_pointer;
70signed int *v_signed_int_pointer;
71unsigned int *v_unsigned_int_pointer;
72
73long *v_long_pointer;
74signed long *v_signed_long_pointer;
75unsigned long *v_unsigned_long_pointer;
76
77float *v_float_pointer;
78double *v_double_pointer;
79
80/**** structs *******/
81
82struct 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
91struct t_struct *v_t_struct_p;
92
93struct {
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. */
103typedef 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. */
109t_struct3 v_struct3;
110
111/**** unions *******/
112
113union 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
122union {
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. */
132typedef 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. */
138t_union3 v_union3;
139
140/*** Functions returning type ********/
141
142char v_char_func () { return(0); }
143signed char v_signed_char_func () { return (0); }
144unsigned char v_unsigned_char_func () { return (0); }
145
146short v_short_func () { return (0); }
147signed short v_signed_short_func () { return (0); }
148unsigned short v_unsigned_short_func () { return (0); }
149
150int v_int_func () { return (0); }
151signed int v_signed_int_func () { return (0); }
152unsigned int v_unsigned_int_func () { return (0); }
153
154long v_long_func () { return (0); }
155signed long v_signed_long_func () { return (0); }
156unsigned long v_unsigned_long_func () { return (0); }
157
158float v_float_func () { return (0.0); }
159double v_double_func () { return (0.0); }
160
161/**** Some misc more complicated things *******/
162
163struct 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
173union 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
183struct 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
198enum
199/* Work around the bug for compilers which don't put out the right stabs. */
200#if __GNUC__ < 2 && !defined (_AIX)
201primary1_tag
202#endif
203{red1, green1, blue1} primary1;
204
205enum {red, green, blue} primary;
206enum colors {yellow, purple, pink} nonprimary;
207
208enum {chevy, ford} clunker;
209enum cars {bmw, porsche} sportscar;
210
211typedef enum {FALSE, TRUE} boolean;
212boolean v_boolean;
213typedef enum bvals {false, true} boolean2;
214
215enum misordered {two = 2, one = 1, zero = 0, three = 3};
216
217/***********/
218
219main ()
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}
This page took 0.057737 seconds and 4 git commands to generate.