]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/cvexpr.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / cvexpr.exp
CommitLineData
6aba47ca 1# Copyright (C) 2001, 2007 Free Software Foundation, Inc.
4749e309
MS
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
25if $tracelevel then {
26 strace $tracelevel
27 }
28
29#
30# test running programs
31#
32set prms_id 0
33set bug_id 0
34
35set testfile "cvexpr"
36set srcfile ${testfile}.c
37set binfile ${objdir}/${subdir}/${testfile}
38
39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
40 untested cvexpr.exp
41 return -1
4749e309
MS
42}
43
44gdb_exit
45gdb_start
46gdb_reinitialize_dir $srcdir/$subdir
47gdb_load ${binfile}
48
49if [target_info exists gdb_stub] {
50 gdb_step_for_stub;
51}
52
53gdb_test "set print sevenbit-strings" "" ""
54gdb_test "set print address off" "" ""
55gdb_test "set width 0" "" ""
56
57set ws "\[ \t\]*"
58
59#
60# Test casting a scalar to const
61#
62
63gdb_test "whatis (const char) v_char" \
64 "type = const char" \
65 "(const char)"
66gdb_test "whatis (const signed char) v_signed_char" \
67 "type = const signed char" \
68 "(const signed char)"
69gdb_test "whatis (const unsigned char) v_unsigned_char" \
70 "type = const (unsigned char|char)" \
71 "(const unsigned char)"
72gdb_test "whatis (const short) v_short" \
73 "type = const (short|short int)" \
74 "(const short)"
75gdb_test "whatis (const signed short) v_signed_short" \
76 "type = const (short|short int|signed short|signed short int)" \
77 "(const signed short)"
78gdb_test "whatis (const unsigned short) v_unsigned_short" \
79 "type = const (unsigned short|short unsigned int)" \
80 "(const unsigned short)"
81gdb_test "whatis (const int) v_int" \
82 "type = const int" \
83 "(const int)"
84gdb_test "whatis (const signed int) v_signed_int" \
85 "type = const (signed int|int)" \
86 "(const signed int)"
87gdb_test "whatis (const unsigned int) v_unsigned_int" \
88 "type = const unsigned int" \
89 "(const unsigned int)"
90gdb_test "whatis (const long) v_long" \
91 "type = const (long|long int)" \
92 "(const long)"
93gdb_test "whatis (const signed long) v_signed_long" \
94 "type = const (signed |)long( int|)" \
95 "(const signed long)"
96gdb_test "whatis (const unsigned long) v_unsigned_long" \
97 "type = const (unsigned long|long unsigned int)" \
98 "(const unsigned long)"
99gdb_test "whatis (const long long) v_long_long" \
100 "type = const long long( int|)" \
101 "(const long long)"
102gdb_test "whatis (const signed long long) v_signed_long_long" \
103 "type = const (signed |)long long( int|)" \
104 "(const signed long long)"
105gdb_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)"
108gdb_test "whatis (const float) v_float" \
109 "type = const float" \
110 "(const float)"
111gdb_test "whatis (const double) v_double" \
112 "type = const double" \
113 "(const double)"
114
115#
116# Test casting a scalar to volatile
117#
118
119gdb_test "whatis (volatile char) v_char" \
120 "type = volatile char" \
121 "(volatile char)"
122gdb_test "whatis (volatile signed char) v_signed_char" \
123 "type = volatile signed char" \
124 "(volatile signed char)"
125gdb_test "whatis (volatile unsigned char) v_unsigned_char" \
126 "type = volatile (unsigned char|char)" \
127 "(volatile unsigned char)"
128gdb_test "whatis (volatile short) v_short" \
129 "type = volatile (short|short int)" \
130 "(volatile short)"
131gdb_test "whatis (volatile signed short) v_signed_short" \
132 "type = volatile (short|short int|signed short|signed short int)" \
133 "(volatile signed short)"
134gdb_test "whatis (volatile unsigned short) v_unsigned_short" \
135 "type = volatile (unsigned short|short unsigned int)" \
136 "(volatile unsigned short)"
137gdb_test "whatis (volatile int) v_int" \
138 "type = volatile int" \
139 "(volatile int)"
140gdb_test "whatis (volatile signed int) v_signed_int" \
141 "type = volatile (signed int|int)" \
142 "(volatile signed int)"
143gdb_test "whatis (volatile unsigned int) v_unsigned_int" \
144 "type = volatile unsigned int" \
145 "(volatile unsigned int)"
146gdb_test "whatis (volatile long) v_long" \
147 "type = volatile (long|long int)" \
148 "(volatile long)"
149gdb_test "whatis (volatile signed long) v_signed_long" \
150 "type = volatile (signed |)long( int|)" \
151 "(volatile signed long)"
152gdb_test "whatis (volatile unsigned long) v_unsigned_long" \
153 "type = volatile (unsigned long|long unsigned int)" \
154 "(volatile unsigned long)"
155gdb_test "whatis (volatile long long) v_long_long" \
156 "type = volatile long long( int|)" \
157 "(volatile long long)"
158gdb_test "whatis (volatile signed long long) v_signed_long_long" \
159 "type = volatile (signed |)long long( int|)" \
160 "(volatile signed long long)"
161gdb_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)"
164gdb_test "whatis (volatile float) v_float" \
165 "type = volatile float" \
166 "(volatile float)"
167gdb_test "whatis (volatile double) v_double" \
168 "type = volatile double" \
169 "(volatile double)"
170
171#
172# Combine const and volatile
173#
174
175gdb_test "whatis (const volatile int) v_int" \
176 "type = const volatile int" \
177 "(const volatile int)"
178gdb_test "whatis (volatile const int) v_int" \
179 "type = const volatile int" \
180 "(volatile const int)"
181gdb_test "whatis (const int volatile) v_int" \
182 "type = const volatile int" \
183 "(const int volatile)"
184gdb_test "whatis (volatile int const) v_int" \
185 "type = const volatile int" \
186 "(volatile int const)"
187gdb_test "whatis (int const volatile) v_int" \
188 "type = const volatile int" \
189 "(int const volatile)"
190gdb_test "whatis (int volatile const) v_int" \
191 "type = const volatile int" \
192 "(int volatile const)"
193
194gdb_test "whatis (const volatile int *) v_int_pointer" \
195 "type = const volatile int${ws}\\*" \
196 "(const volatile int *)"
197gdb_test "whatis (volatile const int *) v_int_pointer" \
198 "type = const volatile int${ws}\\*" \
199 "(volatile const int *)"
200gdb_test "whatis (const int volatile *) v_int_pointer" \
201 "type = const volatile int${ws}\\*" \
202 "(const int volatile)"
203gdb_test "whatis (volatile int const *) v_int_pointer" \
204 "type = const volatile int${ws}\\*" \
205 "(volatile int const *)"
206gdb_test "whatis (int const volatile *) v_int_pointer" \
207 "type = const volatile int${ws}\\*" \
208 "(int const volatile *)"
209gdb_test "whatis (int volatile const *) v_int_pointer" \
210 "type = const volatile int${ws}\\*" \
211 "(int volatile const *)"
212gdb_test "whatis (int * const volatile) v_int_pointer" \
213 "type = int${ws}\\*${ws}const volatile" \
214 "(int * const volatile)"
215gdb_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
290gdb_test "whatis (char const) v_char" \
291 "type = const char" \
292 "(char const)"
293gdb_test "whatis (signed char const) v_signed_char" \
294 "type = const signed char" \
295 "(signed char const)"
296gdb_test "whatis (unsigned char const) v_unsigned_char" \
297 "type = const (unsigned char|char)" \
298 "(unsigned char const)"
299gdb_test "whatis (short const) v_short" \
300 "type = const (short|short int)" \
301 "(short const)"
302gdb_test "whatis (signed short const) v_signed_short" \
303 "type = const (short|short int|signed short|signed short int)" \
304 "(signed short const)"
305gdb_test "whatis (unsigned short const) v_unsigned_short" \
306 "type = const (unsigned short|short unsigned int)" \
307 "(unsigned short const)"
308gdb_test "whatis (int const) v_int" \
309 "type = const int" \
310 "(int const)"
311gdb_test "whatis (signed int const) v_signed_int" \
312 "type = const (signed int|int)" \
313 "(signed int const)"
314gdb_test "whatis (unsigned int const) v_unsigned_int" \
315 "type = const unsigned int" \
316 "(unsigned int const)"
317gdb_test "whatis (long const) v_long" \
318 "type = const (long|long int)" \
319 "(long const)"
320gdb_test "whatis (signed long const) v_signed_long" \
321 "type = const (signed |)long( int|)" \
322 "(signed long const)"
323gdb_test "whatis (unsigned long const) v_unsigned_long" \
324 "type = const (unsigned long|long unsigned int)" \
325 "(unsigned long const)"
326gdb_test "whatis (long long const) v_long_long" \
327 "type = const long long( int|)" \
328 "(long long const)"
329gdb_test "whatis (signed long long const) v_signed_long_long" \
330 "type = const (signed |)long long( int|)" \
331 "(signed long long const)"
332gdb_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)"
335gdb_test "whatis (float const) v_float" \
336 "type = const float" \
337 "(float const)"
338gdb_test "whatis (double const) v_double" \
339 "type = const double" \
340 "(double const)"
341
342gdb_test "whatis (char volatile) v_char" \
343 "type = volatile char" \
344 "(char volatile)"
345gdb_test "whatis (signed char volatile) v_signed_char" \
346 "type = volatile signed char" \
347 "(signed char volatile)"
348gdb_test "whatis (unsigned char volatile) v_unsigned_char" \
349 "type = volatile (unsigned char|char)" \
350 "(unsigned char volatile)"
351gdb_test "whatis (short volatile) v_short" \
352 "type = volatile (short|short int)" \
353 "(short volatile)"
354gdb_test "whatis (signed short volatile) v_signed_short" \
355 "type = volatile (short|short int|signed short|signed short int)" \
356 "(signed short volatile)"
357gdb_test "whatis (unsigned short volatile) v_unsigned_short" \
358 "type = volatile (unsigned short|short unsigned int)" \
359 "(unsigned short volatile)"
360gdb_test "whatis (int volatile) v_int" \
361 "type = volatile int" \
362 "(int volatile)"
363gdb_test "whatis (signed int volatile) v_signed_int" \
364 "type = volatile (signed int|int)" \
365 "(signed int volatile)"
366gdb_test "whatis (unsigned int volatile) v_unsigned_int" \
367 "type = volatile unsigned int" \
368 "(unsigned int volatile)"
369gdb_test "whatis (long volatile) v_long" \
370 "type = volatile (long|long int)" \
371 "(long volatile)"
372gdb_test "whatis (signed long volatile) v_signed_long" \
373 "type = volatile (signed |)long( int|)" \
374 "(signed long volatile)"
375gdb_test "whatis (unsigned long volatile) v_unsigned_long" \
376 "type = volatile (unsigned long|long unsigned int)" \
377 "(unsigned long volatile)"
378gdb_test "whatis (long long volatile) v_long_long" \
379 "type = volatile long long( int|)" \
380 "(long long volatile)"
381gdb_test "whatis (signed long long volatile) v_signed_long_long" \
382 "type = volatile (signed |)long long( int|)" \
383 "(signed long long volatile)"
384gdb_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)"
387gdb_test "whatis (float volatile) v_float" \
388 "type = volatile float" \
389 "(float volatile)"
390gdb_test "whatis (double volatile) v_double" \
391 "type = volatile double" \
392 "(double volatile)"
393
394#
395# enums
396#
397
398gdb_test "whatis (const enum misordered) v_misordered" \
399 "type = const enum misordered" \
400 "(const enum misordered)"
401gdb_test "whatis (enum misordered const) v_misordered" \
402 "type = const enum misordered" \
403 "(enum misordered const)"
404gdb_test "whatis (volatile enum misordered) v_misordered" \
405 "type = volatile enum misordered" \
406 "(volatile enum misordered)"
407gdb_test "whatis (enum misordered volatile) v_misordered" \
408 "type = volatile enum misordered" \
409 "(enum misordered volatile)"
410
411#
412# Pointers
413#
414
415gdb_test "whatis (const int *) v_int_pointer" \
416 "type = const int${ws}\\*" \
417 "(const int *)"
418gdb_test "whatis (int const *) v_int_pointer" \
419 "type = const int${ws}\\*" \
420 "(int const *)"
421gdb_test "whatis (int * const) v_int_pointer" \
422 "type = int \\*${ws}const" \
423 "(int * const)"
424gdb_test "whatis (const int * const) v_int_pointer" \
425 "type = const int${ws}\\*${ws}const" \
426 "(const int * const)"
427gdb_test "whatis (int const * const) v_int_pointer" \
428 "type = const int${ws}\\*${ws}const" \
429 "(int const * const)"
430
431gdb_test "whatis (const int **) v_int_pointer_pointer" \
432 "type = const int${ws}\\*${ws}\\*" \
433 "(const int **)"
434gdb_test "whatis (int const **) v_int_pointer_pointer" \
435 "type = const int${ws}\\*${ws}\\*" \
436 "(int const **)"
437gdb_test "whatis (int ** const) v_int_pointer_pointer" \
438 "type = int \\*${ws}\\*${ws}const" \
439 "(int ** const)"
440gdb_test "whatis (const int * const *) v_int_pointer_pointer" \
441 "type = const int${ws}\\*${ws}const${ws}\\*" \
442 "(const int * const *)"
443gdb_test "whatis (int const * const *) v_int_pointer_pointer" \
444 "type = const int${ws}\\*${ws}const${ws}\\*" \
445 "(int const * const *)"
446gdb_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)"
449gdb_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
465gdb_test "whatis (const struct t_struct) v_struct1" \
466 "type = const struct t_struct" \
467 "(const struct t_struct)"
468gdb_test "whatis (const union t_union) v_union" \
469 "type = const union t_union" \
470 "(const union t_union)"
471gdb_test "whatis (struct t_struct const) v_struct1" \
472 "type = const struct t_struct" \
473 "(struct t_struct const)"
474gdb_test "whatis (union t_union const) v_union" \
475 "type = const union t_union" \
476 "(union t_union const)"
477gdb_test "whatis (const struct t_struct *) &v_struct1" \
478 "type = const struct t_struct${ws}\\*" \
479 "(const struct t_struct *)"
480gdb_test "whatis (const union t_union *) &v_union" \
481 "type = const union t_union${ws}\\*" \
482 "(const union t_union *)"
483gdb_test "whatis (struct t_struct const *) &v_struct1" \
484 "type = const struct t_struct${ws}\\*" \
485 "(struct t_struct const *)"
486gdb_test "whatis (union t_union const *) &v_union" \
487 "type = const union t_union${ws}\\*" \
488 "(union t_union const *)"
489gdb_test "whatis (struct t_struct * const) &v_struct1" \
490 "type = struct t_struct${ws}\\*${ws}const" \
491 "(struct t_struct * const)"
492gdb_test "whatis (union t_union * const) &v_union" \
493 "type = union t_union${ws}\\*${ws}const" \
494 "(union t_union * const)"
495gdb_test "whatis (const struct t_struct * const) &v_struct1" \
496 "type = const struct t_struct${ws}\\*${ws}const" \
497 "(const struct t_struct * const)"
498gdb_test "whatis (const union t_union * const) &v_union" \
499 "type = const union t_union${ws}\\*${ws}const" \
500 "(const union t_union * const)"
501gdb_test "whatis (struct t_struct const * const) &v_struct1" \
502 "type = const struct t_struct${ws}\\*${ws}const" \
503 "(struct t_struct const * const)"
504gdb_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