aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp/inherit.exp
blob: 25723e97c19617757a2b0099fd2fd774adf702af (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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
# Copyright 1992-2018 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 3 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, see <http://www.gnu.org/licenses/>.

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

set ws  "\[\r\n\t \]+"
set nl  "\[\r\n\]+"
set vhn "\\$\[0-9\]+"

if { [skip_cplus_tests] } { continue }

load_lib "cp-support.exp"

standard_testfile misc.cc

if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
    return -1
}

# Single inheritance, print type definitions.

proc test_ptype_si { } {
    global gdb_prompt
    global ws
    global nl

    # A simple class.

    cp_test_ptype_class \
	"A" "ptype A (FIXME)" "class" "A" \
	{
	    { field public "int a;" }
	    { field public "int x;" }
	}
    cp_test_ptype_class "class A" "ptype class A (FIXME)" "class" "A" ibid
    cp_test_ptype_class "g_A" "ptype g_A (FIXME)" "class" "A" ibid

    # A derived class.

    cp_test_ptype_class \
	"B" "" "class" "B" \
	{
	    { base         "public A" }
	    { field public "int b;" }
	    { field public "int x;" }
	}
    cp_test_ptype_class "class B" "" "class" "B" ibid
    cp_test_ptype_class "g_B" "" "class" "B" ibid

    # Another derived class.

    cp_test_ptype_class \
	"C" "" "class" "C" \
	{
	    { base         "public A" }
	    { field public "int c;" }
	    { field public "int x;" }
	}
    cp_test_ptype_class "class C" "" "class" "C" ibid
    cp_test_ptype_class "g_C" "" "class" "C" ibid

    # A structure with no tag.
    # TODO: move this mess into a separate file, and re-specify
    # which results are PASS, KFAIL, XFAIL, and FAIL.

    set re_tag		"tagless_struct"
    set XX_tag		"\\._1"
    set re_class	"(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)"
    set XX_class	"(class $XX_tag \{${ws}public:|struct $XX_tag \{)"
    set re_fields	"int one;${ws}int two;"
    set re_synth_gcc_23	"$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);"
    set XX_synth_gcc_23	"($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);"

    set name "ptype tagless struct"
    gdb_test_multiple "ptype tagless_struct" $name {
	-re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
	    # gcc 2.95.3 -gdwarf-2
	    pass "$name"
	}
	-re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
	    # gcc 2.95.3 -gstabs+
	    pass "$name"
	}
	-re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gdwarf-2
	    # gcc 3.4.1 -gdwarf-2
	    # gcc HEAD 2004-07-31 -gdwarf-2
	    # gcc HEAD 2004-07-31 -gstabs+
	    pass "$name"
	}
	-re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gstabs+
	    # gcc 3.4.1 -gstabs+
	    pass "$name"
	}
	-re "No symbol \"tagless_struct\" in current context.$nl$gdb_prompt $" {
	    # Several GCC 4.x versions provide neither a DW_TAG_typedef DIE
	    # nor use the typedef name as struct tag name.
	    xfail "$name"
	}
    }

    set name "ptype variable of type tagless struct"
    gdb_test_multiple "ptype v_tagless" $name {
	-re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
	    # gcc 2.95.3 -gdwarf-2
	    pass "$name"
	}
	-re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" {
	    # gcc 2.95.3 -gstabs+
	    pass "$name"
	}
	-re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gdwarf-2
	    # gcc 3.4.1 -gdwarf-2
	    # gcc HEAD 2004-07-31 -gdwarf-2
	    # gcc HEAD 2004-07-31 -gstabs+
	    pass "$name"
	}
	-re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gstabs+
	    # gcc 3.4.1 -gstabs+
	    pass "$name"
	}
    }
}

# Multiple inheritance, print type definitions.

proc test_ptype_mi { } {

    # A class with two bases.

    cp_test_ptype_class \
	"D" "" "class" "D" \
	{
	    { base         "public B" }
	    { base         "public C" }
	    { field public "int d;" }
	    { field public "int x;" }
	}
    cp_test_ptype_class "class D" "" "class" "D" ibid
    cp_test_ptype_class "g_D" "" "class" "D" ibid

    # A class derived from the previous class.

    cp_test_ptype_class \
	"E" "" "class" "E" \
	{
	    { base         "public D" }
	    { field public "int e;" }
	    { field public "int x;" }
	}
    cp_test_ptype_class "class E" "" "class" "E" ibid
    cp_test_ptype_class "g_E" "" "class" "E" ibid
}

