1 /* This test program is part of GDB, the GNU debugger.
3 Copyright 1992, 1993, 1994, 1997, 1999, 2004, 2007, 2008, 2009
4 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * Test file with lots of different types, for testing the
26 * First the basic C types.
30 signed char v_signed_char
;
31 unsigned char v_unsigned_char
;
34 signed short v_signed_short
;
35 unsigned short v_unsigned_short
;
38 signed int v_signed_int
;
39 unsigned int v_unsigned_int
;
42 signed long v_signed_long
;
43 unsigned long v_unsigned_long
;
46 long long v_long_long
;
47 signed long long v_signed_long_long
;
48 unsigned long long v_unsigned_long_long
;
55 * Now some derived types, which are arrays, functions-returning,
56 * pointers, structures, unions, and enumerations.
62 signed char v_signed_char_array
[2];
63 unsigned char v_unsigned_char_array
[2];
65 short v_short_array
[2];
66 signed short v_signed_short_array
[2];
67 unsigned short v_unsigned_short_array
[2];
70 signed int v_signed_int_array
[2];
71 unsigned int v_unsigned_int_array
[2];
74 signed long v_signed_long_array
[2];
75 unsigned long v_unsigned_long_array
[2];
78 long long v_long_long_array
[2];
79 signed long long v_signed_long_long_array
[2];
80 unsigned long long v_unsigned_long_long_array
[2];
83 float v_float_array
[2];
84 double v_double_array
[2];
86 /**** pointers *******/
88 /* Make sure they still print as pointer to foo even there is a typedef
89 for that type. Test this not just for char *, which might be
90 a special case kludge in GDB (Unix system include files like to define
91 caddr_t), but for a variety of types. */
92 typedef char *char_addr
;
93 static char_addr a_char_addr
;
94 typedef unsigned short *ushort_addr
;
95 static ushort_addr a_ushort_addr
;
96 typedef signed long *slong_addr
;
97 static slong_addr a_slong_addr
;
99 typedef signed long long *slong_long_addr
;
100 static slong_long_addr a_slong_long_addr
;
103 char *v_char_pointer
;
104 signed char *v_signed_char_pointer
;
105 unsigned char *v_unsigned_char_pointer
;
107 short *v_short_pointer
;
108 signed short *v_signed_short_pointer
;
109 unsigned short *v_unsigned_short_pointer
;
112 signed int *v_signed_int_pointer
;
113 unsigned int *v_unsigned_int_pointer
;
115 long *v_long_pointer
;
116 signed long *v_signed_long_pointer
;
117 unsigned long *v_unsigned_long_pointer
;
120 long long *v_long_long_pointer
;
121 signed long long *v_signed_long_long_pointer
;
122 unsigned long long *v_unsigned_long_long_pointer
;
125 float *v_float_pointer
;
126 double *v_double_pointer
;
128 /**** structs *******/
132 short v_short_member
;
136 long long v_long_long_member
;
138 float v_float_member
;
139 double v_double_member
;
144 short v_short_member
;
148 long long v_long_long_member
;
150 float v_float_member
;
151 double v_double_member
;
154 /**** unions *******/
158 short v_short_member
;
162 long long v_long_long_member
;
164 float v_float_member
;
165 double v_double_member
;
170 short v_short_member
;
174 long long v_long_long_member
;
176 float v_float_member
;
177 double v_double_member
;
180 /*** Functions returning type ********/
182 char v_char_func () { return(0); }
183 signed char v_signed_char_func () { return (0); }
184 unsigned char v_unsigned_char_func () { return (0); }
186 short v_short_func () { return (0); }
187 signed short v_signed_short_func () { return (0); }
188 unsigned short v_unsigned_short_func () { return (0); }
190 int v_int_func () { return (0); }
191 signed int v_signed_int_func () { return (0); }
192 unsigned int v_unsigned_int_func () { return (0); }
194 long v_long_func () { return (0); }
195 signed long v_signed_long_func () { return (0); }
196 unsigned long v_unsigned_long_func () { return (0); }
199 long long v_long_long_func () { return (0); }
200 signed long long v_signed_long_long_func () { return (0); }
201 unsigned long long v_unsigned_long_long_func () { return (0); }
204 float v_float_func () { return (0.0); }
205 double v_double_func () { return (0.0); }
207 /**** Some misc more complicated things *******/
212 struct link
*(*linkfunc
) (struct link
*this, int flags
);
214 struct link
*(*linkfunc
) ();
216 struct t_struct stuff
[1][2][3];
222 struct link
*(*linkfunc
) (struct link
*this, int flags
);
224 struct link
*(*linkfunc
) ();
226 struct t_struct stuff
[1][2][3];
229 struct outer_struct
{
231 struct inner_struct
{
234 }inner_struct_instance
;
237 long inner_union_long
;
238 }inner_union_instance
;
242 /**** Enumerations *******/
244 enum colors
{red
, green
, blue
} color
;
245 enum cars
{chevy
, ford
, porsche
} clunker
;
255 /* Some linkers (e.g. on AIX) remove unreferenced variables,
256 so make sure to reference them. */
263 v_unsigned_short
= 5;
271 v_unsigned_long
= 11;
275 v_signed_long_long
= 13;
276 v_unsigned_long_long
= 14;
283 v_char_array
[0] = v_char
;
284 v_signed_char_array
[0] = v_signed_char
;
285 v_unsigned_char_array
[0] = v_unsigned_char
;
287 v_short_array
[0] = v_short
;
288 v_signed_short_array
[0] = v_signed_short
;
289 v_unsigned_short_array
[0] = v_unsigned_short
;
291 v_int_array
[0] = v_int
;
292 v_signed_int_array
[0] = v_signed_int
;
293 v_unsigned_int_array
[0] = v_unsigned_int
;
295 v_long_array
[0] = v_long
;
296 v_signed_long_array
[0] = v_signed_long
;
297 v_unsigned_long_array
[0] = v_unsigned_long
;
300 v_long_long_array
[0] = v_long_long
;
301 v_signed_long_long_array
[0] = v_signed_long_long
;
302 v_unsigned_long_long_array
[0] = v_unsigned_long_long
;
305 v_float_array
[0] = v_float
;
306 v_double_array
[0] = v_double
;
308 v_char_pointer
= &v_char
;
309 v_signed_char_pointer
= &v_signed_char
;
310 v_unsigned_char_pointer
= &v_unsigned_char
;
312 v_short_pointer
= &v_short
;
313 v_signed_short_pointer
= &v_signed_short
;
314 v_unsigned_short_pointer
= &v_unsigned_short
;
316 v_int_pointer
= &v_int
;
317 v_signed_int_pointer
= &v_signed_int
;
318 v_unsigned_int_pointer
= &v_unsigned_int
;
320 v_long_pointer
= &v_long
;
321 v_signed_long_pointer
= &v_signed_long
;
322 v_unsigned_long_pointer
= &v_unsigned_long
;
325 v_long_long_pointer
= &v_long_long
;
326 v_signed_long_long_pointer
= &v_signed_long_long
;
327 v_unsigned_long_long_pointer
= &v_unsigned_long_long
;
330 v_float_pointer
= &v_float
;
331 v_double_pointer
= &v_double
;
336 u_link
.next
= s_link
;
338 v_union2
.v_short_member
= v_union
.v_short_member
;
340 v_struct1
.v_char_member
= 0;
341 v_struct2
.v_char_member
= 0;
343 nested_su
.outer_int
= 0;