summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp/virtfunc.exp
blob: 958900a4ef1df3947e387818938b10bddf499e82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004
# Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  

# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu

# This file was written by Fred Fish. (fnf@cygnus.com)
# And rewritten by Michael Chastain <mec.gnu@mindspring.com>.

set wsopt	"\[\r\n\t \]*"
set ws		"\[\r\n\t \]+"
set nl		"\[\r\n\]+"

if $tracelevel then {
    strace $tracelevel
}

if { [skip_cplus_tests] } { continue }

set testfile "virtfunc"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}

if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}

# Test ptype of a class.
#
# Different C++ compilers produce different output.  I build up regular
# expressions piece by piece to accommodate all the compilers that I
# have seen: gcc 2.95.3, gcc 3.3.2 (ABI 1), gcc 3.4 prerelease (ABI 2);
# and all the debug formats I have seen: dwarf-2 and stabs+.
#
# A complicated class declaration looks like this:
#
#   class A : public virtual V {	// re_class
#     private:
#       V * _vb$V;			// re_vbptr
#       int a;				// re_fields
#
#     public:				// re_access_methods
#       A & operator=(A const &);	// re_synth_gcc_2
#       A(int, A const &);		// ...
#       A(int);				// ...
#       virtual int f(void);		// re_methods
#   }
#
# RE_CLASS matches the class declaration.  C++ allows multiple ways of
# expressing this.
#
#   struct ... { private: ... };
#   class ... { private: ... };
#   class ... { ... };
#
# RE_VBPTR matches the virtual base declarations.  gcc 2.95.3 sometimes
# emits these, but gcc 3.X.Y never emits these.  The name depends on the
# debug format.
#
# RE_FIELDS matches the data fields of the class.
# RE_METHODS matches the methods explicitly declared for the class.
#
# RE_SYNTH_GCC_2 and RE_SYNTH_GCC_3 match the optional synthetic methods
# of the class.  gcc -gstabs+ emits these methods, and gcc -gdwarf-2
# does not.
#
# RE_ACCESS_METHODS is an access specifier after RE_FIELDS and before
# the methods (explicit methods and/or synthetic methods).
# There is also an RE_ACCESS_FIELDS.
#
# When I get HP-UX aCC, I hope that I can just add RE_SYNTH_ACC_NNN.
#
# Yet another twist: with gcc v2, ctor and dtor methods have a hidden
# argument in front, the "in-charge" flag.  With gcc v3, there is no
# hidden argument; instead, there are multiple object functions for
# each ctor and dtor.
#
# -- chastain 2004-01-01

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 } {
    global gdb_prompt
    global wsopt
    global ws
    global nl

    gdb_test_multiple "$command" "$testname" {
	-re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
	    # gcc 2.95.3, dwarf-2, no vbptr
	    # gcc 3.X, abi 1, dwarf-2
	    # gcc 3.X, abi 2, dwarf-2
	    pass "$testname"
	}
	-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 $" {
	    # gcc 2.95.3, dwarf-2, vbptr
	    # TODO: drow says the vbptr is a bug
	    pass "$testname"
	}
	-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 $" {
	    # gcc 2.95.3, stabs+, no vbptr
	    pass "$testname"
	}
	-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 $" {
	    # gcc 2.95.3, stabs+, vbptr
	    # TODO: drow says the vbptr is a bug
	    pass "$testname"
	}
	-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 $" {
	    # gcc 3.X, abi 1, stabs+
	    pass "$testname"
	}
	-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 $" {
	    # gcc 3.X, abi 2, stabs+
	    pass "$testname"
	}
    }

}

