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