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