proc test_ptype_of_classes {} {
    global gdb_prompt
    global ws
    global nl

    # class VA

    test_one_ptype "ptype VA" "ptype VA" \
	"((struct|class) VA \{${ws}public:|struct VA \{)" \
	"" \
	"" "int va;" \
	"" "" \
	"VA & operator=\\(VA const ?&\\);${ws}VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \
	"VA & operator=\\(VA const ?&\\);${ws}VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \
	""

    # class VB

    test_one_ptype "ptype VB" "ptype VB" \
	"((struct|class) VB \{${ws}public:|struct VB \{)" \
	"" \
	"" "int vb;" \
	"" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
	"VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
	"VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
	""

    # class V

    test_one_ptype "ptype V" "ptype V" \
	"class V : public VA, public VB \{${ws}public:" \
	"" \
	"" "int w;" \
	"" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	""

    # class A

    test_one_ptype "ptype A" "ptype A" \
	"class A : public virtual V \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"" "int a;" \
	"public:" "virtual int f\\((void|)\\);" \
	"A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \
	"A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\(\\);" \
	""

    # class B

    test_one_ptype "ptype B" "ptype B" \
	"class B : public A \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"" "int b;" \
	"public:" "virtual int f\\((void|)\\);" \
	"B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \
	"B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\(\\);" \
	""

    # class C

    test_one_ptype "ptype C" "ptype C" \
	"class C : public virtual V \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"public:" "int c;" \
	"" "" \
	"C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \
	"C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\(\\);" \
	""

    # class AD

    test_one_ptype "ptype AD" "ptype AD" \
	"((struct|class) AD \{${ws}public:|struct AD \{)" \
	"" \
	"" "" \
    	"" "virtual int vg\\((void|)\\);" \
	"AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
	"AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
	""

    # class D

    test_one_ptype "ptype D" "ptype D" \
	"class D : public AD, public virtual V \{(${ws}private:|)" \
    	"V \\*(_vb.1V|_vb.V);" \
    	"public:" "int d;" \
	"" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \
	""

    # class E
    # TODO: E does not show a vbptr for V.  That seems strange.

    test_one_ptype "ptype E" "ptype E" \
	"class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
	"" \
	"public:" "int e;" \
	"" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \
	"E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\(\\);" \
	""

    # An instance of D

    test_one_ptype "ptype dd" "ptype dd" \
	"class D : public AD, public virtual V \{(${ws}private:|)" \
    	"V \\*(_vb.1V|_vb.V);" \
    	"public:" "int d;" \
	"" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \
	""

    # An instance of D *

    test_one_ptype "ptype ppd" "ptype ppd" \
	"class D : public AD, public virtual V \{(${ws}private:|)" \
    	"V \\*(_vb.1V|_vb.V);" \
    	"public:" "int d;" \
	"" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \
	" ?\\*"

    # An instance of AD *
    # TODO: this should be named pADd, not pAd.

    test_one_ptype "ptype pAd" "ptype pAd" \
	"((struct|class) AD \{${ws}public:|struct AD \{)" \
	"" \
	"" "" \
    	"" "virtual int vg\\((void|)\\);" \
	"AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
	"AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
	" ?\\*"

    # An instance of A

    test_one_ptype "ptype a" "ptype a" \
	"class A : public virtual V \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"" "int a;" \
	"public:" "virtual int f\\((void|)\\);" \
	"A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \
	"A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\(\\);" \
	""

    # An instance of B

    test_one_ptype "ptype b" "ptype b" \
	"class B : public A \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"" "int b;" \
	"public:" "virtual int f\\((void|)\\);" \
	"B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \
	"B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\(\\);" \
	""

    # An instance of C

    test_one_ptype "ptype c" "ptype c" \
	"class C : public virtual V \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"public:" "int c;" \
	"" "" \
	"C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \
	"C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\(\\);" \
	""

    # An instance of D

    test_one_ptype "ptype d" "ptype d" \
	"class D : public AD, public virtual V \{(${ws}private:|)" \
    	"V \\*(_vb.1V|_vb.V);" \
    	"public:" "int d;" \
	"" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \
	""

    # An instance of E

    test_one_ptype "ptype e" "ptype e" \
	"class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
	"" \
	"public:" "int e;" \
	"" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \
	"E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\(\\);" \
	""

    # An instance of V

    test_one_ptype "ptype v" "ptype v" \
	"class V : public VA, public VB \{${ws}public:" \
	"" \
	"" "int w;" \
	"" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	""

    # An instance of VB

    test_one_ptype "ptype vb" "ptype vb" \
	"((struct|class) VB \{${ws}public:|struct VB \{)" \
	"" \
	"" "int vb;" \
	"" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
	"VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
	"VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
	""

    # An instance of A *

    test_one_ptype "ptype pAa" "ptype pAa" \
	"class A : public virtual V \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"" "int a;" \
	"public:" "virtual int f\\((void|)\\);" \
	"A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \
	"A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\(\\);" \
	" ?\\*"

    # An instance of A *

    test_one_ptype "ptype pAe" "ptype pAe" \
	"class A : public virtual V \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"" "int a;" \
	"public:" "virtual int f\\((void|)\\);" \
	"A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \
	"A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\(\\);" \
	" ?\\*"

    # An instance of B *

    test_one_ptype "ptype pBe" "ptype pBe" \
	"class B : public A \{(${ws}private:|)" \
	"V \\*(_vb.1V|_vb.V);" \
	"" "int b;" \
	"public:" "virtual int f\\((void|)\\);" \
	"B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \
	"B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\(\\);" \
	" ?\\*"

    # An instance of D *

    test_one_ptype "ptype pDd" "ptype pDd" \
	"class D : public AD, public virtual V \{(${ws}private:|)" \
    	"V \\*(_vb.1V|_vb.V);" \
    	"public:" "int d;" \
	"" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \
	" ?\\*"

    # An instance of D *

    test_one_ptype "ptype pDe" "ptype pDe" \
	"class D : public AD, public virtual V \{(${ws}private:|)" \
    	"V \\*(_vb.1V|_vb.V);" \
    	"public:" "int d;" \
	"" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \
	"D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \
	" ?\\*"

    # An instance of V *

    test_one_ptype "ptype pVa" "ptype pVa" \
	"class V : public VA, public VB \{${ws}public:" \
	"" \
	"" "int w;" \
	"" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	" ?\\*"

    # An instance of V *

    test_one_ptype "ptype pVv" "ptype pVv" \
	"class V : public VA, public VB \{${ws}public:" \
	"" \
	"" "int w;" \
	"" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	" ?\\*"

    # An instance of V *

    test_one_ptype "ptype pVe" "ptype pVe" \
	"class V : public VA, public VB \{${ws}public:" \
	"" \
	"" "int w;" \
	"" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	" ?\\*"

    # An instance of V *

    test_one_ptype "ptype pVd" "ptype pVd" \
	"class V : public VA, public VB \{${ws}public:" \
	"" \
	"" "int w;" \
	"" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	"V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
	" ?\\*"

    # An instance of AD *

    test_one_ptype "ptype pADe" "ptype pADe" \
	"((struct|class) AD \{${ws}public:|struct AD \{)" \
	"" \
	"" "" \
    	"" "virtual int vg\\((void|)\\);" \
	"AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
	"AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
	" ?\\*"

    # An instance of E *

    test_one_ptype "ptype pEe" "ptype pEe" \
	"class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
	"" \
	"public:" "int e;" \
	"" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
	"E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \
	"E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\(\\);" \
	" ?\\*"

    # An instance of VB *

    test_one_ptype "ptype pVB" "ptype pVB" \
	"((struct|class) VB \{${ws}public:|struct VB \{)" \
	"" \
	"" "int vb;" \
	"" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
	"VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
	"VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
	" ?\\*"
}

