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