Commit | Line | Data |
---|---|---|
0b302171 | 1 | # Copyright (C) 2001, 2007-2012 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 | |
25 | set testfile "cvexpr" | |
26 | set srcfile ${testfile}.c | |
27 | set binfile ${objdir}/${subdir}/${testfile} | |
28 | ||
29 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
b60f0898 JB |
30 | untested code-expr.exp |
31 | return -1 | |
bb632afb MS |
32 | } |
33 | ||
34 | gdb_exit | |
35 | gdb_start | |
36 | gdb_reinitialize_dir $srcdir/$subdir | |
37 | gdb_load ${binfile} | |
38 | ||
27d3a1a2 MS |
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" | |
bb632afb MS |
42 | |
43 | set ws "\[ \t\]*" | |
44 | ||
45 | # | |
46 | # Test casting a scalar to const | |
47 | # | |
48 | ||
49 | gdb_test "whatis (@code char) v_char" \ | |
50 | "type = @code char" \ | |
51 | "(@code char)" | |
52 | gdb_test "whatis (@code signed char) v_signed_char" \ | |
53 | "type = @code signed char" \ | |
54 | "(@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)" \ | |
60 | "(@code short)" | |
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" \ | |
68 | "type = @code int" \ | |
69 | "(@code int)" | |
70 | gdb_test "whatis (@code signed int) v_signed_int" \ | |
71 | "type = @code (signed int|int)" \ | |
72 | "(@code signed 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)" \ | |
78 | "(@code long)" | |
79 | gdb_test "whatis (@code signed long) v_signed_long" \ | |
80 | "type = @code (signed |)long( int|)" \ | |
81 | "(@code signed long)" | |
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|)" \ | |
87 | "(@code long long)" | |
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" \ | |
96 | "(@code float)" | |
97 | gdb_test "whatis (@code double) v_double" \ | |
98 | "type = @code double" \ | |
99 | "(@code double)" | |
100 | ||
101 | # | |
102 | # Test casting a scalar to @data | |
103 | # | |
104 | ||
105 | gdb_test "whatis (@data char) v_char" \ | |
106 | "type = @data char" \ | |
107 | "(@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)" \ | |
116 | "(@data short)" | |
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" \ | |
124 | "type = @data int" \ | |
125 | "(@data int)" | |
126 | gdb_test "whatis (@data signed int) v_signed_int" \ | |
127 | "type = @data (signed int|int)" \ | |
128 | "(@data signed 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)" \ | |
134 | "(@data long)" | |
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|)" \ | |
143 | "(@data long long)" | |
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" \ | |
152 | "(@data float)" | |
153 | gdb_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 | ||
161 | gdb_test "whatis (char @code) v_char" \ | |
162 | "type = @code char" \ | |
163 | "(char @code)" | |
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)" \ | |
172 | "(short @code)" | |
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" \ | |
180 | "type = @code int" \ | |
181 | "(int @code)" | |
182 | gdb_test "whatis (signed int @code) v_signed_int" \ | |
183 | "type = @code (signed int|int)" \ | |
184 | "(signed int @code)" | |
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)" \ | |
190 | "(long @code)" | |
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|)" \ | |
199 | "(long long @code)" | |
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" \ | |
208 | "(float @code)" | |
209 | gdb_test "whatis (double @code) v_double" \ | |
210 | "type = @code double" \ | |
211 | "(double @code)" | |
212 | ||
213 | gdb_test "whatis (char @data) v_char" \ | |
214 | "type = @data char" \ | |
215 | "(char @data)" | |
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)" \ | |
224 | "(short @data)" | |
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" \ | |
232 | "type = @data int" \ | |
233 | "(int @data)" | |
234 | gdb_test "whatis (signed int @data) v_signed_int" \ | |
235 | "type = @data (signed int|int)" \ | |
236 | "(signed int @data)" | |
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)" \ | |
242 | "(long @data)" | |
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|)" \ | |
251 | "(long long @data)" | |
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" \ | |
260 | "(float @data)" | |
261 | gdb_test "whatis (double @data) v_double" \ | |
262 | "type = @data double" \ | |
263 | "(double @data)" | |
264 | ||
265 | # | |
266 | # enums | |
267 | # | |
268 | ||
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)" | |
281 | ||
282 | # | |
283 | # Pointers | |
284 | # | |
285 | ||
286 | gdb_test "whatis (@code int *) v_int_pointer" \ | |
287 | "type = @code int${ws}\\*" \ | |
288 | "(@code int *)" | |
289 | gdb_test "whatis (int @code *) v_int_pointer" \ | |
290 | "type = @code int${ws}\\*" \ | |
291 | "(int @code *)" | |
292 | gdb_test "whatis (int * @code) v_int_pointer" \ | |
293 | "type = int \\*${ws}@code" \ | |
294 | "(int * @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)" | |
301 | ||
302 | gdb_test "whatis (@code int **) v_int_pointer_pointer" \ | |
303 | "type = @code int${ws}\\*${ws}\\*" \ | |
304 | "(@code int **)" | |
305 | gdb_test "whatis (int @code **) v_int_pointer_pointer" \ | |
306 | "type = @code int${ws}\\*${ws}\\*" \ | |
307 | "(int @code **)" | |
308 | gdb_test "whatis (int ** @code) v_int_pointer_pointer" \ | |
309 | "type = int \\*${ws}\\*${ws}@code" \ | |
310 | "(int ** @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)" | |
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 | ||
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)" | |
378 | ||
379 | # | |
380 | # Function pointers TODO | |
381 | # | |
382 |