# Call virtual functions.

proc test_virtual_calls {} {
    global gdb_prompt
    global nl

    if [target_info exists gdb,cannot_call_functions] {
	setup_xfail "*-*-*" 2416
	fail "This target can not call functions"
	return 0
    }

    gdb_test "print pAe->f()"   "\\$\[0-9\]+ = 20"
    gdb_test "print pAa->f()"   "\\$\[0-9\]+ = 1"
    gdb_test "print pDe->vg()"  "\\$\[0-9\]+ = 202"
    gdb_test "print pADe->vg()" "\\$\[0-9\]+ = 202"
    gdb_test "print pDd->vg()"  "\\$\[0-9\]+ = 101"
    gdb_test "print pEe->vvb()" "\\$\[0-9\]+ = 411"
    gdb_test "print pVB->vvb()" "\\$\[0-9\]+ = 407"
    gdb_test "print pBe->vvb()" "\\$\[0-9\]+ = 411"
    gdb_test "print pDe->vvb()" "\\$\[0-9\]+ = 411"
    gdb_test "print pEe->vd()"  "\\$\[0-9\]+ = 282"
    gdb_test "print pEe->fvb()" "\\$\[0-9\]+ = 311"

    # more recent results:
    # wrong value "202"
    #   gcc 2.95.3 -gdwarf-2
    #   gcc 2.95.3 -gstabs+
    # attempt to take addres of value not located in memory
    #   gcc 3.3.2 -gdwarf-2
    #   gcc 3.3.2 -gstabs+
    #
    # -- chastain 2003-12-31

    gdb_test_multiple "print pEe->D::vg()" "print pEe->D::vg()" {
	-re "\\$\[0-9]+ = 102$nl$gdb_prompt $" {
	    pass "print pEe->D::vg()"
	}
	-re "Attempt to take address of value not located in memory.$nl$gdb_prompt $" {
	    kfail "gdb/1064" "print pEe->D::vg()"
	}
    }
}

proc do_tests {} {
    global prms_id
    global bug_id
    global srcdir subdir binfile
    global gdb_prompt

    set prms_id 0
    set bug_id 0

    gdb_exit
    gdb_start
    gdb_reinitialize_dir $srcdir/$subdir
    gdb_load $binfile

    gdb_test "set language c++" "" ""
    gdb_test "set width 0" "" ""

    runto_main
    test_ptype_of_classes

    gdb_breakpoint test_calls
    gdb_test "continue" ".*Breakpoint .* test_calls.*" ""
    test_virtual_calls
}

do_tests