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