# Single virtual inheritance, print type definitions.

proc test_ptype_vi { } {

    # class vA

    cp_test_ptype_class \
	"vA" "" "class" "vA" \
	{
	    { field public "int va;" }
	    { field public "int vx;" }
	}
    cp_test_ptype_class "class vA" "" "class" "vA" ibid
    cp_test_ptype_class "g_vA" "" "class" "vA" ibid

    # class vB

    cp_test_ptype_class \
	"vB" "" "class" "vB" \
	{
	    { base         "public virtual vA" }
	    { vbase        "vA" }
	    { field public "int vb;" }
	    { field public "int vx;" }
	}
    cp_test_ptype_class "class vB" "" "class" "vB" ibid
    cp_test_ptype_class "g_vB" "" "class" "vB" ibid

    # class vC

    cp_test_ptype_class \
	"vC" "" "class" "vC" \
	{
	    { base         "public virtual vA" }
	    { vbase        "vA" }
	    { field public "int vc;" }
	    { field public "int vx;" }
	}
    cp_test_ptype_class "class vC" "" "class" "vC" ibid
    cp_test_ptype_class "g_vC" "" "class" "vC" ibid

}

# Multiple virtual inheritance, print type definitions.

proc test_ptype_mvi { } {

    # class vD

    cp_test_ptype_class \
	"vD" "" "class" "vD" \
	{
	    { base         "public virtual vB" }
	    { base         "public virtual vC" }
	    { vbase        "vC" }
	    { vbase        "vB" }
	    { field public "int vd;" }
	    { field public "int vx;" }
	}
    cp_test_ptype_class "class vD" "" "class" "vD" ibid
    cp_test_ptype_class "g_vD" "" "class" "vD" ibid

    # class vE

    cp_test_ptype_class \
	"vE" "" "class" "vE" \
	{
	    { base         "public virtual vD" }
	    { vbase        "vD" }
	    { field public "int ve;" }
	    { field public "int vx;" }
	}
    cp_test_ptype_class "class vE" "" "class" "vE" ibid
    cp_test_ptype_class "g_vE" "" "class" "vE" ibid

}

# Single inheritance, print individual members.

proc test_print_si_members { } {
    global vhn

    # Print all members of g_A using fully qualified form.
    gdb_test "print g_A.A::a" "$vhn = 1"
    gdb_test "print g_A.A::x" "$vhn = 2"

    # Print members of g_A using nonambiguous compact form.
    gdb_test "print g_A.a" "$vhn = 1"
    gdb_test "print g_A.x" "$vhn = 2"

    # Print all members of g_B using fully qualified form.
    gdb_test "print g_B.A::a" "$vhn = 3"
    gdb_test "print g_B.A::x" "$vhn = 4"
    gdb_test "print g_B.B::b" "$vhn = 5"
    gdb_test "print g_B.B::x" "$vhn = 6"

    # Print members of g_B using nonambiguous compact form.
    gdb_test "print g_B.a" "$vhn = 3"
    gdb_test "print g_B.b" "$vhn = 5"
    gdb_test "print g_B.x" "$vhn = 6"

    # Print all members of g_C using fully qualified form.
    gdb_test "print g_C.A::a" "$vhn = 7"
    gdb_test "print g_C.A::x" "$vhn = 8"
    gdb_test "print g_C.C::c" "$vhn = 9"
    gdb_test "print g_C.C::x" "$vhn = 10"

    # Print members of g_C using nonambiguous compact form.
    gdb_test "print g_C.a" "$vhn = 7"
    gdb_test "print g_C.c" "$vhn = 9"
    gdb_test "print g_C.x" "$vhn = 10"
}

# Single inheritance, print complete classes.

proc test_print_si_classes { } {
    global vhn

    # Print all members of g_A, g_B, g_C.
    gdb_test "print g_A" "$vhn = \{a = 1, x = 2\}"
    gdb_test "print g_B" "$vhn = \{<(class A|A)> = \{a = 3, x = 4\}, b = 5, x = 6\}"
    gdb_test "print g_C" "$vhn = \{<(class A|A)> = \{a = 7, x = 8\}, c = 9, x = 10\}"
}

