2004-02-11 Michael Chastain <mec.gnu@mindspring.com>
[external/binutils.git] / gdb / testsuite / gdb.cp / virtfunc.exp
1 # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
17
18 # This file was written by Fred Fish. (fnf@cygnus.com)
19 # And rewritten by Michael Chastain <mec.gnu@mindspring.com>.
20
21 set wsopt       "\[\r\n\t \]*"
22 set ws          "\[\r\n\t \]+"
23 set nl          "\[\r\n\]+"
24
25 if $tracelevel then {
26     strace $tracelevel
27 }
28
29 if { [skip_cplus_tests] } { continue }
30
31 set testfile "virtfunc"
32 set srcfile ${testfile}.cc
33 set binfile ${objdir}/${subdir}/${testfile}
34
35 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
36      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
37 }
38
39 # Test ptype of a class.
40 #
41 # Different C++ compilers produce different output.  I build up regular
42 # expressions piece by piece to accommodate all the compilers that I
43 # have seen: gcc 2.95.3, gcc 3.3.2 (ABI 1), gcc 3.4 prerelease (ABI 2);
44 # and all the debug formats I have seen: dwarf-2 and stabs+.
45 #
46 # A complicated class declaration looks like this:
47 #
48 #   class A : public virtual V {        // re_class
49 #     private:
50 #       V * _vb$V;                      // re_vbptr
51 #       int a;                          // re_fields
52 #
53 #     public:                           // re_access_methods
54 #       A & operator=(A const &);       // re_synth_gcc_2
55 #       A(int, A const &);              // ...
56 #       A(int);                         // ...
57 #       virtual int f(void);            // re_methods
58 #   }
59 #
60 # RE_CLASS matches the class declaration.  C++ allows multiple ways of
61 # expressing this.
62 #
63 #   struct ... { private: ... };
64 #   class ... { private: ... };
65 #   class ... { ... };
66 #
67 # RE_VBPTR matches the virtual base declarations.  gcc 2.95.3 sometimes
68 # emits these, but gcc 3.X.Y never emits these.  The name depends on the
69 # debug format.
70 #
71 # RE_FIELDS matches the data fields of the class.
72 # RE_METHODS matches the methods explicitly declared for the class.
73 #
74 # RE_SYNTH_GCC_2 and RE_SYNTH_GCC_3 match the optional synthetic methods
75 # of the class.  gcc -gstabs+ emits these methods, and gcc -gdwarf-2
76 # does not.
77 #
78 # RE_ACCESS_METHODS is an access specifier after RE_FIELDS and before
79 # the methods (explicit methods and/or synthetic methods).
80 # There is also an RE_ACCESS_FIELDS.
81 #
82 # When I get HP-UX aCC, I hope that I can just add RE_SYNTH_ACC_NNN.
83 #
84 # Yet another twist: with gcc v2, ctor and dtor methods have a hidden
85 # argument in front, the "in-charge" flag.  With gcc v3, there is no
86 # hidden argument; instead, there are multiple object functions for
87 # each ctor and dtor.
88 #
89 # -- chastain 2004-01-01
90
91 proc test_one_ptype { command testname re_class re_vbptr re_access_fields re_fields re_access_methods re_methods re_synth_gcc_2 re_synth_gcc_3 re_star } {
92     global gdb_prompt
93     global wsopt
94     global ws
95     global nl
96
97     gdb_test_multiple "$command" "$testname" {
98         -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
99             # gcc 2.95.3, dwarf-2, no vbptr
100             # gcc 3.X, abi 1, dwarf-2
101             # gcc 3.X, abi 2, dwarf-2
102             pass "$testname"
103         }
104         -re "type = $re_class${wsopt}$re_vbptr${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
105             # gcc 2.95.3, dwarf-2, vbptr
106             # TODO: drow says the vbptr is a bug
107             pass "$testname"
108         }
109         -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_2${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
110             # gcc 2.95.3, stabs+, no vbptr
111             pass "$testname"
112         }
113         -re "type = $re_class${wsopt}$re_vbptr${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_2${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
114             # gcc 2.95.3, stabs+, vbptr
115             # TODO: drow says the vbptr is a bug
116             pass "$testname"
117         }
118         -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_3${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
119             # gcc 3.X, abi 1, stabs+
120             pass "$testname"
121         }
122         -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods${wsopt}$re_synth_gcc_3$nl\}$re_star$nl$gdb_prompt $" {
123             # gcc 3.X, abi 2, stabs+
124             pass "$testname"
125         }
126     }
127
128 }
129
130 proc test_ptype_of_classes {} {
131     global gdb_prompt
132     global ws
133     global nl
134
135     # class VA
136
137     test_one_ptype "ptype VA" "ptype VA" \
138         "((struct|class) VA \{${ws}public:|struct VA \{)" \
139         "" \
140         "" "int va;" \
141         "" "" \
142         "VA & operator=\\(VA const ?&\\);${ws}VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \
143         "VA & operator=\\(VA const ?&\\);${ws}VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \
144         ""
145
146     # class VB
147
148     test_one_ptype "ptype VB" "ptype VB" \
149         "((struct|class) VB \{${ws}public:|struct VB \{)" \
150         "" \
151         "" "int vb;" \
152         "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
153         "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
154         "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
155         ""
156
157     # class V
158
159     test_one_ptype "ptype V" "ptype V" \
160         "class V : public VA, public VB \{${ws}public:" \
161         "" \
162         "" "int w;" \
163         "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
164         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
165         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
166         ""
167
168     # class A
169
170     test_one_ptype "ptype A" "ptype A" \
171         "class A : public virtual V \{(${ws}private:|)" \
172         "V \\*(_vb.1V|_vb.V);" \
173         "" "int a;" \
174         "public:" "virtual int f\\((void|)\\);" \
175         "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \
176         "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" \
177         ""
178
179     # class B
180
181     test_one_ptype "ptype B" "ptype B" \
182         "class B : public A \{(${ws}private:|)" \
183         "V \\*(_vb.1V|_vb.V);" \
184         "" "int b;" \
185         "public:" "virtual int f\\((void|)\\);" \
186         "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \
187         "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);" \
188         ""
189
190     # class C
191
192     test_one_ptype "ptype C" "ptype C" \
193         "class C : public virtual V \{(${ws}private:|)" \
194         "V \\*(_vb.1V|_vb.V);" \
195         "public:" "int c;" \
196         "" "" \
197         "C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \
198         "C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);" \
199         ""
200
201     # class AD
202
203     test_one_ptype "ptype AD" "ptype AD" \
204         "((struct|class) AD \{${ws}public:|struct AD \{)" \
205         "" \
206         "" "" \
207         "" "virtual int vg\\((void|)\\);" \
208         "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
209         "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
210         ""
211
212     # class D
213
214     test_one_ptype "ptype D" "ptype D" \
215         "class D : public AD, public virtual V \{(${ws}private:|)" \
216         "V \\*(_vb.1V|_vb.V);" \
217         "public:" "int d;" \
218         "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
219         "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
220         "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \
221         ""
222
223     # class E
224     # TODO: E does not show a vbptr for V.  That seems strange.
225
226     test_one_ptype "ptype E" "ptype E" \
227         "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
228         "" \
229         "public:" "int e;" \
230         "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
231         "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \
232         "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);" \
233         ""
234
235     # An instance of D
236
237     test_one_ptype "ptype dd" "ptype dd" \
238         "class D : public AD, public virtual V \{(${ws}private:|)" \
239         "V \\*(_vb.1V|_vb.V);" \
240         "public:" "int d;" \
241         "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
242         "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
243         "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \
244         ""
245
246     # An instance of D *
247
248     test_one_ptype "ptype ppd" "ptype ppd" \
249         "class D : public AD, public virtual V \{(${ws}private:|)" \
250         "V \\*(_vb.1V|_vb.V);" \
251         "public:" "int d;" \
252         "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
253         "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
254         "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \
255         " ?\\*"
256
257     # An instance of AD *
258     # TODO: this should be named pADd, not pAd.
259
260     test_one_ptype "ptype pAd" "ptype pAd" \
261         "((struct|class) AD \{${ws}public:|struct AD \{)" \
262         "" \
263         "" "" \
264         "" "virtual int vg\\((void|)\\);" \
265         "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
266         "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
267         " ?\\*"
268
269     # An instance of A
270
271     test_one_ptype "ptype a" "ptype a" \
272         "class A : public virtual V \{(${ws}private:|)" \
273         "V \\*(_vb.1V|_vb.V);" \
274         "" "int a;" \
275         "public:" "virtual int f\\((void|)\\);" \
276         "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \
277         "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" \
278         ""
279
280     # An instance of B
281
282     test_one_ptype "ptype b" "ptype b" \
283         "class B : public A \{(${ws}private:|)" \
284         "V \\*(_vb.1V|_vb.V);" \
285         "" "int b;" \
286         "public:" "virtual int f\\((void|)\\);" \
287         "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \
288         "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);" \
289         ""
290
291     # An instance of C
292
293     test_one_ptype "ptype c" "ptype c" \
294         "class C : public virtual V \{(${ws}private:|)" \
295         "V \\*(_vb.1V|_vb.V);" \
296         "public:" "int c;" \
297         "" "" \
298         "C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \
299         "C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);" \
300         ""
301
302     # An instance of D
303
304     test_one_ptype "ptype d" "ptype d" \
305         "class D : public AD, public virtual V \{(${ws}private:|)" \
306         "V \\*(_vb.1V|_vb.V);" \
307         "public:" "int d;" \
308         "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
309         "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
310         "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \
311         ""
312
313     # An instance of E
314
315     test_one_ptype "ptype e" "ptype e" \
316         "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
317         "" \
318         "public:" "int e;" \
319         "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
320         "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \
321         "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);" \
322         ""
323
324     # An instance of V
325
326     test_one_ptype "ptype v" "ptype v" \
327         "class V : public VA, public VB \{${ws}public:" \
328         "" \
329         "" "int w;" \
330         "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
331         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
332         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
333         ""
334
335     # An instance of VB
336
337     test_one_ptype "ptype vb" "ptype vb" \
338         "((struct|class) VB \{${ws}public:|struct VB \{)" \
339         "" \
340         "" "int vb;" \
341         "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
342         "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
343         "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
344         ""
345
346     # An instance of A *
347
348     test_one_ptype "ptype pAa" "ptype pAa" \
349         "class A : public virtual V \{(${ws}private:|)" \
350         "V \\*(_vb.1V|_vb.V);" \
351         "" "int a;" \
352         "public:" "virtual int f\\((void|)\\);" \
353         "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \
354         "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" \
355         " ?\\*"
356
357     # An instance of A *
358
359     test_one_ptype "ptype pAe" "ptype pAe" \
360         "class A : public virtual V \{(${ws}private:|)" \
361         "V \\*(_vb.1V|_vb.V);" \
362         "" "int a;" \
363         "public:" "virtual int f\\((void|)\\);" \
364         "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \
365         "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" \
366         " ?\\*"
367
368     # An instance of B *
369
370     test_one_ptype "ptype pBe" "ptype pBe" \
371         "class B : public A \{(${ws}private:|)" \
372         "V \\*(_vb.1V|_vb.V);" \
373         "" "int b;" \
374         "public:" "virtual int f\\((void|)\\);" \
375         "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \
376         "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);" \
377         " ?\\*"
378
379     # An instance of D *
380
381     test_one_ptype "ptype pDd" "ptype pDd" \
382         "class D : public AD, public virtual V \{(${ws}private:|)" \
383         "V \\*(_vb.1V|_vb.V);" \
384         "public:" "int d;" \
385         "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
386         "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
387         "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \
388         " ?\\*"
389
390     # An instance of D *
391
392     test_one_ptype "ptype pDe" "ptype pDe" \
393         "class D : public AD, public virtual V \{(${ws}private:|)" \
394         "V \\*(_vb.1V|_vb.V);" \
395         "public:" "int d;" \
396         "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
397         "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
398         "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \
399         " ?\\*"
400
401     # An instance of V *
402
403     test_one_ptype "ptype pVa" "ptype pVa" \
404         "class V : public VA, public VB \{${ws}public:" \
405         "" \
406         "" "int w;" \
407         "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
408         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
409         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
410         " ?\\*"
411
412     # An instance of V *
413
414     test_one_ptype "ptype pVv" "ptype pVv" \
415         "class V : public VA, public VB \{${ws}public:" \
416         "" \
417         "" "int w;" \
418         "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
419         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
420         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
421         " ?\\*"
422
423     # An instance of V *
424
425     test_one_ptype "ptype pVe" "ptype pVe" \
426         "class V : public VA, public VB \{${ws}public:" \
427         "" \
428         "" "int w;" \
429         "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
430         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
431         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
432         " ?\\*"
433
434     # An instance of V *
435
436     test_one_ptype "ptype pVd" "ptype pVd" \
437         "class V : public VA, public VB \{${ws}public:" \
438         "" \
439         "" "int w;" \
440         "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
441         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
442         "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
443         " ?\\*"
444
445     # An instance of AD *
446
447     test_one_ptype "ptype pADe" "ptype pADe" \
448         "((struct|class) AD \{${ws}public:|struct AD \{)" \
449         "" \
450         "" "" \
451         "" "virtual int vg\\((void|)\\);" \
452         "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
453         "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
454         " ?\\*"
455
456     # An instance of E *
457
458     test_one_ptype "ptype pEe" "ptype pEe" \
459         "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
460         "" \
461         "public:" "int e;" \
462         "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
463         "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \
464         "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);" \
465         " ?\\*"
466
467     # An instance of VB *
468
469     test_one_ptype "ptype pVB" "ptype pVB" \
470         "((struct|class) VB \{${ws}public:|struct VB \{)" \
471         "" \
472         "" "int vb;" \
473         "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
474         "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
475         "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
476         " ?\\*"
477 }
478
479 # Call virtual functions.
480
481 proc test_virtual_calls {} {
482     global gdb_prompt
483     global nl
484
485     if [target_info exists gdb,cannot_call_functions] {
486         setup_xfail "*-*-*" 2416
487         fail "This target can not call functions"
488         return 0
489     }
490
491     gdb_test "print pAe->f()"   "\\$\[0-9\]+ = 20"
492     gdb_test "print pAa->f()"   "\\$\[0-9\]+ = 1"
493     gdb_test "print pDe->vg()"  "\\$\[0-9\]+ = 202"
494     gdb_test "print pADe->vg()" "\\$\[0-9\]+ = 202"
495     gdb_test "print pDd->vg()"  "\\$\[0-9\]+ = 101"
496     gdb_test "print pEe->vvb()" "\\$\[0-9\]+ = 411"
497     gdb_test "print pVB->vvb()" "\\$\[0-9\]+ = 407"
498     gdb_test "print pBe->vvb()" "\\$\[0-9\]+ = 411"
499     gdb_test "print pDe->vvb()" "\\$\[0-9\]+ = 411"
500     gdb_test "print pEe->vd()"  "\\$\[0-9\]+ = 282"
501     gdb_test "print pEe->fvb()" "\\$\[0-9\]+ = 311"
502
503     # more recent results:
504     # wrong value "202"
505     #   gcc 2.95.3 -gdwarf-2
506     #   gcc 2.95.3 -gstabs+
507     # attempt to take addres of value not located in memory
508     #   gcc 3.3.2 -gdwarf-2
509     #   gcc 3.3.2 -gstabs+
510     #
511     # -- chastain 2003-12-31
512
513     gdb_test_multiple "print pEe->D::vg()" "print pEe->D::vg()" {
514         -re "\\$\[0-9]+ = 102$nl$gdb_prompt $" {
515             pass "print pEe->D::vg()"
516         }
517         -re "Attempt to take address of value not located in memory.$nl$gdb_prompt $" {
518             kfail "gdb/1064" "print pEe->D::vg()"
519         }
520     }
521 }
522
523 proc do_tests {} {
524     global prms_id
525     global bug_id
526     global srcdir subdir binfile
527     global gdb_prompt
528
529     set prms_id 0
530     set bug_id 0
531
532     gdb_exit
533     gdb_start
534     gdb_reinitialize_dir $srcdir/$subdir
535     gdb_load $binfile
536
537     gdb_test "set language c++" "" ""
538     gdb_test "set width 0" "" ""
539
540     runto_main
541     test_ptype_of_classes
542
543     gdb_breakpoint test_calls
544     gdb_test "continue" ".*Breakpoint .* test_calls.*" ""
545     test_virtual_calls
546 }
547
548 do_tests