Updated copyright notices for most files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / code-expr.exp
CommitLineData
0fb0cc75 1# Copyright (C) 2001, 2007, 2008, 2009 Free Software Foundation, Inc.
bb632afb
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
bb632afb 6# (at your option) any later version.
e22f8b7c 7#
bb632afb
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#
bb632afb 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/>.
bb632afb 15
bb632afb
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 the new "@code" and "@data" modifiers.
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 code-expr.exp
37 return -1
bb632afb
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 (@code char) v_char" \
60 "type = @code char" \
61 "(@code char)"
62gdb_test "whatis (@code signed char) v_signed_char" \
63 "type = @code signed char" \
64 "(@code signed char)"
65gdb_test "whatis (@code unsigned char) v_unsigned_char" \
66 "type = @code (unsigned char|char)" \
67 "(@code unsigned char)"
68gdb_test "whatis (@code short) v_short" \
69 "type = @code (short|short int)" \
70 "(@code short)"
71gdb_test "whatis (@code signed short) v_signed_short" \
72 "type = @code (short|short int|signed short|signed short int)" \
73 "(@code signed short)"
74gdb_test "whatis (@code unsigned short) v_unsigned_short" \
75 "type = @code (unsigned short|short unsigned int)" \
76 "(@code unsigned short)"
77gdb_test "whatis (@code int) v_int" \
78 "type = @code int" \
79 "(@code int)"
80gdb_test "whatis (@code signed int) v_signed_int" \
81 "type = @code (signed int|int)" \
82 "(@code signed int)"
83gdb_test "whatis (@code unsigned int) v_unsigned_int" \
84 "type = @code unsigned int" \
85 "(@code unsigned int)"
86gdb_test "whatis (@code long) v_long" \
87 "type = @code (long|long int)" \
88 "(@code long)"
89gdb_test "whatis (@code signed long) v_signed_long" \
90 "type = @code (signed |)long( int|)" \
91 "(@code signed long)"
92gdb_test "whatis (@code unsigned long) v_unsigned_long" \
93 "type = @code (unsigned long|long unsigned int)" \
94 "(@code unsigned long)"
95gdb_test "whatis (@code long long) v_long_long" \
96 "type = @code long long( int|)" \
97 "(@code long long)"
98gdb_test "whatis (@code signed long long) v_signed_long_long" \
99 "type = @code (signed |)long long( int|)" \
100 "(@code signed long long)"
101gdb_test "whatis (@code unsigned long long) v_unsigned_long_long" \
102 "type = @code (unsigned long long|long long unsigned int)" \
103 "(@code unsigned long long)"
104gdb_test "whatis (@code float) v_float" \
105 "type = @code float" \
106 "(@code float)"
107gdb_test "whatis (@code double) v_double" \
108 "type = @code double" \
109 "(@code double)"
110
111#
112# Test casting a scalar to @data
113#
114
115gdb_test "whatis (@data char) v_char" \
116 "type = @data char" \
117 "(@data char)"
118gdb_test "whatis (@data signed char) v_signed_char" \
119 "type = @data signed char" \
120 "(@data signed char)"
121gdb_test "whatis (@data unsigned char) v_unsigned_char" \
122 "type = @data (unsigned char|char)" \
123 "(@data unsigned char)"
124gdb_test "whatis (@data short) v_short" \
125 "type = @data (short|short int)" \
126 "(@data short)"
127gdb_test "whatis (@data signed short) v_signed_short" \
128 "type = @data (short|short int|signed short|signed short int)" \
129 "(@data signed short)"
130gdb_test "whatis (@data unsigned short) v_unsigned_short" \
131 "type = @data (unsigned short|short unsigned int)" \
132 "(@data unsigned short)"
133gdb_test "whatis (@data int) v_int" \
134 "type = @data int" \
135 "(@data int)"
136gdb_test "whatis (@data signed int) v_signed_int" \
137 "type = @data (signed int|int)" \
138 "(@data signed int)"
139gdb_test "whatis (@data unsigned int) v_unsigned_int" \
140 "type = @data unsigned int" \
141 "(@data unsigned int)"
142gdb_test "whatis (@data long) v_long" \
143 "type = @data (long|long int)" \
144 "(@data long)"
145gdb_test "whatis (@data signed long) v_signed_long" \
146 "type = @data (signed |)long( int|)" \
147 "(@data signed long)"
148gdb_test "whatis (@data unsigned long) v_unsigned_long" \
149 "type = @data (unsigned long|long unsigned int)" \
150 "(@data unsigned long)"
151gdb_test "whatis (@data long long) v_long_long" \
152 "type = @data long long( int|)" \
153 "(@data long long)"
154gdb_test "whatis (@data signed long long) v_signed_long_long" \
155 "type = @data (signed |)long long( int|)" \
156 "(@data signed long long)"
157gdb_test "whatis (@data unsigned long long) v_unsigned_long_long" \
158 "type = @data (unsigned long long|long long unsigned int)" \
159 "(@data unsigned long long)"
160gdb_test "whatis (@data float) v_float" \
161 "type = @data float" \
162 "(@data float)"
163gdb_test "whatis (@data double) v_double" \
164 "type = @data double" \
165 "(@data double)"
166
167#
168# Now put the '@code' and '@data' keywords after the base type.
169#
170
171gdb_test "whatis (char @code) v_char" \
172 "type = @code char" \
173 "(char @code)"
174gdb_test "whatis (signed char @code) v_signed_char" \
175 "type = @code signed char" \
176 "(signed char @code)"
177gdb_test "whatis (unsigned char @code) v_unsigned_char" \
178 "type = @code (unsigned char|char)" \
179 "(unsigned char @code)"
180gdb_test "whatis (short @code) v_short" \
181 "type = @code (short|short int)" \
182 "(short @code)"
183gdb_test "whatis (signed short @code) v_signed_short" \
184 "type = @code (short|short int|signed short|signed short int)" \
185 "(signed short @code)"
186gdb_test "whatis (unsigned short @code) v_unsigned_short" \
187 "type = @code (unsigned short|short unsigned int)" \
188 "(unsigned short @code)"
189gdb_test "whatis (int @code) v_int" \
190 "type = @code int" \
191 "(int @code)"
192gdb_test "whatis (signed int @code) v_signed_int" \
193 "type = @code (signed int|int)" \
194 "(signed int @code)"
195gdb_test "whatis (unsigned int @code) v_unsigned_int" \
196 "type = @code unsigned int" \
197 "(unsigned int @code)"
198gdb_test "whatis (long @code) v_long" \
199 "type = @code (long|long int)" \
200 "(long @code)"
201gdb_test "whatis (signed long @code) v_signed_long" \
202 "type = @code (signed |)long( int|)" \
203 "(signed long @code)"
204gdb_test "whatis (unsigned long @code) v_unsigned_long" \
205 "type = @code (unsigned long|long unsigned int)" \
206 "(unsigned long @code)"
207gdb_test "whatis (long long @code) v_long_long" \
208 "type = @code long long( int|)" \
209 "(long long @code)"
210gdb_test "whatis (signed long long @code) v_signed_long_long" \
211 "type = @code (signed |)long long( int|)" \
212 "(signed long long @code)"
213gdb_test "whatis (unsigned long long @code) v_unsigned_long_long" \
214 "type = @code (unsigned long long|long long unsigned int)" \
215 "(unsigned long long @code)"
216gdb_test "whatis (float @code) v_float" \
217 "type = @code float" \
218 "(float @code)"
219gdb_test "whatis (double @code) v_double" \
220 "type = @code double" \
221 "(double @code)"
222
223gdb_test "whatis (char @data) v_char" \
224 "type = @data char" \
225 "(char @data)"
226gdb_test "whatis (signed char @data) v_signed_char" \
227 "type = @data signed char" \
228 "(signed char @data)"
229gdb_test "whatis (unsigned char @data) v_unsigned_char" \
230 "type = @data (unsigned char|char)" \
231 "(unsigned char @data)"
232gdb_test "whatis (short @data) v_short" \
233 "type = @data (short|short int)" \
234 "(short @data)"
235gdb_test "whatis (signed short @data) v_signed_short" \
236 "type = @data (short|short int|signed short|signed short int)" \
237 "(signed short @data)"
238gdb_test "whatis (unsigned short @data) v_unsigned_short" \
239 "type = @data (unsigned short|short unsigned int)" \
240 "(unsigned short @data)"
241gdb_test "whatis (int @data) v_int" \
242 "type = @data int" \
243 "(int @data)"
244gdb_test "whatis (signed int @data) v_signed_int" \
245 "type = @data (signed int|int)" \
246 "(signed int @data)"
247gdb_test "whatis (unsigned int @data) v_unsigned_int" \
248 "type = @data unsigned int" \
249 "(unsigned int @data)"
250gdb_test "whatis (long @data) v_long" \
251 "type = @data (long|long int)" \
252 "(long @data)"
253gdb_test "whatis (signed long @data) v_signed_long" \
254 "type = @data (signed |)long( int|)" \
255 "(signed long @data)"
256gdb_test "whatis (unsigned long @data) v_unsigned_long" \
257 "type = @data (unsigned long|long unsigned int)" \
258 "(unsigned long @data)"
259gdb_test "whatis (long long @data) v_long_long" \
260 "type = @data long long( int|)" \
261 "(long long @data)"
262gdb_test "whatis (signed long long @data) v_signed_long_long" \
263 "type = @data (signed |)long long( int|)" \
264 "(signed long long @data)"
265gdb_test "whatis (unsigned long long @data) v_unsigned_long_long" \
266 "type = @data (unsigned long long|long long unsigned int)" \
267 "(unsigned long long @data)"
268gdb_test "whatis (float @data) v_float" \
269 "type = @data float" \
270 "(float @data)"
271gdb_test "whatis (double @data) v_double" \
272 "type = @data double" \
273 "(double @data)"
274
275#
276# enums
277#
278
279gdb_test "whatis (@code enum misordered) v_misordered" \
280 "type = @code enum misordered" \
281 "(@code enum misordered)"
282gdb_test "whatis (enum misordered @code) v_misordered" \
283 "type = @code enum misordered" \
284 "(enum misordered @code)"
285gdb_test "whatis (@data enum misordered) v_misordered" \
286 "type = @data enum misordered" \
287 "(@data enum misordered)"
288gdb_test "whatis (enum misordered @data) v_misordered" \
289 "type = @data enum misordered" \
290 "(enum misordered @data)"
291
292#
293# Pointers
294#
295
296gdb_test "whatis (@code int *) v_int_pointer" \
297 "type = @code int${ws}\\*" \
298 "(@code int *)"
299gdb_test "whatis (int @code *) v_int_pointer" \
300 "type = @code int${ws}\\*" \
301 "(int @code *)"
302gdb_test "whatis (int * @code) v_int_pointer" \
303 "type = int \\*${ws}@code" \
304 "(int * @code)"
305gdb_test "whatis (@code int * @code) v_int_pointer" \
306 "type = @code int${ws}\\*${ws}@code" \
307 "(@code int * @code)"
308gdb_test "whatis (int @code * @code) v_int_pointer" \
309 "type = @code int${ws}\\*${ws}@code" \
310 "(int @code * @code)"
311
312gdb_test "whatis (@code int **) v_int_pointer_pointer" \
313 "type = @code int${ws}\\*${ws}\\*" \
314 "(@code int **)"
315gdb_test "whatis (int @code **) v_int_pointer_pointer" \
316 "type = @code int${ws}\\*${ws}\\*" \
317 "(int @code **)"
318gdb_test "whatis (int ** @code) v_int_pointer_pointer" \
319 "type = int \\*${ws}\\*${ws}@code" \
320 "(int ** @code)"
321gdb_test "whatis (@code int * @code *) v_int_pointer_pointer" \
322 "type = @code int${ws}\\*${ws}@code${ws}\\*" \
323 "(@code int * @code *)"
324gdb_test "whatis (int @code * @code *) v_int_pointer_pointer" \
325 "type = @code int${ws}\\*${ws}@code${ws}\\*" \
326 "(int @code * @code *)"
327gdb_test "whatis (@code int * @code * @code) v_int_pointer_pointer" \
328 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \
329 "(@code int * @code * @code)"
330gdb_test "whatis (int @code * @code * @code) v_int_pointer_pointer" \
331 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \
332 "(int @code * @code * @code)"
333
334#
335# Arrays TODO
336#
337
338#
339# Pointers to arrays, arrays of pointers TODO
340#
341
342#
343# Structs and Unions
344#
345
346gdb_test "whatis (@code struct t_struct) v_struct1" \
347 "type = @code struct t_struct" \
348 "(@code struct t_struct)"
349gdb_test "whatis (@code union t_union) v_union" \
350 "type = @code union t_union" \
351 "(@code union t_union)"
352gdb_test "whatis (struct t_struct @code) v_struct1" \
353 "type = @code struct t_struct" \
354 "(struct t_struct @code)"
355gdb_test "whatis (union t_union @code) v_union" \
356 "type = @code union t_union" \
357 "(union t_union @code)"
358gdb_test "whatis (@code struct t_struct *) &v_struct1" \
359 "type = @code struct t_struct${ws}\\*" \
360 "(@code struct t_struct *)"
361gdb_test "whatis (@code union t_union *) &v_union" \
362 "type = @code union t_union${ws}\\*" \
363 "(@code union t_union *)"
364gdb_test "whatis (struct t_struct @code *) &v_struct1" \
365 "type = @code struct t_struct${ws}\\*" \
366 "(struct t_struct @code *)"
367gdb_test "whatis (union t_union @code *) &v_union" \
368 "type = @code union t_union${ws}\\*" \
369 "(union t_union @code *)"
370gdb_test "whatis (struct t_struct * @code) &v_struct1" \
371 "type = struct t_struct${ws}\\*${ws}@code" \
372 "(struct t_struct * @code)"
373gdb_test "whatis (union t_union * @code) &v_union" \
374 "type = union t_union${ws}\\*${ws}@code" \
375 "(union t_union * @code)"
376gdb_test "whatis (@code struct t_struct * @code) &v_struct1" \
377 "type = @code struct t_struct${ws}\\*${ws}@code" \
378 "(@code struct t_struct * @code)"
379gdb_test "whatis (@code union t_union * @code) &v_union" \
380 "type = @code union t_union${ws}\\*${ws}@code" \
381 "(@code union t_union * @code)"
382gdb_test "whatis (struct t_struct @code * @code) &v_struct1" \
383 "type = @code struct t_struct${ws}\\*${ws}@code" \
384 "(struct t_struct @code * @code)"
385gdb_test "whatis (union t_union @code * @code) &v_union" \
386 "type = @code union t_union${ws}\\*${ws}@code" \
387 "(union t_union @code * @code)"
388
389#
390# Function pointers TODO
391#
392
This page took 0.711734 seconds and 4 git commands to generate.