# Multiple inheritance, print individual members.

proc test_print_mi_members {} {
    global gdb_prompt
    global nl
    global vhn

    # Print all members of g_A.
    gdb_test "print g_A.A::a" "$vhn = 1"
    gdb_test "print g_A.A::x" "$vhn = 2"

    # Print all members of g_B.
    gdb_test "print g_B.A::a" "$vhn = 3"
    gdb_test "print g_B.A::x" "$vhn = 4"
    gdb_test "print g_B.B::b" "$vhn = 5"
    gdb_test "print g_B.B::x" "$vhn = 6"

    # Print all members of g_C.
    gdb_test "print g_C.A::a" "$vhn = 7"
    gdb_test "print g_C.A::x" "$vhn = 8"
    gdb_test "print g_C.C::c" "$vhn = 9"
    gdb_test "print g_C.C::x" "$vhn = 10"

    # Print all members of g_D.
    #
    # g_D.A::a and g_D.A::x are ambiguous member accesses.
    gdb_test "print g_D.A::a" "base class 'A' is ambiguous in type 'D'"
    gdb_test "print g_D.C::a" "$vhn = 15"
    gdb_test "print g_D.B::a" "$vhn = 11"
    gdb_test "print g_D.A::x" "base class 'A' is ambiguous in type 'D'"
    gdb_test "print g_D.B::b" "$vhn = 13"
    gdb_test "print g_D.B::x" "$vhn = 14"
    gdb_test "print g_D.C::c" "$vhn = 17"
    gdb_test "print g_D.C::x" "$vhn = 18"
    gdb_test "print g_D.D::d" "$vhn = 19"
    gdb_test "print g_D.D::x" "$vhn = 20"

    # Print all members of g_E.
    # g_E.A::a and g_E.A::x are ambiguous.

    gdb_test "print g_E.A::a" "base class 'A' is ambiguous in type 'E'"
    gdb_test "print g_E.A::x" "base class 'A' is ambiguous in type 'E'"
    gdb_test "print g_E.B::b" "$vhn = 23"
    gdb_test "print g_E.B::x" "$vhn = 24"
    gdb_test "print g_E.C::c" "$vhn = 27"
    gdb_test "print g_E.C::x" "$vhn = 28"
    gdb_test "print g_E.D::d" "$vhn = 29"
    gdb_test "print g_E.D::x" "$vhn = 30"
    gdb_test "print g_E.E::e" "$vhn = 31"
    gdb_test "print g_E.E::x" "$vhn = 32"
}

# Multiple inheritance, print individual member types.

proc test_print_mi_member_types {} {
    global gdb_prompt
    global nl
    global vhn

    # Print the types of some members of g_D without qualifying them.
    gdb_test "ptype g_D.b" "type = int"
    gdb_test "ptype g_D.c" "type = int"
    gdb_test "ptype g_D.d" "type = int"

    # Print the types of qualified members; none of these tests pass today.

    # Print all members of g_A.
    gdb_test "ptype g_A.A::a" "type = int"
    gdb_test "ptype g_A.A::x" "type = int"

    # Print all members of g_B.
    gdb_test "ptype g_B.A::a" "type = int"
    gdb_test "ptype g_B.A::x" "type = int"
    gdb_test "ptype g_B.B::b" "type = int"
    gdb_test "ptype g_B.B::x" "type = int"

    # Print all members of g_C.
    gdb_test "ptype g_C.A::a" "type = int"
    gdb_test "ptype g_C.A::x" "type = int"
    gdb_test "ptype g_C.C::c" "type = int"
    gdb_test "ptype g_C.C::x" "type = int"

    # Print all members of g_D.
    #
    # g_D.A::a and g_D.A::x are ambiguous member accesses.

    gdb_test "ptype g_D.A::a" "base class 'A' is ambiguous in type 'D'"
    gdb_test "ptype g_D.A::x" "base class 'A' is ambiguous in type 'D'"
    gdb_test "ptype g_D.B::b" "type = int"
    gdb_test "ptype g_D.B::x" "type = int"
    gdb_test "ptype g_D.C::c" "type = int"
    gdb_test "ptype g_D.C::x" "type = int"
    gdb_test "ptype g_D.D::d" "type = int"
    gdb_test "ptype g_D.D::x" "type = int"

    # Print all members of g_E.
    # g_E.A::a and g_E.A::x are ambiguous.

    gdb_test "ptype g_E.A::a" "base class 'A' is ambiguous in type 'E'"
    gdb_test "ptype g_E.A::x" "base class 'A' is ambiguous in type 'E'"
    gdb_test "ptype g_E.B::b" "type = int"
    gdb_test "ptype g_E.B::x" "type = int"
    gdb_test "ptype g_E.C::c" "type = int"
    gdb_test "ptype g_E.C::x" "type = int"
    gdb_test "ptype g_E.D::d" "type = int"
    gdb_test "ptype g_E.D::x" "type = int"
    gdb_test "ptype g_E.E::e" "type = int"
    gdb_test "ptype g_E.E::x" "type = int"
}

