1 /* This test program is part of GDB, the GNU debugger.
3 Copyright 1992-2022 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 * Test file with lots of different types, for testing the
24 * First the basic C types.
28 signed char v_signed_char
;
29 unsigned char v_unsigned_char
;
32 signed short v_signed_short
;
33 unsigned short v_unsigned_short
;
36 signed int v_signed_int
;
37 unsigned int v_unsigned_int
;
40 signed long v_signed_long
;
41 unsigned long v_unsigned_long
;
44 long long v_long_long
;
45 signed long long v_signed_long_long
;
46 unsigned long long v_unsigned_long_long
;
53 * Now some derived types, which are arrays, functions-returning,
54 * pointers, structures, unions, and enumerations.
60 signed char v_signed_char_array
[2];
61 unsigned char v_unsigned_char_array
[2];
63 short v_short_array
[2];
64 signed short v_signed_short_array
[2];
65 unsigned short v_unsigned_short_array
[2];
68 signed int v_signed_int_array
[2];
69 unsigned int v_unsigned_int_array
[2];
72 signed long v_signed_long_array
[2];
73 unsigned long v_unsigned_long_array
[2];
76 long long v_long_long_array
[2];
77 signed long long v_signed_long_long_array
[2];
78 unsigned long long v_unsigned_long_long_array
[2];
81 float v_float_array
[2];
82 double v_double_array
[2];
84 /**** pointers *******/
86 /* Make sure they still print as pointer to foo even there is a typedef
87 for that type. Test this not just for char *, which might be
88 a special case kludge in GDB (Unix system include files like to define
89 caddr_t), but for a variety of types. */
90 typedef char *char_addr
;
91 char_addr a_char_addr
;
92 typedef unsigned short *ushort_addr
;
93 ushort_addr a_ushort_addr
;
94 typedef signed long *slong_addr
;
95 slong_addr a_slong_addr
;
97 typedef signed long long *slong_long_addr
;
98 slong_long_addr a_slong_long_addr
;
101 char *v_char_pointer
;
102 signed char *v_signed_char_pointer
;
103 unsigned char *v_unsigned_char_pointer
;
105 short *v_short_pointer
;
106 signed short *v_signed_short_pointer
;
107 unsigned short *v_unsigned_short_pointer
;
110 signed int *v_signed_int_pointer
;
111 unsigned int *v_unsigned_int_pointer
;
113 long *v_long_pointer
;
114 signed long *v_signed_long_pointer
;
115 unsigned long *v_unsigned_long_pointer
;
118 long long *v_long_long_pointer
;
119 signed long long *v_signed_long_long_pointer
;
120 unsigned long long *v_unsigned_long_long_pointer
;
123 float *v_float_pointer
;
124 double *v_double_pointer
;
126 /**** structs *******/
130 short v_short_member
;
134 long long v_long_long_member
;
136 float v_float_member
;
137 double v_double_member
;
138 } v_struct1
, *v_struct_ptr1
;
142 short v_short_member
;
146 long long v_long_long_member
;
148 float v_float_member
;
149 double v_double_member
;
150 } v_struct2
, *v_struct_ptr2
;
152 /**** unions *******/
156 short v_short_member
;
160 long long v_long_long_member
;
162 float v_float_member
;
163 double v_double_member
;
164 } v_union
, *v_union_ptr
;
168 short v_short_member
;
172 long long v_long_long_member
;
174 float v_float_member
;
175 double v_double_member
;
176 } v_union2
, *v_union_ptr2
;
178 /*** Functions returning type ********/
180 char v_char_func () { return(0); }
181 signed char v_signed_char_func () { return (0); }
182 unsigned char v_unsigned_char_func () { return (0); }
184 short v_short_func () { return (0); }
185 signed short v_signed_short_func () { return (0); }
186 unsigned short v_unsigned_short_func () { return (0); }
188 int v_int_func () { return (0); }
189 signed int v_signed_int_func () { return (0); }
190 unsigned int v_unsigned_int_func () { return (0); }
192 long v_long_func () { return (0); }
193 signed long v_signed_long_func () { return (0); }
194 unsigned long v_unsigned_long_func () { return (0); }
197 long long v_long_long_func () { return (0); }
198 signed long long v_signed_long_long_func () { return (0); }
199 unsigned long long v_unsigned_long_long_func () { return (0); }
202 float v_float_func () { return (0.0); }
203 double v_double_func () { return (0.0); }
205 /**** Some misc more complicated things *******/
210 struct link
*(*linkfunc
) (struct link
*self
, int flags
);
212 struct link
*(*linkfunc
) ();
214 struct t_struct stuff
[1][2][3];
220 struct link
*(*linkfunc
) (struct link
*self
, int flags
);
222 struct link
*(*linkfunc
) ();
224 struct t_struct stuff
[1][2][3];
227 struct outer_struct
{
229 struct inner_struct
{
232 }inner_struct_instance
;
235 long inner_union_long
;
236 }inner_union_instance
;
240 /**** Enumerations *******/
242 enum colors
{red
, green
, blue
} color
;
243 enum cars
{chevy
, ford
, porsche
} clunker
;
249 /* Some linkers (e.g. on AIX) remove unreferenced variables,
250 so make sure to reference them. */
257 v_unsigned_short
= 5;
265 v_unsigned_long
= 11;
269 v_signed_long_long
= 13;
270 v_unsigned_long_long
= 14;
277 v_char_array
[0] = v_char
;
278 v_signed_char_array
[0] = v_signed_char
;
279 v_unsigned_char_array
[0] = v_unsigned_char
;
281 v_short_array
[0] = v_short
;
282 v_signed_short_array
[0] = v_signed_short
;
283 v_unsigned_short_array
[0] = v_unsigned_short
;
285 v_int_array
[0] = v_int
;
286 v_signed_int_array
[0] = v_signed_int
;
287 v_unsigned_int_array
[0] = v_unsigned_int
;
289 v_long_array
[0] = v_long
;
290 v_signed_long_array
[0] = v_signed_long
;
291 v_unsigned_long_array
[0] = v_unsigned_long
;
294 v_long_long_array
[0] = v_long_long
;
295 v_signed_long_long_array
[0] = v_signed_long_long
;
296 v_unsigned_long_long_array
[0] = v_unsigned_long_long
;
299 v_float_array
[0] = v_float
;
300 v_double_array
[0] = v_double
;
302 v_char_pointer
= &v_char
;
303 v_signed_char_pointer
= &v_signed_char
;
304 v_unsigned_char_pointer
= &v_unsigned_char
;
306 v_short_pointer
= &v_short
;
307 v_signed_short_pointer
= &v_signed_short
;
308 v_unsigned_short_pointer
= &v_unsigned_short
;
310 v_int_pointer
= &v_int
;
311 v_signed_int_pointer
= &v_signed_int
;
312 v_unsigned_int_pointer
= &v_unsigned_int
;
314 v_long_pointer
= &v_long
;
315 v_signed_long_pointer
= &v_signed_long
;
316 v_unsigned_long_pointer
= &v_unsigned_long
;
319 v_long_long_pointer
= &v_long_long
;
320 v_signed_long_long_pointer
= &v_signed_long_long
;
321 v_unsigned_long_long_pointer
= &v_unsigned_long_long
;
324 v_float_pointer
= &v_float
;
325 v_double_pointer
= &v_double
;
330 u_link
.next
= s_link
;
332 v_union2
.v_short_member
= v_union
.v_short_member
;
334 v_struct1
.v_char_member
= 0;
335 v_struct2
.v_char_member
= 0;
337 nested_su
.outer_int
= 0;