1 # Copyright (C) 2001, 2007-2012 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Written by Michael Snyder, Red Hat, Inc., 9/20/2001
18 # This file is part of the gdb testsuite
19 # Tests for type expressions using the new "@code" and "@data" modifiers.
22 # test running programs
26 set srcfile ${testfile}.c
27 set binfile ${objdir}/${subdir}/${testfile}
29 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
30 untested code-expr.exp
36 gdb_reinitialize_dir $srcdir/$subdir
39 gdb_test_no_output "set print sevenbit-strings"
40 gdb_test_no_output "set print address off"
41 gdb_test_no_output "set width 0"
46 # Test casting a scalar to const
49 gdb_test "whatis (@code char) v_char" \
52 gdb_test "whatis (@code signed char) v_signed_char" \
53 "type = @code signed char" \
55 gdb_test "whatis (@code unsigned char) v_unsigned_char" \
56 "type = @code (unsigned char|char)" \
57 "(@code unsigned char)"
58 gdb_test "whatis (@code short) v_short" \
59 "type = @code (short|short int)" \
61 gdb_test "whatis (@code signed short) v_signed_short" \
62 "type = @code (short|short int|signed short|signed short int)" \
63 "(@code signed short)"
64 gdb_test "whatis (@code unsigned short) v_unsigned_short" \
65 "type = @code (unsigned short|short unsigned int)" \
66 "(@code unsigned short)"
67 gdb_test "whatis (@code int) v_int" \
70 gdb_test "whatis (@code signed int) v_signed_int" \
71 "type = @code (signed int|int)" \
73 gdb_test "whatis (@code unsigned int) v_unsigned_int" \
74 "type = @code unsigned int" \
75 "(@code unsigned int)"
76 gdb_test "whatis (@code long) v_long" \
77 "type = @code (long|long int)" \
79 gdb_test "whatis (@code signed long) v_signed_long" \
80 "type = @code (signed |)long( int|)" \
82 gdb_test "whatis (@code unsigned long) v_unsigned_long" \
83 "type = @code (unsigned long|long unsigned int)" \
84 "(@code unsigned long)"
85 gdb_test "whatis (@code long long) v_long_long" \
86 "type = @code long long( int|)" \
88 gdb_test "whatis (@code signed long long) v_signed_long_long" \
89 "type = @code (signed |)long long( int|)" \
90 "(@code signed long long)"
91 gdb_test "whatis (@code unsigned long long) v_unsigned_long_long" \
92 "type = @code (unsigned long long|long long unsigned int)" \
93 "(@code unsigned long long)"
94 gdb_test "whatis (@code float) v_float" \
95 "type = @code float" \
97 gdb_test "whatis (@code double) v_double" \
98 "type = @code double" \
102 # Test casting a scalar to @data
105 gdb_test "whatis (@data char) v_char" \
106 "type = @data char" \
108 gdb_test "whatis (@data signed char) v_signed_char" \
109 "type = @data signed char" \
110 "(@data signed char)"
111 gdb_test "whatis (@data unsigned char) v_unsigned_char" \
112 "type = @data (unsigned char|char)" \
113 "(@data unsigned char)"
114 gdb_test "whatis (@data short) v_short" \
115 "type = @data (short|short int)" \
117 gdb_test "whatis (@data signed short) v_signed_short" \
118 "type = @data (short|short int|signed short|signed short int)" \
119 "(@data signed short)"
120 gdb_test "whatis (@data unsigned short) v_unsigned_short" \
121 "type = @data (unsigned short|short unsigned int)" \
122 "(@data unsigned short)"
123 gdb_test "whatis (@data int) v_int" \
126 gdb_test "whatis (@data signed int) v_signed_int" \
127 "type = @data (signed int|int)" \
129 gdb_test "whatis (@data unsigned int) v_unsigned_int" \
130 "type = @data unsigned int" \
131 "(@data unsigned int)"
132 gdb_test "whatis (@data long) v_long" \
133 "type = @data (long|long int)" \
135 gdb_test "whatis (@data signed long) v_signed_long" \
136 "type = @data (signed |)long( int|)" \
137 "(@data signed long)"
138 gdb_test "whatis (@data unsigned long) v_unsigned_long" \
139 "type = @data (unsigned long|long unsigned int)" \
140 "(@data unsigned long)"
141 gdb_test "whatis (@data long long) v_long_long" \
142 "type = @data long long( int|)" \
144 gdb_test "whatis (@data signed long long) v_signed_long_long" \
145 "type = @data (signed |)long long( int|)" \
146 "(@data signed long long)"
147 gdb_test "whatis (@data unsigned long long) v_unsigned_long_long" \
148 "type = @data (unsigned long long|long long unsigned int)" \
149 "(@data unsigned long long)"
150 gdb_test "whatis (@data float) v_float" \
151 "type = @data float" \
153 gdb_test "whatis (@data double) v_double" \
154 "type = @data double" \
158 # Now put the '@code' and '@data' keywords after the base type.
161 gdb_test "whatis (char @code) v_char" \
162 "type = @code char" \
164 gdb_test "whatis (signed char @code) v_signed_char" \
165 "type = @code signed char" \
166 "(signed char @code)"
167 gdb_test "whatis (unsigned char @code) v_unsigned_char" \
168 "type = @code (unsigned char|char)" \
169 "(unsigned char @code)"
170 gdb_test "whatis (short @code) v_short" \
171 "type = @code (short|short int)" \
173 gdb_test "whatis (signed short @code) v_signed_short" \
174 "type = @code (short|short int|signed short|signed short int)" \
175 "(signed short @code)"
176 gdb_test "whatis (unsigned short @code) v_unsigned_short" \
177 "type = @code (unsigned short|short unsigned int)" \
178 "(unsigned short @code)"
179 gdb_test "whatis (int @code) v_int" \
182 gdb_test "whatis (signed int @code) v_signed_int" \
183 "type = @code (signed int|int)" \
185 gdb_test "whatis (unsigned int @code) v_unsigned_int" \
186 "type = @code unsigned int" \
187 "(unsigned int @code)"
188 gdb_test "whatis (long @code) v_long" \
189 "type = @code (long|long int)" \
191 gdb_test "whatis (signed long @code) v_signed_long" \
192 "type = @code (signed |)long( int|)" \
193 "(signed long @code)"
194 gdb_test "whatis (unsigned long @code) v_unsigned_long" \
195 "type = @code (unsigned long|long unsigned int)" \
196 "(unsigned long @code)"
197 gdb_test "whatis (long long @code) v_long_long" \
198 "type = @code long long( int|)" \
200 gdb_test "whatis (signed long long @code) v_signed_long_long" \
201 "type = @code (signed |)long long( int|)" \
202 "(signed long long @code)"
203 gdb_test "whatis (unsigned long long @code) v_unsigned_long_long" \
204 "type = @code (unsigned long long|long long unsigned int)" \
205 "(unsigned long long @code)"
206 gdb_test "whatis (float @code) v_float" \
207 "type = @code float" \
209 gdb_test "whatis (double @code) v_double" \
210 "type = @code double" \
213 gdb_test "whatis (char @data) v_char" \
214 "type = @data char" \
216 gdb_test "whatis (signed char @data) v_signed_char" \
217 "type = @data signed char" \
218 "(signed char @data)"
219 gdb_test "whatis (unsigned char @data) v_unsigned_char" \
220 "type = @data (unsigned char|char)" \
221 "(unsigned char @data)"
222 gdb_test "whatis (short @data) v_short" \
223 "type = @data (short|short int)" \
225 gdb_test "whatis (signed short @data) v_signed_short" \
226 "type = @data (short|short int|signed short|signed short int)" \
227 "(signed short @data)"
228 gdb_test "whatis (unsigned short @data) v_unsigned_short" \
229 "type = @data (unsigned short|short unsigned int)" \
230 "(unsigned short @data)"
231 gdb_test "whatis (int @data) v_int" \
234 gdb_test "whatis (signed int @data) v_signed_int" \
235 "type = @data (signed int|int)" \
237 gdb_test "whatis (unsigned int @data) v_unsigned_int" \
238 "type = @data unsigned int" \
239 "(unsigned int @data)"
240 gdb_test "whatis (long @data) v_long" \
241 "type = @data (long|long int)" \
243 gdb_test "whatis (signed long @data) v_signed_long" \
244 "type = @data (signed |)long( int|)" \
245 "(signed long @data)"
246 gdb_test "whatis (unsigned long @data) v_unsigned_long" \
247 "type = @data (unsigned long|long unsigned int)" \
248 "(unsigned long @data)"
249 gdb_test "whatis (long long @data) v_long_long" \
250 "type = @data long long( int|)" \
252 gdb_test "whatis (signed long long @data) v_signed_long_long" \
253 "type = @data (signed |)long long( int|)" \
254 "(signed long long @data)"
255 gdb_test "whatis (unsigned long long @data) v_unsigned_long_long" \
256 "type = @data (unsigned long long|long long unsigned int)" \
257 "(unsigned long long @data)"
258 gdb_test "whatis (float @data) v_float" \
259 "type = @data float" \
261 gdb_test "whatis (double @data) v_double" \
262 "type = @data double" \
269 gdb_test "whatis (@code enum misordered) v_misordered" \
270 "type = @code enum misordered" \
271 "(@code enum misordered)"
272 gdb_test "whatis (enum misordered @code) v_misordered" \
273 "type = @code enum misordered" \
274 "(enum misordered @code)"
275 gdb_test "whatis (@data enum misordered) v_misordered" \
276 "type = @data enum misordered" \
277 "(@data enum misordered)"
278 gdb_test "whatis (enum misordered @data) v_misordered" \
279 "type = @data enum misordered" \
280 "(enum misordered @data)"
286 gdb_test "whatis (@code int *) v_int_pointer" \
287 "type = @code int${ws}\\*" \
289 gdb_test "whatis (int @code *) v_int_pointer" \
290 "type = @code int${ws}\\*" \
292 gdb_test "whatis (int * @code) v_int_pointer" \
293 "type = int \\*${ws}@code" \
295 gdb_test "whatis (@code int * @code) v_int_pointer" \
296 "type = @code int${ws}\\*${ws}@code" \
297 "(@code int * @code)"
298 gdb_test "whatis (int @code * @code) v_int_pointer" \
299 "type = @code int${ws}\\*${ws}@code" \
300 "(int @code * @code)"
302 gdb_test "whatis (@code int **) v_int_pointer_pointer" \
303 "type = @code int${ws}\\*${ws}\\*" \
305 gdb_test "whatis (int @code **) v_int_pointer_pointer" \
306 "type = @code int${ws}\\*${ws}\\*" \
308 gdb_test "whatis (int ** @code) v_int_pointer_pointer" \
309 "type = int \\*${ws}\\*${ws}@code" \
311 gdb_test "whatis (@code int * @code *) v_int_pointer_pointer" \
312 "type = @code int${ws}\\*${ws}@code${ws}\\*" \
313 "(@code int * @code *)"
314 gdb_test "whatis (int @code * @code *) v_int_pointer_pointer" \
315 "type = @code int${ws}\\*${ws}@code${ws}\\*" \
316 "(int @code * @code *)"
317 gdb_test "whatis (@code int * @code * @code) v_int_pointer_pointer" \
318 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \
319 "(@code int * @code * @code)"
320 gdb_test "whatis (int @code * @code * @code) v_int_pointer_pointer" \
321 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \
322 "(int @code * @code * @code)"
329 # Pointers to arrays, arrays of pointers TODO
336 gdb_test "whatis (@code struct t_struct) v_struct1" \
337 "type = @code struct t_struct" \
338 "(@code struct t_struct)"
339 gdb_test "whatis (@code union t_union) v_union" \
340 "type = @code union t_union" \
341 "(@code union t_union)"
342 gdb_test "whatis (struct t_struct @code) v_struct1" \
343 "type = @code struct t_struct" \
344 "(struct t_struct @code)"
345 gdb_test "whatis (union t_union @code) v_union" \
346 "type = @code union t_union" \
347 "(union t_union @code)"
348 gdb_test "whatis (@code struct t_struct *) &v_struct1" \
349 "type = @code struct t_struct${ws}\\*" \
350 "(@code struct t_struct *)"
351 gdb_test "whatis (@code union t_union *) &v_union" \
352 "type = @code union t_union${ws}\\*" \
353 "(@code union t_union *)"
354 gdb_test "whatis (struct t_struct @code *) &v_struct1" \
355 "type = @code struct t_struct${ws}\\*" \
356 "(struct t_struct @code *)"
357 gdb_test "whatis (union t_union @code *) &v_union" \
358 "type = @code union t_union${ws}\\*" \
359 "(union t_union @code *)"
360 gdb_test "whatis (struct t_struct * @code) &v_struct1" \
361 "type = struct t_struct${ws}\\*${ws}@code" \
362 "(struct t_struct * @code)"
363 gdb_test "whatis (union t_union * @code) &v_union" \
364 "type = union t_union${ws}\\*${ws}@code" \
365 "(union t_union * @code)"
366 gdb_test "whatis (@code struct t_struct * @code) &v_struct1" \
367 "type = @code struct t_struct${ws}\\*${ws}@code" \
368 "(@code struct t_struct * @code)"
369 gdb_test "whatis (@code union t_union * @code) &v_union" \
370 "type = @code union t_union${ws}\\*${ws}@code" \
371 "(@code union t_union * @code)"
372 gdb_test "whatis (struct t_struct @code * @code) &v_struct1" \
373 "type = @code struct t_struct${ws}\\*${ws}@code" \
374 "(struct t_struct @code * @code)"
375 gdb_test "whatis (union t_union @code * @code) &v_union" \
376 "type = @code union t_union${ws}\\*${ws}@code" \
377 "(union t_union @code * @code)"
380 # Function pointers TODO