# Multiple inheritance, print complete classes.

proc test_print_mi_classes { } {
    global vhn

    # Print all members of g_D.
    gdb_test "print g_D" "$vhn = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 11, x = 12\}, b = 13, x = 14\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 15, x = 16\}, c = 17, x = 18\}, d = 19, x = 20\}"

    # Print all members of g_E.
    gdb_test "print g_E" "$vhn = \{\<(class |)D\> = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 21, x = 22\}, b = 23, x = 24\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 25, x = 26\}, c = 27, x = 28\}, d = 29, x = 30\}, e = 31, x = 32\}"
}

# Single inheritance, print anonymous unions.
# GDB versions prior to 4.14 entered an infinite loop when printing
# the type of a class containing an anonymous union, and they were also
# incapable of printing the member of an anonymous union.
# We test the printing of the member first, and perform the other tests
# only if the test succeeds, to avoid the infinite loop.

proc test_print_anon_union {} {
    global gdb_prompt
    global ws
    global nl
    global vhn

    gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member"

    set name "print variable of type anonymous union"
    gdb_test_multiple "print g_anon_union" $name {
	-re "$vhn = \{one = 1, \{a = 2, b = \[0-9\]+\}\}$nl$gdb_prompt $" {
	    pass $name
	}
    }

    set name "print type of anonymous union"
    set re_tag "class_with_anon_union"
    set re_class "(class $re_tag \{${ws}public:|struct $re_tag \{)"
    set re_fields "int one;${ws}union \{${ws}int a;${ws}long( int)? b;${ws}\};"
    gdb_test_multiple "ptype g_anon_union" $name {
	-re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
	    pass $name
	}
    }
}


# Single virtual inheritance, print individual members.

proc test_print_svi_members { } {
    global vhn

    # Print all members of g_vA.
    gdb_test "print g_vA.vA::va" "$vhn = 1"
    gdb_test "print g_vA.vA::vx" "$vhn = 2"

    # Print members of g_vA using compact form.
    gdb_test "print g_vA.va" "$vhn = 1"
    gdb_test "print g_vA.vx" "$vhn = 2"

    # Print all members of g_vB.
    gdb_test "print g_vB.vA::va" "$vhn = 3"
    gdb_test "print g_vB.vA::vx" "$vhn = 4"
    gdb_test "print g_vB.vB::vb" "$vhn = 5"
    gdb_test "print g_vB.vB::vx" "$vhn = 6"

    # Print members of g_vB using compact form.
    gdb_test "print g_vB.va" "$vhn = 3"
    gdb_test "print g_vB.vb" "$vhn = 5"
    gdb_test "print g_vB.vx" "$vhn = 6"

    # Print all members of g_vC.
    gdb_test "print g_vC.vA::va" "$vhn = 7"
    gdb_test "print g_vC.vA::vx" "$vhn = 8"
    gdb_test "print g_vC.vC::vc" "$vhn = 9"
    gdb_test "print g_vC.vC::vx" "$vhn = 10"

    # Print members of g_vC using compact form.
    gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va"
    gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc"
    gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx"
}

# Single virtual inheritance, print complete classes.

