1 /* This test program is part of GDB, the GNU debugger.
3 Copyright 2019 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
20 * "ptype" command on CTF data. It's devired from ptype.c.
24 * First the basic C types.
27 #if !defined (__STDC__) && !defined (_AIX)
32 signed char v_signed_char
;
33 unsigned char v_unsigned_char
;
36 signed short v_signed_short
;
37 unsigned short v_unsigned_short
;
40 signed int v_signed_int
;
41 unsigned int v_unsigned_int
;
44 signed long v_signed_long
;
45 unsigned long v_unsigned_long
;
53 signed char v_signed_char_array
[2];
54 unsigned char v_unsigned_char_array
[2];
56 short v_short_array
[2];
57 signed short v_signed_short_array
[2];
58 unsigned short v_unsigned_short_array
[2];
61 signed int v_signed_int_array
[2];
62 unsigned int v_unsigned_int_array
[2];
65 signed long v_signed_long_array
[2];
66 unsigned long v_unsigned_long_array
[2];
68 float v_float_array
[2];
69 double v_double_array
[2];
72 typedef char t_char_array
[];
73 t_char_array
*pv_char_array
;
75 /**** pointers *******/
78 signed char *v_signed_char_pointer
;
79 unsigned char *v_unsigned_char_pointer
;
81 short *v_short_pointer
;
82 signed short *v_signed_short_pointer
;
83 unsigned short *v_unsigned_short_pointer
;
86 signed int *v_signed_int_pointer
;
87 unsigned int *v_unsigned_int_pointer
;
90 signed long *v_signed_long_pointer
;
91 unsigned long *v_unsigned_long_pointer
;
93 float *v_float_pointer
;
94 double *v_double_pointer
;
96 /**** structs *******/
100 short v_short_member
;
103 float v_float_member
;
104 double v_double_member
;
107 struct t_struct
*v_t_struct_p
;
111 short v_short_member
;
114 float v_float_member
;
115 double v_double_member
;
118 /* typedef'd struct without a tag. */
120 double v_double_member
;
123 /* GCC seems to want a variable of this type, or else it won't put out
127 /**** unions *******/
131 short v_short_member
;
134 float v_float_member
;
135 double v_double_member
;
140 short v_short_member
;
143 float v_float_member
;
144 double v_double_member
;
147 /* typedef'd union without a tag. */
149 double v_double_member
;
152 /* GCC seems to want a variable of this type, or else it won't put out
156 /**** Some misc more complicated things *******/
158 struct outer_struct
{
160 struct inner_struct
{
163 }inner_struct_instance
;
166 long inner_union_long
;
167 }inner_union_instance
;
177 struct { int c
; } anonymous_level_2
;
181 /**** Enumerations *******/
184 /* Work around the bug for compilers which don't put out the right stabs. */
185 #if __GNUC__ < 2 && !defined (_AIX)
188 {red1
, green1
, blue1
} primary1
;
190 enum {red
, green
, blue
} primary
;
191 enum colors
{yellow
, purple
, pink
} nonprimary
;
193 enum {chevy
, ford
} clunker
;
194 enum cars
{bmw
, porsche
} sportscar
;
198 typedef enum {FALSE
, TRUE
} boolean
;
200 /*note: aCC has bool type predefined with 'false' and 'true'*/
201 typedef enum bvals
{my_false
, my_true
} boolean2
;
204 enum misordered
{two
= 2, one
= 1, zero
= 0, three
= 3};
206 /* Seems like we need a variable of this type to get the type to be put
207 in the executable, at least for AIX xlc. */
208 enum misordered v_misordered
= three
;
210 /**** Pointers to functions *******/
212 typedef int (*func_type
) (int (*) (int, float), float);
213 double (*old_fptr
) ();
214 double (*new_fptr
) (void);
215 int (*fptr
) (int, float);
216 int *(*fptr2
) (int (*) (int, float), float);
217 int (*xptr
) (int (*) (), int (*) (void), int);
218 int (*(*ffptr
) (char)) (short);
219 int (*(*(*fffptr
) (char)) (short)) (long);
221 func_type v_func_type
;
225 /* Ensure that malloc is a pointer type; avoid use of "void" and any include files. */
226 /* extern char *malloc();*/
228 /* Some of the tests in ptype.exp require invoking malloc, so make
229 sure it is linked in to this program. */
230 v_char_pointer
= (char *) malloc (1);
232 /* Some linkers (e.g. on AIX) remove unreferenced variables,
233 so make sure to reference them. */
239 v_struct1
.v_int_member
= 5;
240 v_struct2
.v_int_member
= 6;
241 v_struct3
.v_int_member
= 7;
249 v_unsigned_short
= 0;
263 v_signed_char_array
[0] = 0;
264 v_unsigned_char_array
[0] = 0;
266 v_short_array
[0] = 0;
267 v_signed_short_array
[0] = 0;
268 v_unsigned_short_array
[0] = 0;
271 v_signed_int_array
[0] = 0;
272 v_unsigned_int_array
[0] = 0;
275 v_signed_long_array
[0] = 0;
276 v_unsigned_long_array
[0] = 0;
278 v_float_array
[0] = 0;
279 v_double_array
[0] = 0;
282 v_signed_char_pointer
= 0;
283 v_unsigned_char_pointer
= 0;
286 v_signed_short_pointer
= 0;
287 v_unsigned_short_pointer
= 0;
290 v_signed_int_pointer
= 0;
291 v_unsigned_int_pointer
= 0;
294 v_signed_long_pointer
= 0;
295 v_unsigned_long_pointer
= 0;
298 v_double_pointer
= 0;
300 nested_su
.outer_int
= 0;
This page took 0.038818 seconds and 4 git commands to generate.