Commit | Line | Data |
---|---|---|
a0644324 MC |
1 | # Copyright 1998, 1999, 2003, 2004 Free Software Foundation, Inc. |
2 | ||
3 | # This file is part of the gdb testsuite | |
c906108c SS |
4 | |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 2 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program; if not, write to the Free Software | |
17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | ||
c906108c SS |
19 | # Tests for pointer-to-member support |
20 | # Written by Satish Pai <pai@apollo.hp.com> 1997-08-19 | |
a0644324 | 21 | # Rewritten by Michael Chastain <mec.gnu@mindspring.com> 2004-01-11 |
c906108c | 22 | |
a0644324 | 23 | # TODO: copyright notice for member-ptr.cc |
c906108c | 24 | |
a0644324 | 25 | set vhn "\\$\[0-9\]+" |
c906108c SS |
26 | |
27 | if $tracelevel then { | |
a0644324 MC |
28 | strace $tracelevel |
29 | } | |
c906108c | 30 | |
d4f3574e SS |
31 | if { [skip_cplus_tests] } { continue } |
32 | ||
c906108c SS |
33 | set prms_id 0 |
34 | set bug_id 0 | |
35 | ||
36 | set testfile "member-ptr" | |
37 | set srcfile ${testfile}.cc | |
38 | set binfile ${objdir}/${subdir}/${testfile} | |
39 | ||
085dd6e6 JM |
40 | if [get_compiler_info ${binfile} "c++"] { |
41 | return -1 | |
42 | } | |
43 | ||
c906108c SS |
44 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { |
45 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
46 | } | |
47 | ||
c906108c SS |
48 | gdb_exit |
49 | gdb_start | |
50 | gdb_reinitialize_dir $srcdir/$subdir | |
51 | gdb_load ${binfile} | |
52 | ||
c906108c SS |
53 | if ![runto_main] then { |
54 | perror "couldn't run to breakpoint" | |
55 | continue | |
56 | } | |
57 | ||
a0644324 MC |
58 | gdb_breakpoint [gdb_get_line_number "pmi = NULL"] |
59 | gdb_continue_to_breakpoint "continue to pmi = NULL" | |
c906108c | 60 | |
a0644324 MC |
61 | # gcc is not ready for production |
62 | # -- chastain 2004-01-12 | |
63 | ||
64 | if { [test_compiler_info "gcc-*"] } { | |
65 | continue | |
c906108c SS |
66 | } |
67 | ||
a0644324 MC |
68 | # ====================== |
69 | # pointer to member data | |
70 | # ====================== | |
71 | ||
c906108c SS |
72 | # ptype on pointer to data member |
73 | ||
a0644324 MC |
74 | set name "ptype pmi (A::j)" |
75 | gdb_test_multiple "ptype pmi" $name { | |
76 | -re "type = int *\\( ?A::\\*\\)\r\n$gdb_prompt $" { | |
77 | pass $name | |
78 | } | |
79 | -re "type = int *A::\r\n$gdb_prompt $" { | |
80 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
81 | # gcc HEAD 2004-01-10 -gstabs+ | |
82 | kfail "gdb/NNNN" $name | |
c906108c | 83 | } |
c906108c SS |
84 | } |
85 | ||
86 | # print pointer to data member | |
87 | ||
a0644324 MC |
88 | set name "print pmi (A::j) " |
89 | gdb_test_multiple "print pmi" $name { | |
90 | -re "$vhn = &A::j\r\n$gdb_prompt $" { | |
91 | pass $name | |
92 | } | |
93 | -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) &A::j\r\n$gdb_prompt $" { | |
94 | pass $name | |
95 | } | |
96 | -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) ?&A::j ?\\+ ?1 bytes\r\n$gdb_prompt $" { | |
97 | # gcc 2.95.3 -gdwarf-2 | |
98 | kfail "gdb/NNNN" $name | |
99 | } | |
100 | -re "$vhn = &A::j ?\\+ ?1 bytes\r\n$gdb_prompt $" { | |
101 | # gcc 2.95.3 -gstabs+ | |
102 | kfail "gdb/NNNN" $name | |
103 | } | |
104 | -re "$vhn = not implemented: member type in c_val_print\r\n$gdb_prompt $" { | |
105 | # gcc HEAD 2004-01-11 05:33:21 -gdwarf-2 | |
106 | # gcc HEAD 2004-01-11 05:33:21 -gstabs+ | |
107 | kfail "gdb/NNNN" $name | |
108 | } | |
109 | -re "$vhn = \\(int ?\\( A::\\*\\)\\) 536870920\r\n$gdb_prompt $" { | |
110 | # the value is 0x20000008 hex. 0x20000000 is an internal flag. | |
111 | # Use '|' to add in more values as needed. | |
112 | # hpacc A.03.45 | |
113 | kfail "gdb/NNNN" $name | |
c906108c | 114 | } |
c906108c SS |
115 | } |
116 | ||
c906108c SS |
117 | # print dereferenced pointer to data member |
118 | ||
a0644324 MC |
119 | set name "print a.*pmi (A::j)" |
120 | gdb_test_multiple "print a.*pmi" $name { | |
121 | -re "$vhn = 121\r\n$gdb_prompt $" { | |
122 | pass $name | |
123 | } | |
124 | -re "$vhn = 855638016\r\n$gdb_prompt $" { | |
125 | # gcc 2.95.3 -gdwarf-2 | |
126 | # gcc 2.95.3 -gstabs+ | |
127 | kfail "gdb/NNNN" $name | |
128 | } | |
129 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
130 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
131 | # gcc HEAD 2004-01-10 -gstabs+ | |
132 | kfail "gdb/NNNN" $name | |
c906108c | 133 | } |
c906108c SS |
134 | } |
135 | ||
136 | # print dereferenced pointer to data member | |
137 | # this time, dereferenced through a pointer | |
138 | ||
a0644324 MC |
139 | set name "print a_p->*pmi (A::j)" |
140 | gdb_test_multiple "print a_p->*pmi" $name { | |
141 | -re "$vhn = 121\r\n$gdb_prompt $" { | |
142 | pass $name | |
143 | } | |
144 | -re "$vhn = 855638016\r\n$gdb_prompt $" { | |
145 | # gcc 2.95.3 -gdwarf-2 | |
146 | # gcc 2.95.3 -gstabs+ | |
147 | kfail "gdb/NNNN" $name | |
148 | } | |
149 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
150 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
151 | # gcc HEAD 2004-01-10 -gstabs+ | |
152 | kfail "gdb/NNNN" $name | |
c906108c | 153 | } |
c906108c SS |
154 | } |
155 | ||
a0644324 | 156 | # set the pointer to a different data member |
c906108c | 157 | |
a0644324 MC |
158 | set name "set var pmi = &A::jj" |
159 | gdb_test_multiple "set var pmi = &A::jj" $name { | |
160 | -re "Invalid cast.\r\n$gdb_prompt $" { | |
161 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
162 | # gcc HEAD 2004-01-10 -gstabs+ | |
163 | kfail "gdb/NNNN" $name | |
164 | } | |
165 | -re "set var pmi = &A::jj\r\n$gdb_prompt $" { | |
166 | # I have to match the echo'ed input explicitly here. | |
167 | # If I leave it out, the pattern becomes too general | |
168 | # and matches anything that ends in "$gdb_prompt $". | |
169 | pass $name | |
c906108c | 170 | } |
c906108c SS |
171 | } |
172 | ||
a0644324 | 173 | # print the pointer again |
c906108c | 174 | |
a0644324 MC |
175 | set name "print pmi (A::jj)" |
176 | gdb_test_multiple "print pmi" $name { | |
177 | -re "$vhn = &A::jj\r\n$gdb_prompt $" { | |
178 | pass $name | |
179 | } | |
180 | -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) &A::jj\r\n$gdb_prompt $" { | |
181 | pass $name | |
182 | } | |
183 | -re "$vhn = not implemented: member type in c_val_print\r\n$gdb_prompt $" { | |
184 | # gcc HEAD 2004-01-11 05:33:21 -gdwarf-2 | |
185 | # gcc HEAD 2004-01-11 05:33:21 -gstabs+ | |
186 | kfail "gdb/NNNN" $name | |
187 | } | |
188 | -re "$vhn = \\(int ?\\( A::\\*\\)\\) 536870924\r\n$gdb_prompt $" { | |
189 | # the value is 0x20000008 hex. 0x20000000 is an internal flag. | |
190 | # Use '|' to add in more values as needed. | |
191 | # hpacc A.03.45 | |
192 | kfail "gdb/NNNN" $name | |
c906108c | 193 | } |
c906108c SS |
194 | } |
195 | ||
196 | # print dereferenced pointer to data member again | |
197 | ||
a0644324 MC |
198 | set name "print a.*pmi (A::jj)" |
199 | gdb_test_multiple "print a.*pmi" $name { | |
200 | -re "$vhn = 1331\r\n$gdb_prompt $" { | |
201 | pass $name | |
202 | } | |
203 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
204 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
205 | # gcc HEAD 2004-01-10 -gstabs+ | |
206 | kfail "gdb/NNNN" $name | |
c906108c | 207 | } |
c906108c SS |
208 | } |
209 | ||
210 | # set the pointer to data member back to A::j | |
211 | ||
a0644324 MC |
212 | set name "set var pmi = &A::j" |
213 | gdb_test_multiple "set var pmi = &A::j" $name { | |
214 | -re "Invalid cast.\r\n$gdb_prompt $" { | |
215 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
216 | # gcc HEAD 2004-01-10 -gstabs+ | |
217 | kfail "gdb/NNNN" $name | |
218 | } | |
219 | -re "set var pmi = &A::j\r\n$gdb_prompt $" { | |
220 | # I have to match the echo'ed input explicitly here. | |
221 | # If I leave it out, the pattern becomes too general | |
222 | # and matches anything that ends in "$gdb_prompt $". | |
223 | pass $name | |
c906108c | 224 | } |
c906108c SS |
225 | } |
226 | ||
227 | # print dereferenced pointer to data member yet again (extra check, why not) | |
228 | ||
a0644324 MC |
229 | set name "print a.*pmi (A::j) (again)" |
230 | gdb_test_multiple "print a.*pmi" $name { | |
231 | -re "$vhn = 121\r\n$gdb_prompt $" { | |
232 | pass $name | |
233 | } | |
234 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
235 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
236 | # gcc HEAD 2004-01-10 -gstabs+ | |
237 | kfail "gdb/NNNN" $name | |
c906108c | 238 | } |
c906108c SS |
239 | } |
240 | ||
241 | # Set the data member pointed to. | |
242 | ||
a0644324 MC |
243 | set name "print a.*pmi = 33" |
244 | gdb_test_multiple "print a.*pmi = 33" $name { | |
245 | -re "$vhn = 33\r\n$gdb_prompt $" { | |
246 | pass $name | |
247 | } | |
248 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
249 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
250 | # gcc HEAD 2004-01-10 -gstabs+ | |
251 | kfail "gdb/NNNN" $name | |
c906108c | 252 | } |
c906108c SS |
253 | } |
254 | ||
255 | # Now check that the data really was changed | |
c906108c | 256 | |
a0644324 MC |
257 | set name "print a.*pmi (A::j) (33)" |
258 | gdb_test_multiple "print a.*pmi" $name { | |
259 | -re "$vhn = 33\r\n$gdb_prompt $" { | |
260 | pass $name | |
261 | } | |
262 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
263 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
264 | # gcc HEAD 2004-01-10 -gstabs+ | |
265 | kfail "gdb/NNNN" $name | |
c906108c | 266 | } |
c906108c SS |
267 | } |
268 | ||
a0644324 | 269 | # Double-check by printing a. |
c906108c | 270 | |
a0644324 MC |
271 | set name "print a (j = 33)" |
272 | gdb_test_multiple "print a" $name { | |
273 | -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex <A virtual table>)\}\r\n$gdb_prompt $" { | |
274 | pass $name | |
c906108c | 275 | } |
a0644324 MC |
276 | -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" { |
277 | pass $name | |
c906108c | 278 | } |
a0644324 MC |
279 | -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" { |
280 | pass $name | |
281 | } | |
282 | -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" { | |
283 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
284 | # gcc HEAD 2004-01-10 -gstabs+ | |
285 | kfail "gdb/NNNN" $name | |
c906108c | 286 | } |
c906108c SS |
287 | } |
288 | ||
a0644324 | 289 | # Set the data member pointed to, using ->* |
c906108c | 290 | |
a0644324 MC |
291 | set name "print a_p->*pmi = 44" |
292 | gdb_test_multiple "print a_p->*pmi = 44" $name { | |
293 | -re "$vhn = 44\r\n$gdb_prompt $" { | |
294 | pass $name | |
295 | } | |
296 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
297 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
298 | # gcc HEAD 2004-01-10 -gstabs+ | |
299 | kfail "gdb/NNNN" $name | |
c906108c | 300 | } |
c906108c SS |
301 | } |
302 | ||
a0644324 | 303 | # Check that the data really was changed |
c906108c | 304 | |
a0644324 MC |
305 | set name "print a_p->*pmi (44)" |
306 | gdb_test_multiple "print a_p->*pmi" $name { | |
307 | -re "$vhn = 44\r\n$gdb_prompt $" { | |
308 | pass $name | |
309 | } | |
310 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
311 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
312 | # gcc HEAD 2004-01-10 -gstabs+ | |
313 | kfail "gdb/NNNN" $name | |
c906108c | 314 | } |
c906108c SS |
315 | } |
316 | ||
a0644324 | 317 | # Double-check by printing a. |
c906108c | 318 | |
a0644324 MC |
319 | set name "print a (j = 44)" |
320 | gdb_test_multiple "print a" $name { | |
321 | -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex <A virtual table>)\}\r\n$gdb_prompt $" { | |
322 | pass $name | |
323 | } | |
324 | -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" { | |
325 | pass $name | |
326 | } | |
327 | -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" { | |
328 | pass $name | |
329 | } | |
330 | -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" { | |
331 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
332 | # gcc HEAD 2004-01-10 -gstabs+ | |
333 | kfail "gdb/NNNN" $name | |
c906108c | 334 | } |
c906108c SS |
335 | } |
336 | ||
a0644324 | 337 | # ptype the dereferenced pointer to member. |
c906108c | 338 | |
a0644324 MC |
339 | set name "ptype a.*pmi" |
340 | gdb_test_multiple "ptype a.*pmi" $name { | |
341 | -re "type = int\r\n$gdb_prompt" { | |
342 | pass $name | |
343 | } | |
344 | -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { | |
345 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
346 | # gcc HEAD 2004-01-10 -gstabs+ | |
347 | kfail "gdb/NNNN" $name | |
c906108c | 348 | } |
c906108c SS |
349 | } |
350 | ||
a0644324 MC |
351 | # dereference the pointer to data member without any object |
352 | # this is not allowed: a pmi must be bound to an object to dereference | |
c906108c | 353 | |
a0644324 MC |
354 | set name "print *pmi" |
355 | gdb_test_multiple "print *pmi" $name { | |
356 | -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { | |
357 | pass $name | |
358 | } | |
359 | -re "Cannot access memory at address 0x4\r\n$gdb_prompt $" { | |
360 | # gcc 2.95.3 -gstabs+ | |
361 | kfail "gdb/NNNN" $name | |
362 | } | |
363 | -re "Cannot access memory at address 0x8\r\n$gdb_prompt $" { | |
364 | # gcc 3.3.2 -gdwarf-2 | |
365 | # gcc 3.3.2 -gstabs+ | |
366 | kfail "gdb/NNNN" $name | |
c906108c | 367 | } |
c906108c SS |
368 | } |
369 | ||
a0644324 MC |
370 | # dereference the pointer to data member without any object |
371 | # this is not allowed: a pmi must be bound to an object to dereference | |
c906108c | 372 | |
a0644324 MC |
373 | set name "ptype *pmi" |
374 | gdb_test_multiple "ptype *pmi" $name { | |
375 | -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { | |
376 | pass $name | |
377 | } | |
378 | -re "type = int A::\r\n$gdb_prompt $" { | |
379 | # gcc 2.95.3 -gstabs+ | |
380 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
381 | # gcc HEAD 2004-01-10 -gstabs+ | |
382 | kfail "gdb/NNNN" $name | |
c906108c | 383 | } |
c906108c SS |
384 | } |
385 | ||
a0644324 MC |
386 | # Check cast of pointer to member to integer. |
387 | # This is similar to "offset-of". | |
388 | # such as "A a; print (size_t) &A.j - (size_t) &A". | |
c906108c | 389 | |
a0644324 MC |
390 | set name "print (int) pmi" |
391 | gdb_test_multiple "print (int) pmi" $name { | |
392 | -re "$vhn = (4|8)\r\n$gdb_prompt" { | |
393 | pass $name | |
c906108c | 394 | } |
c906108c SS |
395 | } |
396 | ||
a0644324 | 397 | # Check "(int) pmi" explicitly for equality. |
c906108c | 398 | |
a0644324 MC |
399 | set name "print ((int) pmi) == ((char *) &a.j - (char *) &a)" |
400 | gdb_test_multiple "print ((int) pmi) == ((char *) &a.j - (char *) & a)" $name { | |
401 | -re "$vhn = true\r\n$gdb_prompt" { | |
402 | pass $name | |
c906108c | 403 | } |
c906108c SS |
404 | } |
405 | ||
a0644324 MC |
406 | # ========================== |
407 | # pointer to member function | |
408 | # ========================== | |
409 | ||
410 | # ptype a pointer to a method | |
c906108c | 411 | |
a0644324 MC |
412 | set name "ptype pmf" |
413 | gdb_test_multiple "ptype pmf" $name { | |
414 | -re "type = int \\( ?A::\\*\\)\\(int\\)\r\n$gdb_prompt $" { | |
415 | pass $name | |
416 | } | |
417 | -re "type = int \\( ?A::\\*\\)\\(void\\)\r\n$gdb_prompt $" { | |
418 | # hpacc A.03.45 | |
419 | kfail "gdb/NNNN" $name | |
420 | } | |
421 | -re "type = struct \{.*\}\r\n$gdb_prompt $" { | |
422 | # gcc 2.95.3 -gdwarf-2 | |
423 | # gcc 2.95.3 -gstabs+ | |
424 | # gcc 3.2.2 -gdwarf-2 | |
425 | # gcc 3.2.2 -gstabs+ | |
426 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
427 | # gcc HEAD 2004-01-10 -gstabs+ | |
428 | kfail "gdb/NNNN" $name | |
c906108c | 429 | } |
c906108c SS |
430 | } |
431 | ||
a0644324 | 432 | # print a pointer to a method |
c906108c | 433 | |
a0644324 MC |
434 | set name "print pmf" |
435 | gdb_test_multiple "print pmf" $name { | |
436 | -re "$vhn = &A::bar\r\n$gdb_prompt $" { | |
437 | pass $name | |
438 | } | |
439 | -re "$vhn = .*not supported with HP aCC.*\r\n$gdb_prompt $" { | |
440 | # hpacc A.03.45 | |
441 | kfail "gdb/NNNN" $name | |
442 | } | |
443 | -re "$vhn = \{.*\}\r\n$gdb_prompt $" { | |
444 | # gcc 2.95.3 -gdwarf-2 | |
445 | # gcc 2.95.3 -gstabs+ | |
446 | # gcc 3.2.2 -gdwarf-2 | |
447 | # gcc 3.2.2 -gstabs+ | |
448 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
449 | # gcc HEAD 2004-01-10 -gstabs+ | |
450 | kfail "gdb/NNNN" $name | |
c906108c | 451 | } |
c906108c SS |
452 | } |
453 | ||
a0644324 | 454 | # ptype a pointer to a pointer to a method |
c906108c | 455 | |
a0644324 MC |
456 | set name "ptype pmf_p" |
457 | gdb_test_multiple "ptype pmf_p" $name { | |
458 | -re "type = int \\( ?A::\\*\\*\\)\\(int\\)\r\n$gdb_prompt $" { | |
459 | pass $name | |
c906108c | 460 | } |
a0644324 MC |
461 | -re "type = int \\( ?A::\\*\\*\\)\\(void\\)\r\n$gdb_prompt $" { |
462 | # hpacc A.03.45 | |
463 | kfail "gdb/NNNN" $name | |
c906108c | 464 | } |
a0644324 MC |
465 | -re "type = struct \{.*\} \\*\r\n$gdb_prompt $" { |
466 | # gcc 2.95.3 -gdwarf-2 | |
467 | # gcc 2.95.3 -gstabs+ | |
468 | # gcc 3.2.2 -gdwarf-2 | |
469 | # gcc 3.2.2 -gstabs+ | |
470 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
471 | # gcc HEAD 2004-01-10 -gstabs+ | |
472 | kfail "gdb/NNNN" $name | |
c906108c | 473 | } |
c906108c SS |
474 | } |
475 | ||
a0644324 | 476 | # print a pointer to a pointer to a method |
c906108c | 477 | |
a0644324 MC |
478 | set name "print pmf_p" |
479 | gdb_test_multiple "print pmf_p" $name { | |
480 | -re "$vhn = \\(int \\( ?A::\\*\\*\\)\\)\\(int\\)\\) $hex\r\n$gdb_prompt $" { | |
481 | pass $name | |
482 | } | |
483 | -re "$vhn = \\(PMF \\*\\) $hex\r\n$gdb_prompt $" { | |
484 | pass "gdb/NNNN" | |
485 | } | |
486 | -re "$vhn = \\(int \\( ?A::\\*\\*\\)\\(void\\)\\) $hex\r\n$gdb_prompt $" { | |
487 | # hpacc A.03.45 | |
488 | kfail "gdb/NNNN" $name | |
489 | } | |
490 | -re "$vhn = \\(struct \{.*\} \\*\\) $hex\r\n$gdb_prompt $" { | |
491 | # gcc 2.95.3 -gdwarf-2 | |
492 | kfail "gdb/NNNN" $name | |
c906108c | 493 | } |
c906108c SS |
494 | } |
495 | ||
a0644324 | 496 | # print dereferenced pointer to method |
c906108c | 497 | |
a0644324 MC |
498 | set name "print a.*pmf" |
499 | gdb_test_multiple "print a.*pmf" $name { | |
500 | -re "$vhn = \\(int \\(\\*\\)\\(int\\)\\) $hex <A::bar\\(int\\)>\r\n$gdb_prompt$ " { | |
501 | pass $name | |
502 | } | |
503 | -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" { | |
504 | # hpacc A.03.45 | |
505 | kfail "gdb/NNNN" $name | |
506 | } | |
507 | -re "Value can't be converted to integer.\r\n$gdb_prompt $" { | |
508 | # gcc 2.95.3 -gdwarf-2 | |
509 | # gcc 2.95.3 -gstabs+ | |
510 | # gcc 3.2.2 -gdwarf-2 | |
511 | # gcc 3.2.2 -gstabs+ | |
512 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
513 | # gcc HEAD 2004-01-10 -gstabs+ | |
514 | kfail "gdb/NNNN" $name | |
c906108c | 515 | } |
c906108c SS |
516 | } |
517 | ||
a0644324 | 518 | # print dereferenced pointer to method, using ->* |
c906108c | 519 | |
a0644324 MC |
520 | set name "print a_p->*pmf" |
521 | gdb_test_multiple "print a_p->*pmf" $name { | |
522 | -re "$vhn = \\(int \\(\\*\\)\\(int\\)\\) $hex <A::bar\\(int\\)>\r\n$gdb_prompt$ " { | |
523 | pass $name | |
524 | } | |
525 | -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" { | |
526 | # hpacc A.03.45 | |
527 | kfail "gdb/NNNN" $name | |
528 | } | |
529 | -re "Value can't be converted to integer.\r\n$gdb_prompt $" { | |
530 | # gcc 2.95.3 -gdwarf-2 | |
531 | # gcc 2.95.3 -gstabs+ | |
532 | # gcc 3.2.2 -gdwarf-2 | |
533 | # gcc 3.2.2 -gstabs+ | |
534 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
535 | # gcc HEAD 2004-01-10 -gstabs+ | |
536 | kfail "gdb/NNNN" $name | |
c906108c | 537 | } |
c906108c SS |
538 | } |
539 | ||
a0644324 | 540 | # set the pointer to data member |
c906108c | 541 | |
a0644324 MC |
542 | set name "set var pmf = &A::foo" |
543 | gdb_test_multiple "set var pmf = &A::foo" $name { | |
544 | -re "set var pmf = &A::foo\r\n$gdb_prompt $" { | |
545 | # I have to match the echo'ed input explicitly here. | |
546 | # If I leave it out, the pattern becomes too general | |
547 | # and matches anything that ends in "$gdb_prompt $". | |
548 | pass $name | |
c906108c | 549 | } |
a0644324 MC |
550 | -re "Invalid cast.\r\n$gdb_prompt $" { |
551 | # gcc 2.95.3 -gdwarf-2 | |
552 | # gcc 2.95.3 -gstabs+ | |
553 | # gcc 3.2.2 -gdwarf-2 | |
554 | # gcc 3.2.2 -gstabs+ | |
555 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
556 | # gcc HEAD 2004-01-10 -gstabs+ | |
557 | kfail "gdb/NNNN" $name | |
558 | } | |
559 | -re "Assignment to pointers to methods not implemented with HP aCC\r\n$gdb_prompt $" { | |
560 | kfail "gdb/NNNN" $name | |
c906108c | 561 | } |
c906108c SS |
562 | } |
563 | ||
a0644324 MC |
564 | # dereference the pointer to data member without any object |
565 | # this is not allowed: a pmf must be bound to an object to dereference | |
c906108c | 566 | |
a0644324 MC |
567 | set name "print *pmf" |
568 | gdb_test_multiple "print *pmf" $name { | |
569 | -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { | |
570 | pass $name | |
571 | } | |
572 | -re "Structure has no component named operator\\*.\r\n$gdb_prompt $" { | |
573 | # gcc 2.95.3 -gdwarf-2 | |
574 | # gcc 2.95.3 -gstabs+ | |
575 | # gcc 3.3.2 -gdwarf-2 | |
576 | # gcc 3.3.2 -gstabs+ | |
577 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
578 | # gcc HEAD 2004-01-10 -gstabs+ | |
579 | kfail "gdb/NNNN" $name | |
c906108c | 580 | } |
c906108c SS |
581 | } |
582 | ||
a0644324 MC |
583 | # dereference the pointer to data member without any object |
584 | # this is not allowed: a pmf must be bound to an object to dereference | |
c906108c | 585 | |
a0644324 MC |
586 | set name "ptype *pmf" |
587 | gdb_test_multiple "ptype *pmf" $name { | |
588 | -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { | |
589 | pass $name | |
590 | } | |
591 | -re "Structure has no component named operator\\*.\r\n$gdb_prompt $" { | |
592 | # gcc 2.95.3 -gdwarf-2 | |
593 | # gcc 2.95.3 -gstabs+ | |
594 | # gcc 3.3.2 -gdwarf-2 | |
595 | # gcc 3.3.2 -gstabs+ | |
596 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
597 | # gcc HEAD 2004-01-10 -gstabs+ | |
598 | kfail "gdb/NNNN" $name | |
c906108c | 599 | } |
c906108c SS |
600 | } |
601 | ||
a0644324 | 602 | # Call a function through a pmf. |
c906108c | 603 | |
a0644324 MC |
604 | set name "print (a.*pmf)(3)" |
605 | gdb_test_multiple "print (a.*pmf)(3)" $name { | |
606 | -re "$vhn = 50\r\n$gdb_prompt $" { | |
607 | pass $name | |
608 | } | |
609 | -re "Not implemented: function invocation through pointer to method with HP aCC\r\n$gdb_prompt $" { | |
610 | # hpacc A.03.45 | |
611 | kfail "gdb/NNNN" $name | |
612 | } | |
613 | -re "Value can't be converted to integer.\r\n$gdb_prompt $" { | |
614 | # gcc 2.95.3 -gdwarf-2 | |
615 | # gcc 2.95.3 -gstabs+ | |
616 | # gcc 3.3.2 -gdwarf-2 | |
617 | # gcc 3.3.2 -gstabs+ | |
618 | # gcc HEAD 2004-01-10 -gdwarf-2 | |
619 | # gcc HEAD 2004-01-10 -gstabs+ | |
620 | kfail "gdb/NNNN" $name | |
c906108c | 621 | } |
c906108c | 622 | } |