proc test_print_svi_classes { } {
    global gdb_prompt
    global hex
    global nl
    global vhn

    # Print all members of g_vA.
    gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}"

    # Print all members of g_vB.
    set re_vbptr_2	"(_vb.2vA|_vb.vA)"
    set re_vbptr_3	"_vptr.vB"

    set name "print g_vB"
    gdb_test_multiple "print g_vB" $name {
	-re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
	    # gcc 2.95.3 -gdwarf-2
	    # gcc 2.95.3 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gdwarf-2
	    # gcc 3.4.1 -gdwarf-2
	    # gcc 3.4.1 -gstabs+
	    # gcc HEAD 2004-07-31 -gdwarf-2
	    pass "$name (FIXME v3 vtbl ptr)"
	}
	-re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <typeinfo for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" {
	    # gcc HEAD 2004-07-31 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = ${hex}( <\[^>]*>)?, vb = 5, vx = 6\}$nl$gdb_prompt $" {
	    # gcc HEAD 2015?+
	    # the vptr is set to the address *after* the vtable,
	    # so the # symbol shown is unpredictable.
	    pass "$name (symbols ignored)"
	}
    }

    # Print all members of g_vC.
    set re_vbptr_2	"(_vb.2vA|_vb.vA)"
    set re_vbptr_3	"_vptr.vC"

    set name "print g_vC"
    gdb_test_multiple "print g_vC" $name {
	-re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
	    # gcc 2.95.3 -gdwarf-2
	    # gcc 2.95.3 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gdwarf-2
	    # gcc 3.4.1 -gdwarf-2
	    # gcc 3.4.1 -gstabs+
	    # gcc HEAD 2004-07-31 -gdwarf-2
	    pass "$name (FIXME v3 vtbl ptr)"
	}
	-re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <typeinfo for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" {
	    # gcc HEAD 2004-07-31 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = ${hex}( <\[^>]*>)?, vc = 9, vx = 10\}$nl$gdb_prompt $" {
	    # gcc HEAD 2015?+
	    # the vptr is set to the address *after* the vtable,
	    # so the symbol shown is unpredictable.
	    pass "$name (symbols ignored)"
	}
    }
}

# Multiple virtual inheritance, print individual members.

proc test_print_mvi_members { } {
    global vhn

    # Print all members of g_vD.
    gdb_test "print g_vD.vA::va" "$vhn = 19"
    gdb_test "print g_vD.vA::vx" "$vhn = 20"
    gdb_test "print g_vD.vB::vb" "$vhn = 21"
    gdb_test "print g_vD.vB::vx" "$vhn = 22"
    gdb_test "print g_vD.vC::vc" "$vhn = 23"
    gdb_test "print g_vD.vC::vx" "$vhn = 24"
    gdb_test "print g_vD.vD::vd" "$vhn = 25"
    gdb_test "print g_vD.vD::vx" "$vhn = 26"

    # Print all members of g_vE.
    gdb_test "print g_vE.vA::va" "$vhn = 0"
    gdb_test "print g_vE.vA::vx" "$vhn = 0"
    gdb_test "print g_vE.vB::vb" "$vhn = 0"
    gdb_test "print g_vE.vB::vx" "$vhn = 0"
    gdb_test "print g_vE.vC::vc" "$vhn = 0"
    gdb_test "print g_vE.vC::vx" "$vhn = 0"
    gdb_test "print g_vE.vD::vd" "$vhn = 0"
    gdb_test "print g_vE.vD::vx" "$vhn = 0"
    gdb_test "print g_vE.vE::ve" "$vhn = 27"
    gdb_test "print g_vE.vE::vx" "$vhn = 28"
}

# Multiple virtual inheritance, print complete classes.

