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