Home | History | Annotate | Download | only in test
      1 //===------------------------- dynamic_cast3.cpp --------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #include <cassert>
     11 #include "support/timer.hpp"
     12 
     13 /*
     14 
     15 A1   A2   A3
     16 
     17 */
     18 
     19 namespace t1
     20 {
     21 
     22 struct A1
     23 {
     24     char _[43981];
     25     virtual ~A1() {}
     26 
     27     A1* getA1() {return this;}
     28 };
     29 
     30 struct A2
     31 {
     32     char _[34981];
     33     virtual ~A2() {}
     34 
     35     A2* getA2() {return this;}
     36 };
     37 
     38 struct A3
     39 {
     40     char _[93481];
     41     virtual ~A3() {}
     42 
     43     A3* getA3() {return this;}
     44 };
     45 
     46 void test()
     47 {
     48     A1 a1;
     49     A2 a2;
     50     A3 a3;
     51     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
     52     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
     53     assert(dynamic_cast<A1*>(a3.getA3()) == 0);
     54     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
     55     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
     56     assert(dynamic_cast<A2*>(a3.getA3()) == 0);
     57     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
     58     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
     59     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
     60 }
     61 
     62 }  // t1
     63 
     64 /*
     65 
     66 A1   A2
     67 |
     68 A3
     69 
     70 */
     71 
     72 namespace t2
     73 {
     74 
     75 struct A1
     76 {
     77     char _[43981];
     78     virtual ~A1() {}
     79 
     80     A1* getA1() {return this;}
     81 };
     82 
     83 struct A2
     84 {
     85     char _[34981];
     86     virtual ~A2() {}
     87 
     88     A2* getA2() {return this;}
     89 };
     90 
     91 struct A3
     92     : public A1
     93 {
     94     char _[93481];
     95     virtual ~A3() {}
     96 
     97     A3* getA3() {return this;}
     98 };
     99 
    100 void test()
    101 {
    102     A1 a1;
    103     A2 a2;
    104     A3 a3;
    105     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    106     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    107     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    108     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
    109 
    110     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    111     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    112     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    113     assert(dynamic_cast<A2*>(a3.getA3()) == 0);
    114 
    115     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    116     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    117     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
    118     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    119 }
    120 
    121 }  // t2
    122 
    123 namespace t3
    124 {
    125 
    126 struct A1
    127 {
    128     char _[43981];
    129     virtual ~A1() {}
    130 
    131     A1* getA1() {return this;}
    132 };
    133 
    134 struct A2
    135 {
    136     char _[34981];
    137     virtual ~A2() {}
    138 
    139     A2* getA2() {return this;}
    140 };
    141 
    142 struct A3
    143     : public virtual A1
    144 {
    145     char _[93481];
    146     virtual ~A3() {}
    147 
    148     A3* getA3() {return this;}
    149 };
    150 
    151 void test()
    152 {
    153     A1 a1;
    154     A2 a2;
    155     A3 a3;
    156     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    157     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    158     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    159     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
    160 
    161     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    162     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    163     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    164     assert(dynamic_cast<A2*>(a3.getA3()) == 0);
    165 
    166     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    167     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    168     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
    169     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    170 }
    171 
    172 }  // t3
    173 
    174 namespace t4
    175 {
    176 
    177 struct A1
    178 {
    179     char _[43981];
    180     virtual ~A1() {}
    181 
    182     A1* getA1() {return this;}
    183 };
    184 
    185 struct A2
    186 {
    187     char _[34981];
    188     virtual ~A2() {}
    189 
    190     A2* getA2() {return this;}
    191 };
    192 
    193 struct A3
    194     : private A1
    195 {
    196     char _[93481];
    197     virtual ~A3() {}
    198 
    199     A1* getA1() {return this;}
    200     A3* getA3() {return this;}
    201 };
    202 
    203 void test()
    204 {
    205     A1 a1;
    206     A2 a2;
    207     A3 a3;
    208     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    209     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    210     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    211 
    212     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    213     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    214     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    215     assert(dynamic_cast<A2*>(a3.getA3()) == 0);
    216 
    217     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    218     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    219     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    220     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    221 }
    222 
    223 }  // t4
    224 
    225 namespace t5
    226 {
    227 
    228 struct A1
    229 {
    230     char _[43981];
    231     virtual ~A1() {}
    232 
    233     A1* getA1() {return this;}
    234 };
    235 
    236 struct A2
    237 {
    238     char _[34981];
    239     virtual ~A2() {}
    240 
    241     A2* getA2() {return this;}
    242 };
    243 
    244 struct A3
    245     : private virtual A1
    246 {
    247     char _[93481];
    248     virtual ~A3() {}
    249 
    250     A1* getA1() {return this;}
    251     A3* getA3() {return this;}
    252 };
    253 
    254 void test()
    255 {
    256     A1 a1;
    257     A2 a2;
    258     A3 a3;
    259     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    260     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    261     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    262 
    263     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    264     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    265     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    266     assert(dynamic_cast<A2*>(a3.getA3()) == 0);
    267 
    268     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    269     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    270     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    271     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    272 }
    273 
    274 }  // t5
    275 
    276 /*
    277 
    278 A1   A2
    279  \  /
    280   A3
    281 
    282 */
    283 
    284 namespace t6
    285 {
    286 
    287 struct A1
    288 {
    289     char _[43981];
    290     virtual ~A1() {}
    291 
    292     A1* getA1() {return this;}
    293 };
    294 
    295 struct A2
    296 {
    297     char _[34981];
    298     virtual ~A2() {}
    299 
    300     A2* getA2() {return this;}
    301 };
    302 
    303 struct A3
    304     : public A1,
    305       public A2
    306 {
    307     char _[93481];
    308     virtual ~A3() {}
    309 
    310     A1* getA1() {return this;}
    311     A2* getA2() {return this;}
    312     A3* getA3() {return this;}
    313 };
    314 
    315 void test()
    316 {
    317     A1 a1;
    318     A2 a2;
    319     A3 a3;
    320     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    321     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    322     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    323     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
    324     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
    325 
    326     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    327     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    328     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
    329     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    330     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    331 
    332     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    333     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    334     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
    335     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    336     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    337 }
    338 
    339 }  // t6
    340 
    341 namespace t7
    342 {
    343 
    344 struct A1
    345 {
    346     char _[43981];
    347     virtual ~A1() {}
    348 
    349     A1* getA1() {return this;}
    350 };
    351 
    352 struct A2
    353 {
    354     char _[34981];
    355     virtual ~A2() {}
    356 
    357     A2* getA2() {return this;}
    358 };
    359 
    360 struct A3
    361     : public virtual A1,
    362       public A2
    363 {
    364     char _[93481];
    365     virtual ~A3() {}
    366 
    367     A1* getA1() {return this;}
    368     A2* getA2() {return this;}
    369     A3* getA3() {return this;}
    370 };
    371 
    372 void test()
    373 {
    374     A1 a1;
    375     A2 a2;
    376     A3 a3;
    377     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    378     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    379     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    380     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
    381     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
    382 
    383     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    384     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    385     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
    386     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    387     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    388 
    389     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    390     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    391     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
    392     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    393     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    394 }
    395 
    396 }  // t7
    397 
    398 namespace t8
    399 {
    400 
    401 struct A1
    402 {
    403     char _[43981];
    404     virtual ~A1() {}
    405 
    406     A1* getA1() {return this;}
    407 };
    408 
    409 struct A2
    410 {
    411     char _[34981];
    412     virtual ~A2() {}
    413 
    414     A2* getA2() {return this;}
    415 };
    416 
    417 struct A3
    418     : private A1,
    419       public A2
    420 {
    421     char _[93481];
    422     virtual ~A3() {}
    423 
    424     A1* getA1() {return this;}
    425     A2* getA2() {return this;}
    426     A3* getA3() {return this;}
    427 };
    428 
    429 void test()
    430 {
    431     A1 a1;
    432     A2 a2;
    433     A3 a3;
    434     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    435     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    436     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    437     assert(dynamic_cast<A1*>(a3.getA2()) == 0);
    438 
    439     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    440     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    441     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    442     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    443     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    444 
    445     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    446     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    447     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    448     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    449     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    450 }
    451 
    452 }  // t8
    453 
    454 namespace t9
    455 {
    456 
    457 struct A1
    458 {
    459     char _[43981];
    460     virtual ~A1() {}
    461 
    462     A1* getA1() {return this;}
    463 };
    464 
    465 struct A2
    466 {
    467     char _[34981];
    468     virtual ~A2() {}
    469 
    470     A2* getA2() {return this;}
    471 };
    472 
    473 struct A3
    474     : private virtual A1,
    475       public A2
    476 {
    477     char _[93481];
    478     virtual ~A3() {}
    479 
    480     A1* getA1() {return this;}
    481     A2* getA2() {return this;}
    482     A3* getA3() {return this;}
    483 };
    484 
    485 void test()
    486 {
    487     A1 a1;
    488     A2 a2;
    489     A3 a3;
    490     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    491     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    492     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    493     assert(dynamic_cast<A1*>(a3.getA2()) == 0);
    494 
    495     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    496     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    497     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    498     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    499     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    500 
    501     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    502     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    503     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    504     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    505     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    506 }
    507 
    508 }  // t9
    509 
    510 namespace t10
    511 {
    512 
    513 struct A1
    514 {
    515     char _[43981];
    516     virtual ~A1() {}
    517 
    518     A1* getA1() {return this;}
    519 };
    520 
    521 struct A2
    522 {
    523     char _[34981];
    524     virtual ~A2() {}
    525 
    526     A2* getA2() {return this;}
    527 };
    528 
    529 struct A3
    530     : public virtual A1,
    531       public virtual A2
    532 {
    533     char _[93481];
    534     virtual ~A3() {}
    535 
    536     A1* getA1() {return this;}
    537     A2* getA2() {return this;}
    538     A3* getA3() {return this;}
    539 };
    540 
    541 void test()
    542 {
    543     A1 a1;
    544     A2 a2;
    545     A3 a3;
    546     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    547     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    548     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    549     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
    550     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
    551 
    552     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    553     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    554     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
    555     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    556     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    557 
    558     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    559     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    560     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
    561     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    562     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    563 }
    564 
    565 }  // t10
    566 
    567 namespace t11
    568 {
    569 
    570 struct A1
    571 {
    572     char _[43981];
    573     virtual ~A1() {}
    574 
    575     A1* getA1() {return this;}
    576 };
    577 
    578 struct A2
    579 {
    580     char _[34981];
    581     virtual ~A2() {}
    582 
    583     A2* getA2() {return this;}
    584 };
    585 
    586 struct A3
    587     : private A1,
    588       public virtual A2
    589 {
    590     char _[93481];
    591     virtual ~A3() {}
    592 
    593     A1* getA1() {return this;}
    594     A2* getA2() {return this;}
    595     A3* getA3() {return this;}
    596 };
    597 
    598 void test()
    599 {
    600     A1 a1;
    601     A2 a2;
    602     A3 a3;
    603     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    604     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    605     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    606     assert(dynamic_cast<A1*>(a3.getA2()) == 0);
    607 
    608     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    609     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    610     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    611     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    612     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    613 
    614     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    615     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    616     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    617     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    618     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    619 }
    620 
    621 }  // t11
    622 
    623 namespace t12
    624 {
    625 
    626 struct A1
    627 {
    628     char _[43981];
    629     virtual ~A1() {}
    630 
    631     A1* getA1() {return this;}
    632 };
    633 
    634 struct A2
    635 {
    636     char _[34981];
    637     virtual ~A2() {}
    638 
    639     A2* getA2() {return this;}
    640 };
    641 
    642 struct A3
    643     : private virtual A1,
    644       public virtual A2
    645 {
    646     char _[93481];
    647     virtual ~A3() {}
    648 
    649     A1* getA1() {return this;}
    650     A2* getA2() {return this;}
    651     A3* getA3() {return this;}
    652 };
    653 
    654 void test()
    655 {
    656     A1 a1;
    657     A2 a2;
    658     A3 a3;
    659     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    660     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    661     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    662     assert(dynamic_cast<A1*>(a3.getA2()) == 0);
    663 
    664     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    665     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    666     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    667     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    668     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    669 
    670     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    671     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    672     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    673     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    674     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    675 }
    676 
    677 }  // t12
    678 
    679 namespace t13
    680 {
    681 
    682 struct A1
    683 {
    684     char _[43981];
    685     virtual ~A1() {}
    686 
    687     A1* getA1() {return this;}
    688 };
    689 
    690 struct A2
    691 {
    692     char _[34981];
    693     virtual ~A2() {}
    694 
    695     A2* getA2() {return this;}
    696 };
    697 
    698 struct A3
    699     : private A1,
    700       private A2
    701 {
    702     char _[93481];
    703     virtual ~A3() {}
    704 
    705     A1* getA1() {return this;}
    706     A2* getA2() {return this;}
    707     A3* getA3() {return this;}
    708 };
    709 
    710 void test()
    711 {
    712     A1 a1;
    713     A2 a2;
    714     A3 a3;
    715     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    716     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    717     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    718     assert(dynamic_cast<A1*>(a3.getA2()) == 0);
    719 
    720     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    721     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    722     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    723     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    724 
    725     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    726     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    727     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    728     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
    729     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    730 }
    731 
    732 }  // t13
    733 
    734 namespace t14
    735 {
    736 
    737 struct A1
    738 {
    739     char _[43981];
    740     virtual ~A1() {}
    741 
    742     A1* getA1() {return this;}
    743 };
    744 
    745 struct A2
    746 {
    747     char _[34981];
    748     virtual ~A2() {}
    749 
    750     A2* getA2() {return this;}
    751 };
    752 
    753 struct A3
    754     : private virtual A1,
    755       private A2
    756 {
    757     char _[93481];
    758     virtual ~A3() {}
    759 
    760     A1* getA1() {return this;}
    761     A2* getA2() {return this;}
    762     A3* getA3() {return this;}
    763 };
    764 
    765 void test()
    766 {
    767     A1 a1;
    768     A2 a2;
    769     A3 a3;
    770     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    771     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    772     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    773     assert(dynamic_cast<A1*>(a3.getA2()) == 0);
    774 
    775     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    776     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    777     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    778     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    779 
    780     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    781     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    782     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    783     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
    784     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    785 }
    786 
    787 }  // t14
    788 
    789 namespace t15
    790 {
    791 
    792 struct A1
    793 {
    794     char _[43981];
    795     virtual ~A1() {}
    796 
    797     A1* getA1() {return this;}
    798 };
    799 
    800 struct A2
    801 {
    802     char _[34981];
    803     virtual ~A2() {}
    804 
    805     A2* getA2() {return this;}
    806 };
    807 
    808 struct A3
    809     : private virtual A1,
    810       private virtual A2
    811 {
    812     char _[93481];
    813     virtual ~A3() {}
    814 
    815     A1* getA1() {return this;}
    816     A2* getA2() {return this;}
    817     A3* getA3() {return this;}
    818 };
    819 
    820 void test()
    821 {
    822     A1 a1;
    823     A2 a2;
    824     A3 a3;
    825     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    826     assert(dynamic_cast<A1*>(a2.getA2()) == 0);
    827     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    828     assert(dynamic_cast<A1*>(a3.getA2()) == 0);
    829 
    830     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    831     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    832     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
    833     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    834 
    835     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    836     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    837     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
    838     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
    839     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    840 }
    841 
    842 }  // t15
    843 
    844 /*
    845 
    846 A1
    847 |
    848 A2
    849 |
    850 A3
    851 
    852 */
    853 
    854 namespace t16
    855 {
    856 
    857 struct A1
    858 {
    859     char _[43981];
    860     virtual ~A1() {}
    861 
    862     A1* getA1() {return this;}
    863 };
    864 
    865 struct A2
    866     : public A1
    867 {
    868     char _[34981];
    869     virtual ~A2() {}
    870 
    871     A1* getA1() {return this;}
    872     A2* getA2() {return this;}
    873 };
    874 
    875 struct A3
    876     : public A2
    877 {
    878     char _[93481];
    879     virtual ~A3() {}
    880 
    881     A1* getA1() {return this;}
    882     A2* getA2() {return this;}
    883     A3* getA3() {return this;}
    884 };
    885 
    886 void test()
    887 {
    888     A1 a1;
    889     A2 a2;
    890     A3 a3;
    891     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    892     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
    893     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
    894     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    895     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
    896     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
    897 
    898     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    899     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
    900     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    901     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
    902     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    903     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    904 
    905     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    906     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
    907     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    908     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
    909     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    910     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    911 }
    912 
    913 }  // t16
    914 
    915 namespace t17
    916 {
    917 
    918 struct A1
    919 {
    920     char _[43981];
    921     virtual ~A1() {}
    922 
    923     A1* getA1() {return this;}
    924 };
    925 
    926 struct A2
    927     : public virtual A1
    928 {
    929     char _[34981];
    930     virtual ~A2() {}
    931 
    932     A1* getA1() {return this;}
    933     A2* getA2() {return this;}
    934 };
    935 
    936 struct A3
    937     : public A2
    938 {
    939     char _[93481];
    940     virtual ~A3() {}
    941 
    942     A1* getA1() {return this;}
    943     A2* getA2() {return this;}
    944     A3* getA3() {return this;}
    945 };
    946 
    947 void test()
    948 {
    949     A1 a1;
    950     A2 a2;
    951     A3 a3;
    952     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
    953     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
    954     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
    955     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
    956     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
    957     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
    958 
    959     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
    960     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
    961     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
    962     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
    963     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
    964     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
    965 
    966     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
    967     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
    968     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
    969     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
    970     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
    971     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
    972 }
    973 
    974 }  // t17
    975 
    976 namespace t18
    977 {
    978 
    979 struct A1
    980 {
    981     char _[43981];
    982     virtual ~A1() {}
    983 
    984     A1* getA1() {return this;}
    985 };
    986 
    987 struct A2
    988     : private A1
    989 {
    990     char _[34981];
    991     virtual ~A2() {}
    992 
    993     A1* getA1() {return this;}
    994     A2* getA2() {return this;}
    995 };
    996 
    997 struct A3
    998     : public A2
    999 {
   1000     char _[93481];
   1001     virtual ~A3() {}
   1002 
   1003     A2* getA2() {return this;}
   1004     A3* getA3() {return this;}
   1005 };
   1006 
   1007 void test()
   1008 {
   1009     A1 a1;
   1010     A2 a2;
   1011     A3 a3;
   1012     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1013     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1014     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1015 
   1016     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1017     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1018     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1019     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   1020     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1021     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1022 
   1023     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1024     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1025     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1026     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   1027     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1028     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1029 }
   1030 
   1031 }  // t18
   1032 
   1033 namespace t19
   1034 {
   1035 
   1036 struct A1
   1037 {
   1038     char _[43981];
   1039     virtual ~A1() {}
   1040 
   1041     A1* getA1() {return this;}
   1042 };
   1043 
   1044 struct A2
   1045     : protected virtual A1
   1046 {
   1047     char _[34981];
   1048     virtual ~A2() {}
   1049 
   1050     A1* getA1() {return this;}
   1051     A2* getA2() {return this;}
   1052 };
   1053 
   1054 struct A3
   1055     : public A2
   1056 {
   1057     char _[93481];
   1058     virtual ~A3() {}
   1059 
   1060     A2* getA2() {return this;}
   1061     A3* getA3() {return this;}
   1062 };
   1063 
   1064 void test()
   1065 {
   1066     A1 a1;
   1067     A2 a2;
   1068     A3 a3;
   1069     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1070     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1071     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1072 
   1073     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1074     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1075     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1076     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   1077     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1078     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1079 
   1080     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1081     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1082     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1083     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   1084     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1085     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1086 }
   1087 
   1088 }  // t19
   1089 
   1090 namespace t20
   1091 {
   1092 
   1093 struct A1
   1094 {
   1095     char _[43981];
   1096     virtual ~A1() {}
   1097 
   1098     A1* getA1() {return this;}
   1099 };
   1100 
   1101 struct A2
   1102     : public virtual A1
   1103 {
   1104     char _[34981];
   1105     virtual ~A2() {}
   1106 
   1107     A1* getA1() {return this;}
   1108     A2* getA2() {return this;}
   1109 };
   1110 
   1111 struct A3
   1112     : public virtual A2
   1113 {
   1114     char _[93481];
   1115     virtual ~A3() {}
   1116 
   1117     A1* getA1() {return this;}
   1118     A2* getA2() {return this;}
   1119     A3* getA3() {return this;}
   1120 };
   1121 
   1122 void test()
   1123 {
   1124     A1 a1;
   1125     A2 a2;
   1126     A3 a3;
   1127     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1128     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1129     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   1130     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1131     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
   1132     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
   1133 
   1134     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1135     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   1136     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1137     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
   1138     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1139     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1140 
   1141     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1142     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1143     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1144     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
   1145     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1146     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1147 }
   1148 
   1149 }  // t20
   1150 
   1151 namespace t21
   1152 {
   1153 
   1154 struct A1
   1155 {
   1156     char _[43981];
   1157     virtual ~A1() {}
   1158 
   1159     A1* getA1() {return this;}
   1160 };
   1161 
   1162 struct A2
   1163     : private A1
   1164 {
   1165     char _[34981];
   1166     virtual ~A2() {}
   1167 
   1168     A1* getA1() {return this;}
   1169     A2* getA2() {return this;}
   1170 };
   1171 
   1172 struct A3
   1173     : public virtual A2
   1174 {
   1175     char _[93481];
   1176     virtual ~A3() {}
   1177 
   1178     A2* getA2() {return this;}
   1179     A3* getA3() {return this;}
   1180 };
   1181 
   1182 void test()
   1183 {
   1184     A1 a1;
   1185     A2 a2;
   1186     A3 a3;
   1187     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1188     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1189     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1190 
   1191     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1192     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1193     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1194     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   1195     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1196     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1197 
   1198     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1199     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1200     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1201     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   1202     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1203     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1204 }
   1205 
   1206 }  // t21
   1207 
   1208 namespace t22
   1209 {
   1210 
   1211 struct A1
   1212 {
   1213     char _[43981];
   1214     virtual ~A1() {}
   1215 
   1216     A1* getA1() {return this;}
   1217 };
   1218 
   1219 struct A2
   1220     : protected virtual A1
   1221 {
   1222     char _[34981];
   1223     virtual ~A2() {}
   1224 
   1225     A1* getA1() {return this;}
   1226     A2* getA2() {return this;}
   1227 };
   1228 
   1229 struct A3
   1230     : public virtual A2
   1231 {
   1232     char _[93481];
   1233     virtual ~A3() {}
   1234 
   1235     A2* getA2() {return this;}
   1236     A3* getA3() {return this;}
   1237 };
   1238 
   1239 void test()
   1240 {
   1241     A1 a1;
   1242     A2 a2;
   1243     A3 a3;
   1244     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1245     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1246     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1247 
   1248     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1249     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1250     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1251     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   1252     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1253     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1254 
   1255     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1256     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1257     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1258     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   1259     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1260     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1261 }
   1262 
   1263 }  // t22
   1264 
   1265 namespace t23
   1266 {
   1267 
   1268 struct A1
   1269 {
   1270     char _[43981];
   1271     virtual ~A1() {}
   1272 
   1273     A1* getA1() {return this;}
   1274 };
   1275 
   1276 struct A2
   1277     : private A1
   1278 {
   1279     char _[34981];
   1280     virtual ~A2() {}
   1281 
   1282     A1* getA1() {return this;}
   1283     A2* getA2() {return this;}
   1284 };
   1285 
   1286 struct A3
   1287     : private A2
   1288 {
   1289     char _[93481];
   1290     virtual ~A3() {}
   1291 
   1292     t23::A1* getA1() {return A2::getA1();}
   1293     A2* getA2() {return this;}
   1294     A3* getA3() {return this;}
   1295 };
   1296 
   1297 void test()
   1298 {
   1299     A1 a1;
   1300     A2 a2;
   1301     A3 a3;
   1302     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1303     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1304     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1305 
   1306     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1307     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1308     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1309     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   1310     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1311 
   1312     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1313     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1314     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1315     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   1316     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   1317     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1318 }
   1319 
   1320 }  // t23
   1321 
   1322 namespace t24
   1323 {
   1324 
   1325 struct A1
   1326 {
   1327     char _[43981];
   1328     virtual ~A1() {}
   1329 
   1330     A1* getA1() {return this;}
   1331 };
   1332 
   1333 struct A2
   1334     : protected virtual A1
   1335 {
   1336     char _[34981];
   1337     virtual ~A2() {}
   1338 
   1339     A1* getA1() {return this;}
   1340     A2* getA2() {return this;}
   1341 };
   1342 
   1343 struct A3
   1344     : private A2
   1345 {
   1346     char _[93481];
   1347     virtual ~A3() {}
   1348 
   1349     t24::A1* getA1() {return A2::getA1();}
   1350     A2* getA2() {return this;}
   1351     A3* getA3() {return this;}
   1352 };
   1353 
   1354 void test()
   1355 {
   1356     A1 a1;
   1357     A2 a2;
   1358     A3 a3;
   1359     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1360     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1361     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1362 
   1363     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1364     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1365     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1366     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   1367     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1368 
   1369     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1370     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1371     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1372     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   1373     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   1374     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1375 }
   1376 
   1377 }  // t24
   1378 
   1379 namespace t25
   1380 {
   1381 
   1382 struct A1
   1383 {
   1384     char _[43981];
   1385     virtual ~A1() {}
   1386 
   1387     A1* getA1() {return this;}
   1388 };
   1389 
   1390 struct A2
   1391     : protected virtual A1
   1392 {
   1393     char _[34981];
   1394     virtual ~A2() {}
   1395 
   1396     A1* getA1() {return this;}
   1397     A2* getA2() {return this;}
   1398 };
   1399 
   1400 struct A3
   1401     : private virtual A2
   1402 {
   1403     char _[93481];
   1404     virtual ~A3() {}
   1405 
   1406     t25::A1* getA1() {return A2::getA1();}
   1407     A2* getA2() {return this;}
   1408     A3* getA3() {return this;}
   1409 };
   1410 
   1411 void test()
   1412 {
   1413     A1 a1;
   1414     A2 a2;
   1415     A3 a3;
   1416     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1417     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1418     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1419 
   1420     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1421     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1422     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1423     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   1424     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1425 
   1426     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1427     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1428     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1429     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   1430     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   1431     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1432 }
   1433 
   1434 }  // t25
   1435 
   1436 /*
   1437 
   1438 A1 A1
   1439 |  |
   1440 A2 |
   1441  \ |
   1442   A3
   1443 
   1444 */
   1445 
   1446 namespace t26
   1447 {
   1448 
   1449 struct A1
   1450 {
   1451     char _[43981];
   1452     virtual ~A1() {}
   1453 
   1454     A1* getA1() {return this;}
   1455 };
   1456 
   1457 struct A2
   1458     : public A1
   1459 {
   1460     char _[34981];
   1461     virtual ~A2() {}
   1462 
   1463     A1* getA1() {return this;}
   1464     A2* getA2() {return this;}
   1465 };
   1466 
   1467 struct A3
   1468     : public A1,
   1469       public A2
   1470 {
   1471     char _[93481];
   1472     virtual ~A3() {}
   1473 
   1474     A1* getA12() {return A2::getA1();}
   1475     A2* getA2() {return this;}
   1476     A3* getA3() {return this;}
   1477 };
   1478 
   1479 void test()
   1480 {
   1481     A1 a1;
   1482     A2 a2;
   1483     A3 a3;
   1484     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1485     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1486     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   1487     assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());
   1488     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA12());
   1489 
   1490     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1491     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   1492     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1493     assert(dynamic_cast<A2*>(a3.getA12()) == a3.getA2());
   1494     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1495     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1496 
   1497     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1498     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1499     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1500     assert(dynamic_cast<A3*>(a3.getA12()) == a3.getA3());
   1501     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1502     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1503 }
   1504 
   1505 }  // t26
   1506 
   1507 namespace t27
   1508 {
   1509 
   1510 struct A1
   1511 {
   1512     char _[43981];
   1513     virtual ~A1() {}
   1514 
   1515     A1* getA1() {return this;}
   1516 };
   1517 
   1518 struct A2
   1519     : private A1
   1520 {
   1521     char _[34981];
   1522     virtual ~A2() {}
   1523 
   1524     A1* getA1() {return this;}
   1525     A2* getA2() {return this;}
   1526 };
   1527 
   1528 struct A3
   1529     : public A1,
   1530       public A2
   1531 {
   1532     char _[93481];
   1533     virtual ~A3() {}
   1534 
   1535     A1* getA12() {return A2::getA1();}
   1536     A2* getA2() {return this;}
   1537     A3* getA3() {return this;}
   1538 };
   1539 
   1540 void test()
   1541 {
   1542     A1 a1;
   1543     A2 a2;
   1544     A3 a3;
   1545     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1546     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1547     assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());
   1548 
   1549     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1550     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1551     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1552     assert(dynamic_cast<A2*>(a3.getA12()) == 0);
   1553     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1554     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1555 
   1556     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1557     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1558     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1559     assert(dynamic_cast<A3*>(a3.getA12()) == 0);
   1560     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1561     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1562 }
   1563 
   1564 }  // t27
   1565 
   1566 namespace t28
   1567 {
   1568 
   1569 struct A1
   1570 {
   1571     char _[43981];
   1572     virtual ~A1() {}
   1573 
   1574     A1* getA1() {return this;}
   1575 };
   1576 
   1577 struct A2
   1578     : public A1
   1579 {
   1580     char _[34981];
   1581     virtual ~A2() {}
   1582 
   1583     A1* getA1() {return this;}
   1584     A2* getA2() {return this;}
   1585 };
   1586 
   1587 struct A3
   1588     : private A1,
   1589       public A2
   1590 {
   1591     char _[93481];
   1592     virtual ~A3() {}
   1593 
   1594     A1* getA12() {return A2::getA1();}
   1595     A2* getA2() {return this;}
   1596     A3* getA3() {return this;}
   1597 };
   1598 
   1599 void test()
   1600 {
   1601     A1 a1;
   1602     A2 a2;
   1603     A3 a3;
   1604     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1605     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1606     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   1607     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA12());
   1608 
   1609     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1610     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   1611     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1612     assert(dynamic_cast<A2*>(a3.getA12()) == a3.getA2());
   1613     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1614     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1615 
   1616     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1617     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1618     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1619     assert(dynamic_cast<A3*>(a3.getA12()) == a3.getA3());
   1620     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1621     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1622 }
   1623 
   1624 }  // t28
   1625 
   1626 namespace t29
   1627 {
   1628 
   1629 struct A1
   1630 {
   1631     char _[43981];
   1632     virtual ~A1() {}
   1633 
   1634     A1* getA1() {return this;}
   1635 };
   1636 
   1637 struct A2
   1638     : public A1
   1639 {
   1640     char _[34981];
   1641     virtual ~A2() {}
   1642 
   1643     A1* getA1() {return this;}
   1644     A2* getA2() {return this;}
   1645 };
   1646 
   1647 struct A3
   1648     : public A1,
   1649       private A2
   1650 {
   1651     char _[93481];
   1652     virtual ~A3() {}
   1653 
   1654     A1* getA12() {return A2::getA1();}
   1655     A2* getA2() {return this;}
   1656     A3* getA3() {return this;}
   1657 };
   1658 
   1659 void test()
   1660 {
   1661     A1 a1;
   1662     A2 a2;
   1663     A3 a3;
   1664     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1665     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1666     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   1667     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA12());
   1668 
   1669     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1670     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   1671     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1672     assert(dynamic_cast<A2*>(a3.getA12()) == a3.getA2());
   1673     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1674 
   1675     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1676     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1677     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1678     assert(dynamic_cast<A3*>(a3.getA12()) == 0);
   1679     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   1680     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1681 }
   1682 
   1683 }  // t29
   1684 
   1685 namespace t30
   1686 {
   1687 
   1688 struct A1
   1689 {
   1690     char _[43981];
   1691     virtual ~A1() {}
   1692 
   1693     A1* getA1() {return this;}
   1694 };
   1695 
   1696 struct A2
   1697     : public A1
   1698 {
   1699     char _[34981];
   1700     virtual ~A2() {}
   1701 
   1702     A1* getA1() {return this;}
   1703     A2* getA2() {return this;}
   1704 };
   1705 
   1706 struct A3
   1707     : private A1,
   1708       private A2
   1709 {
   1710     char _[93481];
   1711     virtual ~A3() {}
   1712 
   1713     A1* getA12() {return A2::getA1();}
   1714     A2* getA2() {return this;}
   1715     A3* getA3() {return this;}
   1716 };
   1717 
   1718 void test()
   1719 {
   1720     A1 a1;
   1721     A2 a2;
   1722     A3 a3;
   1723     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1724     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1725     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   1726     assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());
   1727     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA12());
   1728 
   1729     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1730     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   1731     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1732     assert(dynamic_cast<A2*>(a3.getA12()) == a3.getA2());
   1733     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1734 
   1735     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1736     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1737     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1738     assert(dynamic_cast<A3*>(a3.getA12()) == 0);
   1739     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   1740     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1741 }
   1742 
   1743 }  // t30
   1744 
   1745 namespace t31
   1746 {
   1747 
   1748 struct A1
   1749 {
   1750     char _[43981];
   1751     virtual ~A1() {}
   1752 
   1753     A1* getA1() {return this;}
   1754 };
   1755 
   1756 struct A2
   1757     : private A1
   1758 {
   1759     char _[34981];
   1760     virtual ~A2() {}
   1761 
   1762     A1* getA1() {return this;}
   1763     A2* getA2() {return this;}
   1764 };
   1765 
   1766 struct A3
   1767     : public A1,
   1768       private A2
   1769 {
   1770     char _[93481];
   1771     virtual ~A3() {}
   1772 
   1773     A1* getA12() {return A2::getA1();}
   1774     A2* getA2() {return this;}
   1775     A3* getA3() {return this;}
   1776 };
   1777 
   1778 void test()
   1779 {
   1780     A1 a1;
   1781     A2 a2;
   1782     A3 a3;
   1783     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1784     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1785     assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());
   1786 
   1787     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1788     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1789     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1790     assert(dynamic_cast<A2*>(a3.getA12()) == 0);
   1791     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1792 
   1793     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1794     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1795     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1796     assert(dynamic_cast<A3*>(a3.getA12()) == 0);
   1797     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   1798     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1799 }
   1800 
   1801 }  // t31
   1802 
   1803 namespace t32
   1804 {
   1805 
   1806 struct A1
   1807 {
   1808     char _[43981];
   1809     virtual ~A1() {}
   1810 
   1811     A1* getA1() {return this;}
   1812 };
   1813 
   1814 struct A2
   1815     : private A1
   1816 {
   1817     char _[34981];
   1818     virtual ~A2() {}
   1819 
   1820     A1* getA1() {return this;}
   1821     A2* getA2() {return this;}
   1822 };
   1823 
   1824 struct A3
   1825     : private A1,
   1826       public A2
   1827 {
   1828     char _[93481];
   1829     virtual ~A3() {}
   1830 
   1831     A1* getA12() {return A2::getA1();}
   1832     A2* getA2() {return this;}
   1833     A3* getA3() {return this;}
   1834 };
   1835 
   1836 void test()
   1837 {
   1838     A1 a1;
   1839     A2 a2;
   1840     A3 a3;
   1841     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1842     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1843     assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());
   1844 
   1845     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1846     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1847     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1848     assert(dynamic_cast<A2*>(a3.getA12()) == 0);
   1849     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1850 
   1851     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1852     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1853     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1854     assert(dynamic_cast<A3*>(a3.getA12()) == 0);
   1855     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1856     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1857 }
   1858 
   1859 }  // t32
   1860 
   1861 namespace t33
   1862 {
   1863 
   1864 struct A1
   1865 {
   1866     char _[43981];
   1867     virtual ~A1() {}
   1868 
   1869     A1* getA1() {return this;}
   1870 };
   1871 
   1872 struct A2
   1873     : private A1
   1874 {
   1875     char _[34981];
   1876     virtual ~A2() {}
   1877 
   1878     A1* getA1() {return this;}
   1879     A2* getA2() {return this;}
   1880 };
   1881 
   1882 struct A3
   1883     : private A1,
   1884       private A2
   1885 {
   1886     char _[93481];
   1887     virtual ~A3() {}
   1888 
   1889     A1* getA12() {return A2::getA1();}
   1890     A2* getA2() {return this;}
   1891     A3* getA3() {return this;}
   1892 };
   1893 
   1894 void test()
   1895 {
   1896     A1 a1;
   1897     A2 a2;
   1898     A3 a3;
   1899     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1900     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1901     assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());
   1902 
   1903     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1904     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   1905     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1906     assert(dynamic_cast<A2*>(a3.getA12()) == 0);
   1907     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1908 
   1909     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1910     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1911     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1912     assert(dynamic_cast<A3*>(a3.getA12()) == 0);
   1913     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   1914     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1915 }
   1916 
   1917 }  // t33
   1918 
   1919 /*
   1920 
   1921 A1
   1922 | \
   1923 A2 \
   1924  \ |
   1925   A3
   1926 
   1927 */
   1928 
   1929 namespace t34
   1930 {
   1931 
   1932 struct A1
   1933 {
   1934     char _[43981];
   1935     virtual ~A1() {}
   1936 
   1937     A1* getA1() {return this;}
   1938 };
   1939 
   1940 struct A2
   1941     : public virtual A1
   1942 {
   1943     char _[34981];
   1944     virtual ~A2() {}
   1945 
   1946     A1* getA1() {return this;}
   1947     A2* getA2() {return this;}
   1948 };
   1949 
   1950 struct A3
   1951     : public virtual A1,
   1952       public A2
   1953 {
   1954     char _[93481];
   1955     virtual ~A3() {}
   1956 
   1957     A1* getA1() {return A1::getA1();}
   1958     A2* getA2() {return this;}
   1959     A3* getA3() {return this;}
   1960 };
   1961 
   1962 void test()
   1963 {
   1964     A1 a1;
   1965     A2 a2;
   1966     A3 a3;
   1967     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   1968     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   1969     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   1970     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   1971     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
   1972     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
   1973 
   1974     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   1975     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   1976     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   1977     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
   1978     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   1979     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   1980 
   1981     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   1982     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   1983     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   1984     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
   1985     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   1986     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   1987 }
   1988 
   1989 }  // t34
   1990 
   1991 namespace t35
   1992 {
   1993 
   1994 struct A1
   1995 {
   1996     char _[43981];
   1997     virtual ~A1() {}
   1998 
   1999     A1* getA1() {return this;}
   2000 };
   2001 
   2002 struct A2
   2003     : private virtual A1
   2004 {
   2005     char _[34981];
   2006     virtual ~A2() {}
   2007 
   2008     A1* getA1() {return this;}
   2009     A2* getA2() {return this;}
   2010 };
   2011 
   2012 struct A3
   2013     : public virtual A1,
   2014       public A2
   2015 {
   2016     char _[93481];
   2017     virtual ~A3() {}
   2018 
   2019     A1* getA1() {return A1::getA1();}
   2020     A2* getA2() {return this;}
   2021     A3* getA3() {return this;}
   2022 };
   2023 
   2024 void test()
   2025 {
   2026     A1 a1;
   2027     A2 a2;
   2028     A3 a3;
   2029     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   2030     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   2031     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   2032     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
   2033 
   2034     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   2035     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   2036     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   2037     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
   2038     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   2039     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   2040 
   2041     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   2042     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   2043     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   2044     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
   2045     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   2046     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   2047 }
   2048 
   2049 }  // t35
   2050 
   2051 namespace t36
   2052 {
   2053 
   2054 struct A1
   2055 {
   2056     char _[43981];
   2057     virtual ~A1() {}
   2058 
   2059     A1* getA1() {return this;}
   2060 };
   2061 
   2062 struct A2
   2063     : public virtual A1
   2064 {
   2065     char _[34981];
   2066     virtual ~A2() {}
   2067 
   2068     A1* getA1() {return this;}
   2069     A2* getA2() {return this;}
   2070 };
   2071 
   2072 struct A3
   2073     : private virtual A1,
   2074       public A2
   2075 {
   2076     char _[93481];
   2077     virtual ~A3() {}
   2078 
   2079     A1* getA1() {return A1::getA1();}
   2080     A2* getA2() {return this;}
   2081     A3* getA3() {return this;}
   2082 };
   2083 
   2084 void test()
   2085 {
   2086     A1 a1;
   2087     A2 a2;
   2088     A3 a3;
   2089     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   2090     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   2091     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   2092     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   2093     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
   2094     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
   2095 
   2096     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   2097     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   2098     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   2099     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
   2100     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   2101     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   2102 
   2103     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   2104     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   2105     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   2106     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
   2107     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   2108     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   2109 }
   2110 
   2111 }  // t36
   2112 
   2113 namespace t37
   2114 {
   2115 
   2116 struct A1
   2117 {
   2118     char _[43981];
   2119     virtual ~A1() {}
   2120 
   2121     A1* getA1() {return this;}
   2122 };
   2123 
   2124 struct A2
   2125     : public virtual A1
   2126 {
   2127     char _[34981];
   2128     virtual ~A2() {}
   2129 
   2130     A1* getA1() {return this;}
   2131     A2* getA2() {return this;}
   2132 };
   2133 
   2134 struct A3
   2135     : public virtual A1,
   2136       private A2
   2137 {
   2138     char _[93481];
   2139     virtual ~A3() {}
   2140 
   2141     A1* getA1() {return A1::getA1();}
   2142     A2* getA2() {return this;}
   2143     A3* getA3() {return this;}
   2144 };
   2145 
   2146 void test()
   2147 {
   2148     A1 a1;
   2149     A2 a2;
   2150     A3 a3;
   2151     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   2152     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   2153     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   2154     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   2155     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
   2156     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
   2157 
   2158     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   2159     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   2160     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   2161     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
   2162     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   2163 
   2164     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   2165     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   2166     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   2167     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
   2168     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   2169     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   2170 }
   2171 
   2172 }  // t37
   2173 
   2174 namespace t38
   2175 {
   2176 
   2177 struct A1
   2178 {
   2179     char _[43981];
   2180     virtual ~A1() {}
   2181 
   2182     A1* getA1() {return this;}
   2183 };
   2184 
   2185 struct A2
   2186     : public virtual A1
   2187 {
   2188     char _[34981];
   2189     virtual ~A2() {}
   2190 
   2191     A1* getA1() {return this;}
   2192     A2* getA2() {return this;}
   2193 };
   2194 
   2195 struct A3
   2196     : private virtual A1,
   2197       private A2
   2198 {
   2199     char _[93481];
   2200     virtual ~A3() {}
   2201 
   2202     A1* getA1() {return A1::getA1();}
   2203     A2* getA2() {return this;}
   2204     A3* getA3() {return this;}
   2205 };
   2206 
   2207 void test()
   2208 {
   2209     A1 a1;
   2210     A2 a2;
   2211     A3 a3;
   2212     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   2213     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   2214     assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());
   2215     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   2216     assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());
   2217 
   2218     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   2219     assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());
   2220     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   2221     assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());
   2222     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   2223 
   2224     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   2225     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   2226     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   2227     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   2228     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   2229     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   2230 }
   2231 
   2232 }  // t38
   2233 
   2234 namespace t39
   2235 {
   2236 
   2237 struct A1
   2238 {
   2239     char _[43981];
   2240     virtual ~A1() {}
   2241 
   2242     A1* getA1() {return this;}
   2243 };
   2244 
   2245 struct A2
   2246     : private virtual A1
   2247 {
   2248     char _[34981];
   2249     virtual ~A2() {}
   2250 
   2251     A1* getA1() {return this;}
   2252     A2* getA2() {return this;}
   2253 };
   2254 
   2255 struct A3
   2256     : public virtual A1,
   2257       private A2
   2258 {
   2259     char _[93481];
   2260     virtual ~A3() {}
   2261 
   2262     A1* getA1() {return A1::getA1();}
   2263     A2* getA2() {return this;}
   2264     A3* getA3() {return this;}
   2265 };
   2266 
   2267 void test()
   2268 {
   2269     A1 a1;
   2270     A2 a2;
   2271     A3 a3;
   2272     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   2273     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   2274     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   2275     assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());
   2276 
   2277     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   2278     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   2279     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   2280     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   2281     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   2282 
   2283     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   2284     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   2285     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   2286     assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());
   2287     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   2288     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   2289 }
   2290 
   2291 }  // t39
   2292 
   2293 namespace t40
   2294 {
   2295 
   2296 struct A1
   2297 {
   2298     char _[43981];
   2299     virtual ~A1() {}
   2300 
   2301     A1* getA1() {return this;}
   2302 };
   2303 
   2304 struct A2
   2305     : private virtual A1
   2306 {
   2307     char _[34981];
   2308     virtual ~A2() {}
   2309 
   2310     A1* getA1() {return this;}
   2311     A2* getA2() {return this;}
   2312 };
   2313 
   2314 struct A3
   2315     : private virtual A1,
   2316       public A2
   2317 {
   2318     char _[93481];
   2319     virtual ~A3() {}
   2320 
   2321     A1* getA1() {return A1::getA1();}
   2322     A2* getA2() {return this;}
   2323     A3* getA3() {return this;}
   2324 };
   2325 
   2326 void test()
   2327 {
   2328     A1 a1;
   2329     A2 a2;
   2330     A3 a3;
   2331     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   2332     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   2333     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   2334 
   2335     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   2336     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   2337     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   2338     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   2339     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   2340     assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());
   2341 
   2342     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   2343     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   2344     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   2345     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   2346     assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());
   2347     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   2348 }
   2349 
   2350 }  // t40
   2351 
   2352 namespace t41
   2353 {
   2354 
   2355 struct A1
   2356 {
   2357     char _[43981];
   2358     virtual ~A1() {}
   2359 
   2360     A1* getA1() {return this;}
   2361 };
   2362 
   2363 struct A2
   2364     : private virtual A1
   2365 {
   2366     char _[34981];
   2367     virtual ~A2() {}
   2368 
   2369     A1* getA1() {return this;}
   2370     A2* getA2() {return this;}
   2371 };
   2372 
   2373 struct A3
   2374     : private virtual A1,
   2375       private A2
   2376 {
   2377     char _[93481];
   2378     virtual ~A3() {}
   2379 
   2380     A1* getA1() {return A1::getA1();}
   2381     A2* getA2() {return this;}
   2382     A3* getA3() {return this;}
   2383 };
   2384 
   2385 void test()
   2386 {
   2387     A1 a1;
   2388     A2 a2;
   2389     A3 a3;
   2390     assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());
   2391     assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());
   2392     assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());
   2393 
   2394     assert(dynamic_cast<A2*>(a1.getA1()) == 0);
   2395     assert(dynamic_cast<A2*>(a2.getA1()) == 0);
   2396     assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());
   2397     assert(dynamic_cast<A2*>(a3.getA1()) == 0);
   2398     assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());
   2399 
   2400     assert(dynamic_cast<A3*>(a1.getA1()) == 0);
   2401     assert(dynamic_cast<A3*>(a2.getA1()) == 0);
   2402     assert(dynamic_cast<A3*>(a2.getA2()) == 0);
   2403     assert(dynamic_cast<A3*>(a3.getA1()) == 0);
   2404     assert(dynamic_cast<A3*>(a3.getA2()) == 0);
   2405     assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());
   2406 }
   2407 
   2408 }  // t41
   2409 
   2410 int main()
   2411 {
   2412     timer t;
   2413     t1::test();
   2414     t2::test();
   2415     t3::test();
   2416     t4::test();
   2417     t5::test();
   2418     t6::test();
   2419     t7::test();
   2420     t8::test();
   2421     t9::test();
   2422     t10::test();
   2423     t11::test();
   2424     t12::test();
   2425     t13::test();
   2426     t14::test();
   2427     t15::test();
   2428     t16::test();
   2429     t17::test();
   2430     t18::test();
   2431     t19::test();
   2432     t20::test();
   2433     t21::test();
   2434     t22::test();
   2435     t23::test();
   2436     t24::test();
   2437     t25::test();
   2438     t26::test();
   2439     t27::test();
   2440     t28::test();
   2441     t29::test();
   2442     t30::test();
   2443     t31::test();
   2444     t32::test();
   2445     t33::test();
   2446     t34::test();
   2447     t35::test();
   2448     t36::test();
   2449     t37::test();
   2450     t38::test();
   2451     t39::test();
   2452     t40::test();
   2453     t41::test();
   2454 }
   2455