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