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