proc test_print_mvi_classes { } {
    global gdb_prompt
    global hex
    global ws
    global nl
    global vhn

    # Virtual base pointers for everybody.

    set re_vbptr_2_vA	"(_vb.2vA|_vb.vA)"
    set re_vbptr_2_vB	"(_vb.2vB|_vb.vB)"
    set re_vbptr_2_vC	"(_vb.2vC|_vb.vC)"
    set re_vbptr_2_vD	"(_vb.2vD|_vb.vD)"
    set re_vbptr_3_vA	"_vptr.vA"
    set re_vbptr_3_vB	"_vptr.vB"
    set re_vbptr_3_vC	"_vptr.vC"
    set re_vbptr_3_vD	"_vptr.vD"
    set re_vbptr_3_vE	"_vptr.vE"

    # Print all members of g_vD.

    set name "print g_vD"
    gdb_test_multiple "print g_vD" $name {
	-re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_2_vA = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_2_vA = $hex, vc = 23, vx = 24\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
	    # gcc 2.95.3 -gdwarf-2
	    # gcc 2.95.3 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = ${hex}( <vtable for vD.*>)?, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <vtable for vC.*>)?, vc = 23, vx = 24\}, $re_vbptr_3_vD = ${hex}( <vtable for vD.*>)?, vd = 25, vx = 26\}$nl$gdb_prompt $" {
	    # gcc 3.3.2 -gdwarf-2
	    # gcc HEAD 2004-01-21 -gdwarf-2
	    # gcc HEAD 2004-01-21 -gstabs+
	    pass "$name (FIXME v3 vtbl ptr)"
	}
	-re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = $hex <VTT for vD>, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
	    # gcc 3.3.2 -gstabs+
	    pass "$name"
	}
	-re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = ${hex}( <\[^>]*>)?, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <\[^>]*>)?, vc = 23, vx = 24\}, $re_vbptr_3_vD = ${hex}( <\[^>]*>)?, vd = 25, vx = 26\}$nl$gdb_prompt $" {
	    # gcc HEAD 2015?+
	    # the vptr is set to the address *after* the vtable,
	    # so the symbol shown is unpredictable.
	    pass "$name (symbols ignored)"
	}
    }

    # Print all members of g_vE.

    set name "print g_vE"
    gdb_test_multiple "print g_vE" $name {
	-re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_2_vA = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_2_vA = $hex, vc = 0, vx = 0\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 0, vx = 0\}, $re_vbptr_2_vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
	    # gcc 2.95.3 -gdwarf-2
	    # gcc 2.95.3 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = ${hex}( <vtable for vE.*>)?, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <vtable for vE.*>)?, vc = 0, vx = 0\}, $re_vbptr_3_vD = ${hex}( <vtable for vE.*>)?, vd = 0, vx = 0\}, $re_vbptr_3_vE = ${hex}( <vtable for vE.*>)?, ve = 27, vx = 28\}$nl$gdb_prompt $" {
	    # gcc 3.3.4 -gdwarf-2
	    # gcc 3.3.4 -gstabs+
	    # gcc 3.4.1 -gdwarf-2
	    # gcc 3.4.1 -gstabs+
	    # gcc HEAD 2004-07-31 -gdwarf-2
	    pass "$name (FIXME v3 vtbl ptr)"
	}
	-re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex <VTT for vD>, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
	    # gcc 3.2.7-rh -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex <typeinfo for vE>, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
	    # gcc HEAD 2004-07-31 -gstabs+
	    pass $name
	}
	-re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = ${hex}( <\[^>]*>)?, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <\[^>]*>)?, vc = 0, vx = 0\}, $re_vbptr_3_vD = ${hex}( <\[^>]*>)?, vd = 0, vx = 0\}, $re_vbptr_3_vE = ${hex}( <\[^>]*>)?, ve = 27, vx = 28\}$nl$gdb_prompt $" {
	    # gcc HEAD 2015?+
	    # the vptr is set to the address *after* the vtable,
	    # so the symbol shown is unpredictable.
	    pass "$name (symbols ignored)"
	}
    }
}

proc do_tests { } {
    gdb_test_no_output "set width 0"

    if { ![runto_main] } then {
	perror "couldn't run to main"
	return
    }

    gdb_test_no_output "set language c++"
    test_ptype_si
    test_ptype_mi
    test_ptype_vi
    test_ptype_mvi

    if { ![runto 'inheritance2'] } then {
	perror "couldn't run to inheritance2"
	return
    }

    test_print_si_members
    test_print_si_classes
    test_print_mi_members
    test_print_mi_member_types
    test_print_mi_classes
    test_print_anon_union

    if { ![runto 'inheritance4'] } {
	perror "couldn't run to inheritance4"
	return
    }

    test_print_svi_members
    test_print_svi_classes
    test_print_mvi_members
    test_print_mvi_classes
}

do_tests