Switch the license of all .c files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.c
CommitLineData
96033e83
MC
1/* This test program is part of GDB, the GNU debugger.
2
6aba47ca 3 Copyright 1992, 1993, 1994, 1997, 1999, 2004, 2007
96033e83
MC
4 Free Software Foundation, Inc.
5
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
a9762ec7 8 the Free Software Foundation; either version 3 of the License, or
96033e83
MC
9 (at your option) any later version.
10
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.
a9762ec7 15
96033e83 16 You should have received a copy of the GNU General Public License
a9762ec7 17 along with this program. If not, see <http://www.gnu.org/licenses/>.
96033e83
MC
18 */
19
c906108c
SS
20/*
21 * Test file with lots of different types, for testing the
22 * "whatis" command.
23 */
24
25/*
26 * First the basic C types.
27 */
28
c906108c
SS
29char v_char;
30signed char v_signed_char;
31unsigned char v_unsigned_char;
32
33short v_short;
34signed short v_signed_short;
35unsigned short v_unsigned_short;
36
37int v_int;
38signed int v_signed_int;
39unsigned int v_unsigned_int;
40
41long v_long;
42signed long v_signed_long;
43unsigned long v_unsigned_long;
44
45float v_float;
46double v_double;
47
48/*
49 * Now some derived types, which are arrays, functions-returning,
50 * pointers, structures, unions, and enumerations.
51 */
52
53/**** arrays *******/
54
55char v_char_array[2];
56signed char v_signed_char_array[2];
57unsigned char v_unsigned_char_array[2];
58
59short v_short_array[2];
60signed short v_signed_short_array[2];
61unsigned short v_unsigned_short_array[2];
62
63int v_int_array[2];
64signed int v_signed_int_array[2];
65unsigned int v_unsigned_int_array[2];
66
67long v_long_array[2];
68signed long v_signed_long_array[2];
69unsigned long v_unsigned_long_array[2];
70
71float v_float_array[2];
72double v_double_array[2];
73
74/**** pointers *******/
75
76/* Make sure they still print as pointer to foo even there is a typedef
77 for that type. Test this not just for char *, which might be
78 a special case kludge in GDB (Unix system include files like to define
79 caddr_t), but for a variety of types. */
80typedef char *char_addr;
f8261448 81static char_addr a_char_addr;
c906108c 82typedef unsigned short *ushort_addr;
f8261448 83static ushort_addr a_ushort_addr;
c906108c 84typedef signed long *slong_addr;
f8261448 85static slong_addr a_slong_addr;
c906108c
SS
86
87char *v_char_pointer;
88signed char *v_signed_char_pointer;
89unsigned char *v_unsigned_char_pointer;
90
91short *v_short_pointer;
92signed short *v_signed_short_pointer;
93unsigned short *v_unsigned_short_pointer;
94
95int *v_int_pointer;
96signed int *v_signed_int_pointer;
97unsigned int *v_unsigned_int_pointer;
98
99long *v_long_pointer;
100signed long *v_signed_long_pointer;
101unsigned long *v_unsigned_long_pointer;
102
103float *v_float_pointer;
104double *v_double_pointer;
105
106/**** structs *******/
107
108struct t_struct {
109 char v_char_member;
110 short v_short_member;
111 int v_int_member;
112 long v_long_member;
113 float v_float_member;
114 double v_double_member;
115} v_struct1;
116
117struct {
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_struct2;
125
126/**** unions *******/
127
128union t_union {
129 char v_char_member;
130 short v_short_member;
131 int v_int_member;
132 long v_long_member;
133 float v_float_member;
134 double v_double_member;
135} v_union;
136
137union {
138 char v_char_member;
139 short v_short_member;
140 int v_int_member;
141 long v_long_member;
142 float v_float_member;
143 double v_double_member;
144} v_union2;
145
146/*** Functions returning type ********/
147
148char v_char_func () { return(0); }
149signed char v_signed_char_func () { return (0); }
150unsigned char v_unsigned_char_func () { return (0); }
151
152short v_short_func () { return (0); }
153signed short v_signed_short_func () { return (0); }
154unsigned short v_unsigned_short_func () { return (0); }
155
156int v_int_func () { return (0); }
157signed int v_signed_int_func () { return (0); }
158unsigned int v_unsigned_int_func () { return (0); }
159
160long v_long_func () { return (0); }
161signed long v_signed_long_func () { return (0); }
162unsigned long v_unsigned_long_func () { return (0); }
163
164float v_float_func () { return (0.0); }
165double v_double_func () { return (0.0); }
166
167/**** Some misc more complicated things *******/
168
169struct link {
170 struct link *next;
171#ifdef __STDC__
172 struct link *(*linkfunc) (struct link *this, int flags);
173#else
174 struct link *(*linkfunc) ();
175#endif
176 struct t_struct stuff[1][2][3];
177} *s_link;
178
179union tu_link {
180 struct link *next;
181#ifdef __STDC__
182 struct link *(*linkfunc) (struct link *this, int flags);
183#else
184 struct link *(*linkfunc) ();
185#endif
186 struct t_struct stuff[1][2][3];
187} u_link;
188
189struct outer_struct {
190 int outer_int;
191 struct inner_struct {
192 int inner_int;
193 long inner_long;
194 }inner_struct_instance;
195 union inner_union {
196 int inner_union_int;
197 long inner_union_long;
198 }inner_union_instance;
199 long outer_long;
200} nested_su;
201
202/**** Enumerations *******/
203
204enum colors {red, green, blue} color;
205enum cars {chevy, ford, porsche} clunker;
206
207/***********/
208
085dd6e6 209int main ()
c906108c
SS
210{
211#ifdef usestubs
212 set_debug_traps();
213 breakpoint();
214#endif
215 /* Some linkers (e.g. on AIX) remove unreferenced variables,
216 so make sure to reference them. */
217 v_char = 0;
218 v_signed_char = 1;
219 v_unsigned_char = 2;
220
221 v_short = 3;
222 v_signed_short = 4;
223 v_unsigned_short = 5;
224
225 v_int = 6;
226 v_signed_int = 7;
227 v_unsigned_int = 8;
228
229 v_long = 9;
230 v_signed_long = 10;
231 v_unsigned_long = 11;
232
233 v_float = 100.0;
234 v_double = 200.0;
235
236
237 v_char_array[0] = v_char;
238 v_signed_char_array[0] = v_signed_char;
239 v_unsigned_char_array[0] = v_unsigned_char;
240
241 v_short_array[0] = v_short;
242 v_signed_short_array[0] = v_signed_short;
243 v_unsigned_short_array[0] = v_unsigned_short;
244
245 v_int_array[0] = v_int;
246 v_signed_int_array[0] = v_signed_int;
247 v_unsigned_int_array[0] = v_unsigned_int;
248
249 v_long_array[0] = v_long;
250 v_signed_long_array[0] = v_signed_long;
251 v_unsigned_long_array[0] = v_unsigned_long;
252
253 v_float_array[0] = v_float;
254 v_double_array[0] = v_double;
255
256 v_char_pointer = &v_char;
257 v_signed_char_pointer = &v_signed_char;
258 v_unsigned_char_pointer = &v_unsigned_char;
259
260 v_short_pointer = &v_short;
261 v_signed_short_pointer = &v_signed_short;
262 v_unsigned_short_pointer = &v_unsigned_short;
263
264 v_int_pointer = &v_int;
265 v_signed_int_pointer = &v_signed_int;
266 v_unsigned_int_pointer = &v_unsigned_int;
267
268 v_long_pointer = &v_long;
269 v_signed_long_pointer = &v_signed_long;
270 v_unsigned_long_pointer = &v_unsigned_long;
271
272 v_float_pointer = &v_float;
273 v_double_pointer = &v_double;
274
275 color = red;
276 clunker = porsche;
277
278 u_link.next = s_link;
279
280 v_union2.v_short_member = v_union.v_short_member;
281
282 v_struct1.v_char_member = 0;
283 v_struct2.v_char_member = 0;
284
285 nested_su.outer_int = 0;
286 return 0;
287}
This page took 0.67584 seconds and 4 git commands to generate.