* config/tc-arm.c (arm_cpus): Add entry for ARM Cortex-M0.
[binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.c
blob80aa86a47e692e0117d462e38cf30c54bbfa9f2f
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
22 * "whatis" command.
26 * First the basic C types.
29 char v_char;
30 signed char v_signed_char;
31 unsigned char v_unsigned_char;
33 short v_short;
34 signed short v_signed_short;
35 unsigned short v_unsigned_short;
37 int v_int;
38 signed int v_signed_int;
39 unsigned int v_unsigned_int;
41 long v_long;
42 signed long v_signed_long;
43 unsigned long v_unsigned_long;
45 #ifndef NO_LONG_LONG
46 long long v_long_long;
47 signed long long v_signed_long_long;
48 unsigned long long v_unsigned_long_long;
49 #endif
51 float v_float;
52 double v_double;
55 * Now some derived types, which are arrays, functions-returning,
56 * pointers, structures, unions, and enumerations.
59 /**** arrays *******/
61 char v_char_array[2];
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];
69 int v_int_array[2];
70 signed int v_signed_int_array[2];
71 unsigned int v_unsigned_int_array[2];
73 long v_long_array[2];
74 signed long v_signed_long_array[2];
75 unsigned long v_unsigned_long_array[2];
77 #ifndef NO_LONG_LONG
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];
81 #endif
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;
98 #ifndef NO_LONG_LONG
99 typedef signed long long *slong_long_addr;
100 static slong_long_addr a_slong_long_addr;
101 #endif
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;
111 int *v_int_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;
119 #ifndef NO_LONG_LONG
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;
123 #endif
125 float *v_float_pointer;
126 double *v_double_pointer;
128 /**** structs *******/
130 struct t_struct {
131 char v_char_member;
132 short v_short_member;
133 int v_int_member;
134 long v_long_member;
135 #ifndef NO_LONG_LONG
136 long long v_long_long_member;
137 #endif
138 float v_float_member;
139 double v_double_member;
140 } v_struct1;
142 struct {
143 char v_char_member;
144 short v_short_member;
145 int v_int_member;
146 long v_long_member;
147 #ifndef NO_LONG_LONG
148 long long v_long_long_member;
149 #endif
150 float v_float_member;
151 double v_double_member;
152 } v_struct2;
154 /**** unions *******/
156 union t_union {
157 char v_char_member;
158 short v_short_member;
159 int v_int_member;
160 long v_long_member;
161 #ifndef NO_LONG_LONG
162 long long v_long_long_member;
163 #endif
164 float v_float_member;
165 double v_double_member;
166 } v_union;
168 union {
169 char v_char_member;
170 short v_short_member;
171 int v_int_member;
172 long v_long_member;
173 #ifndef NO_LONG_LONG
174 long long v_long_long_member;
175 #endif
176 float v_float_member;
177 double v_double_member;
178 } v_union2;
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); }
198 #ifndef NO_LONG_LONG
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); }
202 #endif
204 float v_float_func () { return (0.0); }
205 double v_double_func () { return (0.0); }
207 /**** Some misc more complicated things *******/
209 struct link {
210 struct link *next;
211 #ifdef __STDC__
212 struct link *(*linkfunc) (struct link *this, int flags);
213 #else
214 struct link *(*linkfunc) ();
215 #endif
216 struct t_struct stuff[1][2][3];
217 } *s_link;
219 union tu_link {
220 struct link *next;
221 #ifdef __STDC__
222 struct link *(*linkfunc) (struct link *this, int flags);
223 #else
224 struct link *(*linkfunc) ();
225 #endif
226 struct t_struct stuff[1][2][3];
227 } u_link;
229 struct outer_struct {
230 int outer_int;
231 struct inner_struct {
232 int inner_int;
233 long inner_long;
234 }inner_struct_instance;
235 union inner_union {
236 int inner_union_int;
237 long inner_union_long;
238 }inner_union_instance;
239 long outer_long;
240 } nested_su;
242 /**** Enumerations *******/
244 enum colors {red, green, blue} color;
245 enum cars {chevy, ford, porsche} clunker;
247 /***********/
249 int main ()
251 #ifdef usestubs
252 set_debug_traps();
253 breakpoint();
254 #endif
255 /* Some linkers (e.g. on AIX) remove unreferenced variables,
256 so make sure to reference them. */
257 v_char = 0;
258 v_signed_char = 1;
259 v_unsigned_char = 2;
261 v_short = 3;
262 v_signed_short = 4;
263 v_unsigned_short = 5;
265 v_int = 6;
266 v_signed_int = 7;
267 v_unsigned_int = 8;
269 v_long = 9;
270 v_signed_long = 10;
271 v_unsigned_long = 11;
273 #ifndef NO_LONG_LONG
274 v_long_long = 12;
275 v_signed_long_long = 13;
276 v_unsigned_long_long = 14;
277 #endif
279 v_float = 100.0;
280 v_double = 200.0;
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;
299 #ifndef NO_LONG_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;
303 #endif
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;
324 #ifndef NO_LONG_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;
328 #endif
330 v_float_pointer = &v_float;
331 v_double_pointer = &v_double;
333 color = red;
334 clunker = porsche;
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;
344 return 0;