]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/cvexpr.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / cvexpr.exp
1 # Copyright (C) 2001, 2007 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # Written by Michael Snyder, Red Hat, Inc., 9/20/2001
21
22 # This file is part of the gdb testsuite
23 # Tests for type expressions using const and volatile keywords.
24
25 if $tracelevel then {
26 strace $tracelevel
27 }
28
29 #
30 # test running programs
31 #
32 set prms_id 0
33 set bug_id 0
34
35 set testfile "cvexpr"
36 set srcfile ${testfile}.c
37 set binfile ${objdir}/${subdir}/${testfile}
38
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
40 untested cvexpr.exp
41 return -1
42 }
43
44 gdb_exit
45 gdb_start
46 gdb_reinitialize_dir $srcdir/$subdir
47 gdb_load ${binfile}
48
49 if [target_info exists gdb_stub] {
50 gdb_step_for_stub;
51 }
52
53 gdb_test "set print sevenbit-strings" "" ""
54 gdb_test "set print address off" "" ""
55 gdb_test "set width 0" "" ""
56
57 set ws "\[ \t\]*"
58
59 #
60 # Test casting a scalar to const
61 #
62
63 gdb_test "whatis (const char) v_char" \
64 "type = const char" \
65 "(const char)"
66 gdb_test "whatis (const signed char) v_signed_char" \
67 "type = const signed char" \
68 "(const signed char)"
69 gdb_test "whatis (const unsigned char) v_unsigned_char" \
70 "type = const (unsigned char|char)" \
71 "(const unsigned char)"
72 gdb_test "whatis (const short) v_short" \
73 "type = const (short|short int)" \
74 "(const short)"
75 gdb_test "whatis (const signed short) v_signed_short" \
76 "type = const (short|short int|signed short|signed short int)" \
77 "(const signed short)"
78 gdb_test "whatis (const unsigned short) v_unsigned_short" \
79 "type = const (unsigned short|short unsigned int)" \
80 "(const unsigned short)"
81 gdb_test "whatis (const int) v_int" \
82 "type = const int" \
83 "(const int)"
84 gdb_test "whatis (const signed int) v_signed_int" \
85 "type = const (signed int|int)" \
86 "(const signed int)"
87 gdb_test "whatis (const unsigned int) v_unsigned_int" \
88 "type = const unsigned int" \
89 "(const unsigned int)"
90 gdb_test "whatis (const long) v_long" \
91 "type = const (long|long int)" \
92 "(const long)"
93 gdb_test "whatis (const signed long) v_signed_long" \
94 "type = const (signed |)long( int|)" \
95 "(const signed long)"
96 gdb_test "whatis (const unsigned long) v_unsigned_long" \
97 "type = const (unsigned long|long unsigned int)" \
98 "(const unsigned long)"
99 gdb_test "whatis (const long long) v_long_long" \
100 "type = const long long( int|)" \
101 "(const long long)"
102 gdb_test "whatis (const signed long long) v_signed_long_long" \
103 "type = const (signed |)long long( int|)" \
104 "(const signed long long)"
105 gdb_test "whatis (const unsigned long long) v_unsigned_long_long" \
106 "type = const (unsigned long long|long long unsigned int)" \
107 "(const unsigned long long)"
108 gdb_test "whatis (const float) v_float" \
109 "type = const float" \
110 "(const float)"
111 gdb_test "whatis (const double) v_double" \
112 "type = const double" \
113 "(const double)"
114
115 #
116 # Test casting a scalar to volatile
117 #
118
119 gdb_test "whatis (volatile char) v_char" \
120 "type = volatile char" \
121 "(volatile char)"
122 gdb_test "whatis (volatile signed char) v_signed_char" \
123 "type = volatile signed char" \
124 "(volatile signed char)"
125 gdb_test "whatis (volatile unsigned char) v_unsigned_char" \
126 "type = volatile (unsigned char|char)" \
127 "(volatile unsigned char)"
128 gdb_test "whatis (volatile short) v_short" \
129 "type = volatile (short|short int)" \
130 "(volatile short)"
131 gdb_test "whatis (volatile signed short) v_signed_short" \
132 "type = volatile (short|short int|signed short|signed short int)" \
133 "(volatile signed short)"
134 gdb_test "whatis (volatile unsigned short) v_unsigned_short" \
135 "type = volatile (unsigned short|short unsigned int)" \
136 "(volatile unsigned short)"
137 gdb_test "whatis (volatile int) v_int" \
138 "type = volatile int" \
139 "(volatile int)"
140 gdb_test "whatis (volatile signed int) v_signed_int" \
141 "type = volatile (signed int|int)" \
142 "(volatile signed int)"
143 gdb_test "whatis (volatile unsigned int) v_unsigned_int" \
144 "type = volatile unsigned int" \
145 "(volatile unsigned int)"
146 gdb_test "whatis (volatile long) v_long" \
147 "type = volatile (long|long int)" \
148 "(volatile long)"
149 gdb_test "whatis (volatile signed long) v_signed_long" \
150 "type = volatile (signed |)long( int|)" \
151 "(volatile signed long)"
152 gdb_test "whatis (volatile unsigned long) v_unsigned_long" \
153 "type = volatile (unsigned long|long unsigned int)" \
154 "(volatile unsigned long)"
155 gdb_test "whatis (volatile long long) v_long_long" \
156 "type = volatile long long( int|)" \
157 "(volatile long long)"
158 gdb_test "whatis (volatile signed long long) v_signed_long_long" \
159 "type = volatile (signed |)long long( int|)" \
160 "(volatile signed long long)"
161 gdb_test "whatis (volatile unsigned long long) v_unsigned_long_long" \
162 "type = volatile (unsigned long long|long long unsigned int)" \
163 "(volatile unsigned long long)"
164 gdb_test "whatis (volatile float) v_float" \
165 "type = volatile float" \
166 "(volatile float)"
167 gdb_test "whatis (volatile double) v_double" \
168 "type = volatile double" \
169 "(volatile double)"
170
171 #
172 # Combine const and volatile
173 #
174
175 gdb_test "whatis (const volatile int) v_int" \
176 "type = const volatile int" \
177 "(const volatile int)"
178 gdb_test "whatis (volatile const int) v_int" \
179 "type = const volatile int" \
180 "(volatile const int)"
181 gdb_test "whatis (const int volatile) v_int" \
182 "type = const volatile int" \
183 "(const int volatile)"
184 gdb_test "whatis (volatile int const) v_int" \
185 "type = const volatile int" \
186 "(volatile int const)"
187 gdb_test "whatis (int const volatile) v_int" \
188 "type = const volatile int" \
189 "(int const volatile)"
190 gdb_test "whatis (int volatile const) v_int" \
191 "type = const volatile int" \
192 "(int volatile const)"
193
194 gdb_test "whatis (const volatile int *) v_int_pointer" \
195 "type = const volatile int${ws}\\*" \
196 "(const volatile int *)"
197 gdb_test "whatis (volatile const int *) v_int_pointer" \
198 "type = const volatile int${ws}\\*" \
199 "(volatile const int *)"
200 gdb_test "whatis (const int volatile *) v_int_pointer" \
201 "type = const volatile int${ws}\\*" \
202 "(const int volatile)"
203 gdb_test "whatis (volatile int const *) v_int_pointer" \
204 "type = const volatile int${ws}\\*" \
205 "(volatile int const *)"
206 gdb_test "whatis (int const volatile *) v_int_pointer" \
207 "type = const volatile int${ws}\\*" \
208 "(int const volatile *)"
209 gdb_test "whatis (int volatile const *) v_int_pointer" \
210 "type = const volatile int${ws}\\*" \
211 "(int volatile const *)"
212 gdb_test "whatis (int * const volatile) v_int_pointer" \
213 "type = int${ws}\\*${ws}const volatile" \
214 "(int * const volatile)"
215 gdb_test "whatis (int * volatile const) v_int_pointer" \
216 "type = int${ws}\\*${ws}const volatile" \
217 "(int * volatile const)"
218
219
220 #
221 # Put 'signed' and 'unsigned' before const/volatile (FIXME)
222 #
223
224 #gdb_test "whatis (signed const char) v_signed_char" \
225 # "type = const char" \
226 # "(signed const char)"
227 #gdb_test "whatis (unsigned const char) v_unsigned_char" \
228 # "type = const (unsigned char|char)" \
229 # "(unsigned const char)"
230 #gdb_test "whatis (signed const short) v_signed_short" \
231 # "type = const (short|short int|signed short|signed short int)" \
232 # "(signed const short)"
233 #gdb_test "whatis (unsigned const short) v_unsigned_short" \
234 # "type = const (unsigned short|short unsigned int)" \
235 # "(unsigned const short)"
236 #gdb_test "whatis (signed const int) v_signed_int" \
237 # "type = const (signed int|int)" \
238 # "(signed const int)"
239 #gdb_test "whatis (unsigned const int) v_unsigned_int" \
240 # "type = const unsigned int" \
241 # "(unsigned const int)"
242 #gdb_test "whatis (signed const long) v_signed_long" \
243 # "type = const (signed |)long( int|)" \
244 # "(signed const long)"
245 #gdb_test "whatis (unsigned const long) v_unsigned_long" \
246 # "type = const (unsigned long|long unsigned int)" \
247 # "(unsigned const long)"
248 #gdb_test "whatis (signed const long long) v_signed_long_long" \
249 # "type = const (signed |)long long( int|)" \
250 # "(signed const long long)"
251 #gdb_test "whatis (unsigned const long long) v_unsigned_long_long" \
252 # "type = const (unsigned long long|long long unsigned int)" \
253 # "(const unsigned long long)"
254
255 #gdb_test "whatis (signed volatile char) v_signed_char" \
256 # "type = volatile char" \
257 # "(signed volatile char)"
258 #gdb_test "whatis (unsigned volatile char) v_unsigned_char" \
259 # "type = volatile (unsigned char|char)" \
260 # "(unsigned volatile char)"
261 #gdb_test "whatis (signed volatile short) v_signed_short" \
262 # "type = volatile (short|short int|signed short|signed short int)" \
263 # "(signed volatile short)"
264 #gdb_test "whatis (unsigned volatile short) v_unsigned_short" \
265 # "type = volatile (unsigned short|short unsigned int)" \
266 # "(unsigned volatile short)"
267 #gdb_test "whatis (signed volatile int) v_signed_int" \
268 # "type = volatile (signed int|int)" \
269 # "(signed volatile int)"
270 #gdb_test "whatis (unsigned volatile int) v_unsigned_int" \
271 # "type = volatile unsigned int" \
272 # "(unsigned volatile int)"
273 #gdb_test "whatis (signed volatile long) v_signed_long" \
274 # "type = volatile (signed |)long( int|)" \
275 # "(signed volatile long)"
276 #gdb_test "whatis (unsigned volatile long) v_unsigned_long" \
277 # "type = volatile (unsigned long|long unsigned int)" \
278 # "(unsigned volatile long)"
279 #gdb_test "whatis (signed volatile long long) v_signed_long_long" \
280 # "type = volatile (signed |)long long( int|)" \
281 # "(signed volatile long long)"
282 #gdb_test "whatis (unsigned volatile long long) v_unsigned_long_long" \
283 # "type = volatile (unsigned long long|long long unsigned int)" \
284 # "(unsigned volatile long long)"
285
286 #
287 # Now put the 'const' and 'volatile' keywords after the base type.
288 #
289
290 gdb_test "whatis (char const) v_char" \
291 "type = const char" \
292 "(char const)"
293 gdb_test "whatis (signed char const) v_signed_char" \
294 "type = const signed char" \
295 "(signed char const)"
296 gdb_test "whatis (unsigned char const) v_unsigned_char" \
297 "type = const (unsigned char|char)" \
298 "(unsigned char const)"
299 gdb_test "whatis (short const) v_short" \
300 "type = const (short|short int)" \
301 "(short const)"
302 gdb_test "whatis (signed short const) v_signed_short" \
303 "type = const (short|short int|signed short|signed short int)" \
304 "(signed short const)"
305 gdb_test "whatis (unsigned short const) v_unsigned_short" \
306 "type = const (unsigned short|short unsigned int)" \
307 "(unsigned short const)"
308 gdb_test "whatis (int const) v_int" \
309 "type = const int" \
310 "(int const)"
311 gdb_test "whatis (signed int const) v_signed_int" \
312 "type = const (signed int|int)" \
313 "(signed int const)"
314 gdb_test "whatis (unsigned int const) v_unsigned_int" \
315 "type = const unsigned int" \
316 "(unsigned int const)"
317 gdb_test "whatis (long const) v_long" \
318 "type = const (long|long int)" \
319 "(long const)"
320 gdb_test "whatis (signed long const) v_signed_long" \
321 "type = const (signed |)long( int|)" \
322 "(signed long const)"
323 gdb_test "whatis (unsigned long const) v_unsigned_long" \
324 "type = const (unsigned long|long unsigned int)" \
325 "(unsigned long const)"
326 gdb_test "whatis (long long const) v_long_long" \
327 "type = const long long( int|)" \
328 "(long long const)"
329 gdb_test "whatis (signed long long const) v_signed_long_long" \
330 "type = const (signed |)long long( int|)" \
331 "(signed long long const)"
332 gdb_test "whatis (unsigned long long const) v_unsigned_long_long" \
333 "type = const (unsigned long long|long long unsigned int)" \
334 "(unsigned long long const)"
335 gdb_test "whatis (float const) v_float" \
336 "type = const float" \
337 "(float const)"
338 gdb_test "whatis (double const) v_double" \
339 "type = const double" \
340 "(double const)"
341
342 gdb_test "whatis (char volatile) v_char" \
343 "type = volatile char" \
344 "(char volatile)"
345 gdb_test "whatis (signed char volatile) v_signed_char" \
346 "type = volatile signed char" \
347 "(signed char volatile)"
348 gdb_test "whatis (unsigned char volatile) v_unsigned_char" \
349 "type = volatile (unsigned char|char)" \
350 "(unsigned char volatile)"
351 gdb_test "whatis (short volatile) v_short" \
352 "type = volatile (short|short int)" \
353 "(short volatile)"
354 gdb_test "whatis (signed short volatile) v_signed_short" \
355 "type = volatile (short|short int|signed short|signed short int)" \
356 "(signed short volatile)"
357 gdb_test "whatis (unsigned short volatile) v_unsigned_short" \
358 "type = volatile (unsigned short|short unsigned int)" \
359 "(unsigned short volatile)"
360 gdb_test "whatis (int volatile) v_int" \
361 "type = volatile int" \
362 "(int volatile)"
363 gdb_test "whatis (signed int volatile) v_signed_int" \
364 "type = volatile (signed int|int)" \
365 "(signed int volatile)"
366 gdb_test "whatis (unsigned int volatile) v_unsigned_int" \
367 "type = volatile unsigned int" \
368 "(unsigned int volatile)"
369 gdb_test "whatis (long volatile) v_long" \
370 "type = volatile (long|long int)" \
371 "(long volatile)"
372 gdb_test "whatis (signed long volatile) v_signed_long" \
373 "type = volatile (signed |)long( int|)" \
374 "(signed long volatile)"
375 gdb_test "whatis (unsigned long volatile) v_unsigned_long" \
376 "type = volatile (unsigned long|long unsigned int)" \
377 "(unsigned long volatile)"
378 gdb_test "whatis (long long volatile) v_long_long" \
379 "type = volatile long long( int|)" \
380 "(long long volatile)"
381 gdb_test "whatis (signed long long volatile) v_signed_long_long" \
382 "type = volatile (signed |)long long( int|)" \
383 "(signed long long volatile)"
384 gdb_test "whatis (unsigned long long volatile) v_unsigned_long_long" \
385 "type = volatile (unsigned long long|long long unsigned int)" \
386 "(unsigned long long volatile)"
387 gdb_test "whatis (float volatile) v_float" \
388 "type = volatile float" \
389 "(float volatile)"
390 gdb_test "whatis (double volatile) v_double" \
391 "type = volatile double" \
392 "(double volatile)"
393
394 #
395 # enums
396 #
397
398 gdb_test "whatis (const enum misordered) v_misordered" \
399 "type = const enum misordered" \
400 "(const enum misordered)"
401 gdb_test "whatis (enum misordered const) v_misordered" \
402 "type = const enum misordered" \
403 "(enum misordered const)"
404 gdb_test "whatis (volatile enum misordered) v_misordered" \
405 "type = volatile enum misordered" \
406 "(volatile enum misordered)"
407 gdb_test "whatis (enum misordered volatile) v_misordered" \
408 "type = volatile enum misordered" \
409 "(enum misordered volatile)"
410
411 #
412 # Pointers
413 #
414
415 gdb_test "whatis (const int *) v_int_pointer" \
416 "type = const int${ws}\\*" \
417 "(const int *)"
418 gdb_test "whatis (int const *) v_int_pointer" \
419 "type = const int${ws}\\*" \
420 "(int const *)"
421 gdb_test "whatis (int * const) v_int_pointer" \
422 "type = int \\*${ws}const" \
423 "(int * const)"
424 gdb_test "whatis (const int * const) v_int_pointer" \
425 "type = const int${ws}\\*${ws}const" \
426 "(const int * const)"
427 gdb_test "whatis (int const * const) v_int_pointer" \
428 "type = const int${ws}\\*${ws}const" \
429 "(int const * const)"
430
431 gdb_test "whatis (const int **) v_int_pointer_pointer" \
432 "type = const int${ws}\\*${ws}\\*" \
433 "(const int **)"
434 gdb_test "whatis (int const **) v_int_pointer_pointer" \
435 "type = const int${ws}\\*${ws}\\*" \
436 "(int const **)"
437 gdb_test "whatis (int ** const) v_int_pointer_pointer" \
438 "type = int \\*${ws}\\*${ws}const" \
439 "(int ** const)"
440 gdb_test "whatis (const int * const *) v_int_pointer_pointer" \
441 "type = const int${ws}\\*${ws}const${ws}\\*" \
442 "(const int * const *)"
443 gdb_test "whatis (int const * const *) v_int_pointer_pointer" \
444 "type = const int${ws}\\*${ws}const${ws}\\*" \
445 "(int const * const *)"
446 gdb_test "whatis (const int * const * const) v_int_pointer_pointer" \
447 "type = const int${ws}\\*${ws}const${ws}\\*${ws}const" \
448 "(const int * const * const)"
449 gdb_test "whatis (int const * const * const) v_int_pointer_pointer" \
450 "type = const int${ws}\\*${ws}const${ws}\\*${ws}const" \
451 "(int const * const * const)"
452
453 #
454 # Arrays TODO
455 #
456
457 #
458 # Pointers to arrays, arrays of pointers TODO
459 #
460
461 #
462 # Structs and Unions
463 #
464
465 gdb_test "whatis (const struct t_struct) v_struct1" \
466 "type = const struct t_struct" \
467 "(const struct t_struct)"
468 gdb_test "whatis (const union t_union) v_union" \
469 "type = const union t_union" \
470 "(const union t_union)"
471 gdb_test "whatis (struct t_struct const) v_struct1" \
472 "type = const struct t_struct" \
473 "(struct t_struct const)"
474 gdb_test "whatis (union t_union const) v_union" \
475 "type = const union t_union" \
476 "(union t_union const)"
477 gdb_test "whatis (const struct t_struct *) &v_struct1" \
478 "type = const struct t_struct${ws}\\*" \
479 "(const struct t_struct *)"
480 gdb_test "whatis (const union t_union *) &v_union" \
481 "type = const union t_union${ws}\\*" \
482 "(const union t_union *)"
483 gdb_test "whatis (struct t_struct const *) &v_struct1" \
484 "type = const struct t_struct${ws}\\*" \
485 "(struct t_struct const *)"
486 gdb_test "whatis (union t_union const *) &v_union" \
487 "type = const union t_union${ws}\\*" \
488 "(union t_union const *)"
489 gdb_test "whatis (struct t_struct * const) &v_struct1" \
490 "type = struct t_struct${ws}\\*${ws}const" \
491 "(struct t_struct * const)"
492 gdb_test "whatis (union t_union * const) &v_union" \
493 "type = union t_union${ws}\\*${ws}const" \
494 "(union t_union * const)"
495 gdb_test "whatis (const struct t_struct * const) &v_struct1" \
496 "type = const struct t_struct${ws}\\*${ws}const" \
497 "(const struct t_struct * const)"
498 gdb_test "whatis (const union t_union * const) &v_union" \
499 "type = const union t_union${ws}\\*${ws}const" \
500 "(const union t_union * const)"
501 gdb_test "whatis (struct t_struct const * const) &v_struct1" \
502 "type = const struct t_struct${ws}\\*${ws}const" \
503 "(struct t_struct const * const)"
504 gdb_test "whatis (union t_union const * const) &v_union" \
505 "type = const union t_union${ws}\\*${ws}const" \
506 "(union t_union const * const)"
507
508 #
509 # Function pointers TODO
510 #
511