This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ptype.c
CommitLineData
c906108c
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 */
085dd6e6 9#include <stdlib.h>
c906108c
SS
10
11#if !defined (__STDC__) && !defined (_AIX)
12#define signed /**/
13#endif
14
15char v_char;
16signed char v_signed_char;
17unsigned char v_unsigned_char;
18
19short v_short;
20signed short v_signed_short;
21unsigned short v_unsigned_short;
22
23int v_int;
24signed int v_signed_int;
25unsigned int v_unsigned_int;
26
27long v_long;
28signed long v_signed_long;
29unsigned long v_unsigned_long;
30
31float v_float;
32double v_double;
33
34/*
35 * Now some derived types, which are arrays, functions-returning,
36 * pointers, structures, unions, and enumerations.
37 */
38
39/**** arrays *******/
40
41char v_char_array[2];
42signed char v_signed_char_array[2];
43unsigned char v_unsigned_char_array[2];
44
45short v_short_array[2];
46signed short v_signed_short_array[2];
47unsigned short v_unsigned_short_array[2];
48
49int v_int_array[2];
50signed int v_signed_int_array[2];
51unsigned int v_unsigned_int_array[2];
52
53long v_long_array[2];
54signed long v_signed_long_array[2];
55unsigned long v_unsigned_long_array[2];
56
57float v_float_array[2];
58double v_double_array[2];
59
60/* PR 3742 */
61typedef char t_char_array[];
62
63/**** pointers *******/
64
65char *v_char_pointer;
66signed char *v_signed_char_pointer;
67unsigned char *v_unsigned_char_pointer;
68
69short *v_short_pointer;
70signed short *v_signed_short_pointer;
71unsigned short *v_unsigned_short_pointer;
72
73int *v_int_pointer;
74signed int *v_signed_int_pointer;
75unsigned int *v_unsigned_int_pointer;
76
77long *v_long_pointer;
78signed long *v_signed_long_pointer;
79unsigned long *v_unsigned_long_pointer;
80
81float *v_float_pointer;
82double *v_double_pointer;
83
84/**** structs *******/
85
86struct t_struct {
87 char v_char_member;
88 short v_short_member;
89 int v_int_member;
90 long v_long_member;
91 float v_float_member;
92 double v_double_member;
93} v_struct1;
94
95struct t_struct *v_t_struct_p;
96
97struct {
98 char v_char_member;
99 short v_short_member;
100 int v_int_member;
101 long v_long_member;
102 float v_float_member;
103 double v_double_member;
104} v_struct2;
105
106/* typedef'd struct without a tag. */
107typedef struct {
108 double v_double_member;
109 int v_int_member;
110} t_struct3;
111/* GCC seems to want a variable of this type, or else it won't put out
112 a symbol. */
113t_struct3 v_struct3;
114
115/**** unions *******/
116
117union t_union {
118 char v_char_member;
119 short v_short_member;
120 int v_int_member;
121 long v_long_member;
122 float v_float_member;
123 double v_double_member;
124} v_union;
125
126union {
127 char v_char_member;
128 short v_short_member;
129 int v_int_member;
130 long v_long_member;
131 float v_float_member;
132 double v_double_member;
133} v_union2;
134
135/* typedef'd union without a tag. */
136typedef union {
137 double v_double_member;
138 int v_int_member;
139} t_union3;
140/* GCC seems to want a variable of this type, or else it won't put out
141 a symbol. */
142t_union3 v_union3;
143
144/*** Functions returning type ********/
145
146char v_char_func () { return(0); }
147signed char v_signed_char_func () { return (0); }
148unsigned char v_unsigned_char_func () { return (0); }
149
150short v_short_func () { return (0); }
151signed short v_signed_short_func () { return (0); }
152unsigned short v_unsigned_short_func () { return (0); }
153
154int v_int_func () { return (0); }
155signed int v_signed_int_func () { return (0); }
156unsigned int v_unsigned_int_func () { return (0); }
157
158long v_long_func () { return (0); }
159signed long v_signed_long_func () { return (0); }
160unsigned long v_unsigned_long_func () { return (0); }
161
162float v_float_func () { return (0.0); }
163double v_double_func () { return (0.0); }
164
165/**** Some misc more complicated things *******/
166
167struct link {
168 struct link *next;
169#ifdef __STDC__
170 struct link *(*linkfunc) (struct link *this, int flags);
171#else
172 struct link *(*linkfunc) ();
173#endif
174 struct t_struct stuff[1][2][3];
175} *s_link;
176
177union tu_link {
178 struct link *next;
179#ifdef __STDC__
180 struct link *(*linkfunc) (struct link *this, int flags);
181#else
182 struct link *(*linkfunc) ();
183#endif
184 struct t_struct stuff[1][2][3];
185} u_link;
186
187struct outer_struct {
188 int outer_int;
189 struct inner_struct {
190 int inner_int;
191 long inner_long;
192 }inner_struct_instance;
193 union inner_union {
194 int inner_union_int;
195 long inner_union_long;
196 }inner_union_instance;
197 long outer_long;
198} nested_su;
199
200/**** Enumerations *******/
201
202enum
203/* Work around the bug for compilers which don't put out the right stabs. */
204#if __GNUC__ < 2 && !defined (_AIX)
205primary1_tag
206#endif
207{red1, green1, blue1} primary1;
208
209enum {red, green, blue} primary;
210enum colors {yellow, purple, pink} nonprimary;
211
212enum {chevy, ford} clunker;
213enum cars {bmw, porsche} sportscar;
214
215typedef enum {FALSE, TRUE} boolean;
216boolean v_boolean;
085dd6e6
JM
217/*note: aCC has bool type predefined with 'false' and 'true'*/
218typedef enum bvals {my_false, my_true} boolean2;
c906108c
SS
219boolean2 v_boolean2;
220
221enum misordered {two = 2, one = 1, zero = 0, three = 3};
222
085dd6e6
JM
223/* Seems like we need a variable of this type to get the type to be put
224 in the executable, at least for AIX xlc. */
225enum misordered v_misordered = three;
226
c906108c
SS
227/***********/
228
085dd6e6 229int main ()
c906108c
SS
230{
231 /* Ensure that malloc is a pointer type; avoid use of "void" and any include files. */
085dd6e6 232/* extern char *malloc();*/
c906108c
SS
233
234 /* Some of the tests in ptype.exp require invoking malloc, so make
235 sure it is linked in to this program. */
236 v_char_pointer = (char *) malloc (1);
237
238#ifdef usestubs
239 set_debug_traps();
240 breakpoint();
241#endif
242 /* Some linkers (e.g. on AIX) remove unreferenced variables,
243 so make sure to reference them. */
244 primary = blue;
245 primary1 = blue1;
246 nonprimary = pink;
247 sportscar = porsche;
248 clunker = ford;
249 v_struct1.v_int_member = 5;
250 v_struct2.v_int_member = 6;
251 v_struct3.v_int_member = 7;
252
253 v_char = 0;
254 v_signed_char = 0;
255 v_unsigned_char = 0;
256
257 v_short = 0;
258 v_signed_short = 0;
259 v_unsigned_short = 0;
260
261 v_int = 0;
262 v_signed_int = 0;
263 v_unsigned_int = 0;
264
265 v_long = 0;
266 v_signed_long = 0;
267 v_unsigned_long = 0;
268
269 v_float = 0;
270 v_double = 0;
271
272 v_char_array[0] = 0;
273 v_signed_char_array[0] = 0;
274 v_unsigned_char_array[0] = 0;
275
276 v_short_array[0] = 0;
277 v_signed_short_array[0] = 0;
278 v_unsigned_short_array[0] = 0;
279
280 v_int_array[0] = 0;
281 v_signed_int_array[0] = 0;
282 v_unsigned_int_array[0] = 0;
283
284 v_long_array[0] = 0;
285 v_signed_long_array[0] = 0;
286 v_unsigned_long_array[0] = 0;
287
288 v_float_array[0] = 0;
289 v_double_array[0] = 0;
290
291 v_char_pointer = 0;
292 v_signed_char_pointer = 0;
293 v_unsigned_char_pointer = 0;
294
295 v_short_pointer = 0;
296 v_signed_short_pointer = 0;
297 v_unsigned_short_pointer = 0;
298
299 v_int_pointer = 0;
300 v_signed_int_pointer = 0;
301 v_unsigned_int_pointer = 0;
302
303 v_long_pointer = 0;
304 v_signed_long_pointer = 0;
305 v_unsigned_long_pointer = 0;
306
307 v_float_pointer = 0;
308 v_double_pointer = 0;
309
310 nested_su.outer_int = 0;
311 v_t_struct_p = 0;
312
313 v_boolean = FALSE;
085dd6e6
JM
314 v_boolean2 = my_false;
315 return 0;
c906108c 316}
This page took 0.040272 seconds and 4 git commands to generate.