]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/ptype.c
2 * Test file with lots of different types, for testing the
7 * First the basic C types.
10 #if !defined (__STDC__) && !defined (_AIX)
15 signed char v_signed_char
;
16 unsigned char v_unsigned_char
;
19 signed short v_signed_short
;
20 unsigned short v_unsigned_short
;
23 signed int v_signed_int
;
24 unsigned int v_unsigned_int
;
27 signed long v_signed_long
;
28 unsigned long v_unsigned_long
;
34 * Now some derived types, which are arrays, functions-returning,
35 * pointers, structures, unions, and enumerations.
41 signed char v_signed_char_array
[2];
42 unsigned char v_unsigned_char_array
[2];
44 short v_short_array
[2];
45 signed short v_signed_short_array
[2];
46 unsigned short v_unsigned_short_array
[2];
49 signed int v_signed_int_array
[2];
50 unsigned int v_unsigned_int_array
[2];
53 signed long v_signed_long_array
[2];
54 unsigned long v_unsigned_long_array
[2];
56 float v_float_array
[2];
57 double v_double_array
[2];
59 /**** pointers *******/
62 signed char *v_signed_char_pointer
;
63 unsigned char *v_unsigned_char_pointer
;
65 short *v_short_pointer
;
66 signed short *v_signed_short_pointer
;
67 unsigned short *v_unsigned_short_pointer
;
70 signed int *v_signed_int_pointer
;
71 unsigned int *v_unsigned_int_pointer
;
74 signed long *v_signed_long_pointer
;
75 unsigned long *v_unsigned_long_pointer
;
77 float *v_float_pointer
;
78 double *v_double_pointer
;
80 /**** structs *******/
88 double v_double_member
;
91 struct t_struct
*v_t_struct_p
;
99 double v_double_member
;
102 /* typedef'd struct without a tag. */
104 double v_double_member
;
107 /* GCC seems to want a variable of this type, or else it won't put out
111 /**** unions *******/
115 short v_short_member
;
118 float v_float_member
;
119 double v_double_member
;
124 short v_short_member
;
127 float v_float_member
;
128 double v_double_member
;
131 /* typedef'd union without a tag. */
133 double v_double_member
;
136 /* GCC seems to want a variable of this type, or else it won't put out
140 /*** Functions returning type ********/
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); }
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); }
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); }
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); }
158 float v_float_func () { return (0.0); }
159 double v_double_func () { return (0.0); }
161 /**** Some misc more complicated things *******/
166 struct link
*(*linkfunc
) (struct link
*this, int flags
);
168 struct link
*(*linkfunc
) ();
170 struct t_struct stuff
[1][2][3];
176 struct link
*(*linkfunc
) (struct link
*this, int flags
);
178 struct link
*(*linkfunc
) ();
180 struct t_struct stuff
[1][2][3];
183 struct outer_struct
{
185 struct inner_struct
{
188 }inner_struct_instance
;
191 long inner_union_long
;
192 }inner_union_instance
;
196 /**** Enumerations *******/
199 /* Work around the bug for compilers which don't put out the right stabs. */
200 #if __GNUC__ < 2 && !defined (_AIX)
203 {red1
, green1
, blue1
} primary1
;
205 enum {red
, green
, blue
} primary
;
206 enum colors
{yellow
, purple
, pink
} nonprimary
;
208 enum {chevy
, ford
} clunker
;
209 enum cars
{bmw
, porsche
} sportscar
;
211 typedef enum {FALSE
, TRUE
} boolean
;
213 typedef enum bvals
{false, true} boolean2
;
215 enum misordered
{two
= 2, one
= 1, zero
= 0, three
= 3};
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
;
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);
229 /* Some linkers (e.g. on AIX) remove unreferenced variables,
230 so make sure to reference them. */
236 v_struct1
.v_int_member
= 5;
237 v_struct2
.v_int_member
= 6;
238 v_struct3
.v_int_member
= 7;
246 v_unsigned_short
= 0;
260 v_signed_char_array
[0] = 0;
261 v_unsigned_char_array
[0] = 0;
263 v_short_array
[0] = 0;
264 v_signed_short_array
[0] = 0;
265 v_unsigned_short_array
[0] = 0;
268 v_signed_int_array
[0] = 0;
269 v_unsigned_int_array
[0] = 0;
272 v_signed_long_array
[0] = 0;
273 v_unsigned_long_array
[0] = 0;
275 v_float_array
[0] = 0;
276 v_double_array
[0] = 0;
279 v_signed_char_pointer
= 0;
280 v_unsigned_char_pointer
= 0;
283 v_signed_short_pointer
= 0;
284 v_unsigned_short_pointer
= 0;
287 v_signed_int_pointer
= 0;
288 v_unsigned_int_pointer
= 0;
291 v_signed_long_pointer
= 0;
292 v_unsigned_long_pointer
= 0;
295 v_double_pointer
= 0;
297 nested_su
.outer_int
= 0;