llvm-project
2463 строки · 51.4 Кб
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include <cassert>10#include "support/timer.h"11
12// This test explicitly tests dynamic cast with types that have inaccessible
13// bases.
14#if defined(__clang__)15# pragma clang diagnostic ignored "-Winaccessible-base"16#elif defined(__GNUC__)17# pragma GCC diagnostic ignored "-Winaccessible-base"18#endif19
20/*
21
22A1 A2 A3
23
24*/
25
26namespace t127{
28
29struct A130{
31char _[43981];32virtual ~A1() {}33
34A1* getA1() {return this;}35};36
37struct A238{
39char _[34981];40virtual ~A2() {}41
42A2* getA2() {return this;}43};44
45struct A346{
47char _[93481];48virtual ~A3() {}49
50A3* getA3() {return this;}51};52
53void test()54{
55A1 a1;56A2 a2;57A3 a3;58assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());59assert(dynamic_cast<A1*>(a2.getA2()) == 0);60assert(dynamic_cast<A1*>(a3.getA3()) == 0);61assert(dynamic_cast<A2*>(a1.getA1()) == 0);62assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());63assert(dynamic_cast<A2*>(a3.getA3()) == 0);64assert(dynamic_cast<A3*>(a1.getA1()) == 0);65assert(dynamic_cast<A3*>(a2.getA2()) == 0);66assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());67}
68
69} // t170
71/*
72
73A1 A2
74|
75A3
76
77*/
78
79namespace t280{
81
82struct A183{
84char _[43981];85virtual ~A1() {}86
87A1* getA1() {return this;}88};89
90struct A291{
92char _[34981];93virtual ~A2() {}94
95A2* getA2() {return this;}96};97
98struct A399: public A1100{
101char _[93481];102virtual ~A3() {}103
104A3* getA3() {return this;}105};106
107void test()108{
109A1 a1;110A2 a2;111A3 a3;112assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());113assert(dynamic_cast<A1*>(a2.getA2()) == 0);114assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());115assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());116
117assert(dynamic_cast<A2*>(a1.getA1()) == 0);118assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());119assert(dynamic_cast<A2*>(a3.getA1()) == 0);120assert(dynamic_cast<A2*>(a3.getA3()) == 0);121
122assert(dynamic_cast<A3*>(a1.getA1()) == 0);123assert(dynamic_cast<A3*>(a2.getA2()) == 0);124assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());125assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());126}
127
128} // t2129
130namespace t3131{
132
133struct A1134{
135char _[43981];136virtual ~A1() {}137
138A1* getA1() {return this;}139};140
141struct A2142{
143char _[34981];144virtual ~A2() {}145
146A2* getA2() {return this;}147};148
149struct A3150: public virtual A1151{
152char _[93481];153virtual ~A3() {}154
155A3* getA3() {return this;}156};157
158void test()159{
160A1 a1;161A2 a2;162A3 a3;163assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());164assert(dynamic_cast<A1*>(a2.getA2()) == 0);165assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());166assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());167
168assert(dynamic_cast<A2*>(a1.getA1()) == 0);169assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());170assert(dynamic_cast<A2*>(a3.getA1()) == 0);171assert(dynamic_cast<A2*>(a3.getA3()) == 0);172
173assert(dynamic_cast<A3*>(a1.getA1()) == 0);174assert(dynamic_cast<A3*>(a2.getA2()) == 0);175assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());176assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());177}
178
179} // t3180
181namespace t4182{
183
184struct A1185{
186char _[43981];187virtual ~A1() {}188
189A1* getA1() {return this;}190};191
192struct A2193{
194char _[34981];195virtual ~A2() {}196
197A2* getA2() {return this;}198};199
200struct A3201: private A1202{
203char _[93481];204virtual ~A3() {}205
206A1* getA1() {return this;}207A3* getA3() {return this;}208};209
210void test()211{
212A1 a1;213A2 a2;214A3 a3;215assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());216assert(dynamic_cast<A1*>(a2.getA2()) == 0);217assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());218
219assert(dynamic_cast<A2*>(a1.getA1()) == 0);220assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());221assert(dynamic_cast<A2*>(a3.getA1()) == 0);222assert(dynamic_cast<A2*>(a3.getA3()) == 0);223
224assert(dynamic_cast<A3*>(a1.getA1()) == 0);225assert(dynamic_cast<A3*>(a2.getA2()) == 0);226assert(dynamic_cast<A3*>(a3.getA1()) == 0);227assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());228}
229
230} // t4231
232namespace t5233{
234
235struct A1236{
237char _[43981];238virtual ~A1() {}239
240A1* getA1() {return this;}241};242
243struct A2244{
245char _[34981];246virtual ~A2() {}247
248A2* getA2() {return this;}249};250
251struct A3252: private virtual A1253{
254char _[93481];255virtual ~A3() {}256
257A1* getA1() {return this;}258A3* getA3() {return this;}259};260
261void test()262{
263A1 a1;264A2 a2;265A3 a3;266assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());267assert(dynamic_cast<A1*>(a2.getA2()) == 0);268assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());269
270assert(dynamic_cast<A2*>(a1.getA1()) == 0);271assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());272assert(dynamic_cast<A2*>(a3.getA1()) == 0);273assert(dynamic_cast<A2*>(a3.getA3()) == 0);274
275assert(dynamic_cast<A3*>(a1.getA1()) == 0);276assert(dynamic_cast<A3*>(a2.getA2()) == 0);277assert(dynamic_cast<A3*>(a3.getA1()) == 0);278assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());279}
280
281} // t5282
283/*
284
285A1 A2
286\ /
287A3
288
289*/
290
291namespace t6292{
293
294struct A1295{
296char _[43981];297virtual ~A1() {}298
299A1* getA1() {return this;}300};301
302struct A2303{
304char _[34981];305virtual ~A2() {}306
307A2* getA2() {return this;}308};309
310struct A3311: public A1,312public A2313{
314char _[93481];315virtual ~A3() {}316
317A1* getA1() {return this;}318A2* getA2() {return this;}319A3* getA3() {return this;}320};321
322void test()323{
324A1 a1;325A2 a2;326A3 a3;327assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());328assert(dynamic_cast<A1*>(a2.getA2()) == 0);329assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());330assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());331assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());332
333assert(dynamic_cast<A2*>(a1.getA1()) == 0);334assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());335assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());336assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());337assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());338
339assert(dynamic_cast<A3*>(a1.getA1()) == 0);340assert(dynamic_cast<A3*>(a2.getA2()) == 0);341assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());342assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());343assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());344}
345
346} // t6347
348namespace t7349{
350
351struct A1352{
353char _[43981];354virtual ~A1() {}355
356A1* getA1() {return this;}357};358
359struct A2360{
361char _[34981];362virtual ~A2() {}363
364A2* getA2() {return this;}365};366
367struct A3368: public virtual A1,369public A2370{
371char _[93481];372virtual ~A3() {}373
374A1* getA1() {return this;}375A2* getA2() {return this;}376A3* getA3() {return this;}377};378
379void test()380{
381A1 a1;382A2 a2;383A3 a3;384assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());385assert(dynamic_cast<A1*>(a2.getA2()) == 0);386assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());387assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());388assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());389
390assert(dynamic_cast<A2*>(a1.getA1()) == 0);391assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());392assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());393assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());394assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());395
396assert(dynamic_cast<A3*>(a1.getA1()) == 0);397assert(dynamic_cast<A3*>(a2.getA2()) == 0);398assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());399assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());400assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());401}
402
403} // t7404
405namespace t8406{
407
408struct A1409{
410char _[43981];411virtual ~A1() {}412
413A1* getA1() {return this;}414};415
416struct A2417{
418char _[34981];419virtual ~A2() {}420
421A2* getA2() {return this;}422};423
424struct A3425: private A1,426public A2427{
428char _[93481];429virtual ~A3() {}430
431A1* getA1() {return this;}432A2* getA2() {return this;}433A3* getA3() {return this;}434};435
436void test()437{
438A1 a1;439A2 a2;440A3 a3;441assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());442assert(dynamic_cast<A1*>(a2.getA2()) == 0);443assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());444assert(dynamic_cast<A1*>(a3.getA2()) == 0);445
446assert(dynamic_cast<A2*>(a1.getA1()) == 0);447assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());448assert(dynamic_cast<A2*>(a3.getA1()) == 0);449assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());450assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());451
452assert(dynamic_cast<A3*>(a1.getA1()) == 0);453assert(dynamic_cast<A3*>(a2.getA2()) == 0);454assert(dynamic_cast<A3*>(a3.getA1()) == 0);455assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());456assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());457}
458
459} // t8460
461namespace t9462{
463
464struct A1465{
466char _[43981];467virtual ~A1() {}468
469A1* getA1() {return this;}470};471
472struct A2473{
474char _[34981];475virtual ~A2() {}476
477A2* getA2() {return this;}478};479
480struct A3481: private virtual A1,482public A2483{
484char _[93481];485virtual ~A3() {}486
487A1* getA1() {return this;}488A2* getA2() {return this;}489A3* getA3() {return this;}490};491
492void test()493{
494A1 a1;495A2 a2;496A3 a3;497assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());498assert(dynamic_cast<A1*>(a2.getA2()) == 0);499assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());500assert(dynamic_cast<A1*>(a3.getA2()) == 0);501
502assert(dynamic_cast<A2*>(a1.getA1()) == 0);503assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());504assert(dynamic_cast<A2*>(a3.getA1()) == 0);505assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());506assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());507
508assert(dynamic_cast<A3*>(a1.getA1()) == 0);509assert(dynamic_cast<A3*>(a2.getA2()) == 0);510assert(dynamic_cast<A3*>(a3.getA1()) == 0);511assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());512assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());513}
514
515} // t9516
517namespace t10518{
519
520struct A1521{
522char _[43981];523virtual ~A1() {}524
525A1* getA1() {return this;}526};527
528struct A2529{
530char _[34981];531virtual ~A2() {}532
533A2* getA2() {return this;}534};535
536struct A3537: public virtual A1,538public virtual A2539{
540char _[93481];541virtual ~A3() {}542
543A1* getA1() {return this;}544A2* getA2() {return this;}545A3* getA3() {return this;}546};547
548void test()549{
550A1 a1;551A2 a2;552A3 a3;553assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());554assert(dynamic_cast<A1*>(a2.getA2()) == 0);555assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());556assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());557assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());558
559assert(dynamic_cast<A2*>(a1.getA1()) == 0);560assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());561assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());562assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());563assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());564
565assert(dynamic_cast<A3*>(a1.getA1()) == 0);566assert(dynamic_cast<A3*>(a2.getA2()) == 0);567assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());568assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());569assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());570}
571
572} // t10573
574namespace t11575{
576
577struct A1578{
579char _[43981];580virtual ~A1() {}581
582A1* getA1() {return this;}583};584
585struct A2586{
587char _[34981];588virtual ~A2() {}589
590A2* getA2() {return this;}591};592
593struct A3594: private A1,595public virtual A2596{
597char _[93481];598virtual ~A3() {}599
600A1* getA1() {return this;}601A2* getA2() {return this;}602A3* getA3() {return this;}603};604
605void test()606{
607A1 a1;608A2 a2;609A3 a3;610assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());611assert(dynamic_cast<A1*>(a2.getA2()) == 0);612assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());613assert(dynamic_cast<A1*>(a3.getA2()) == 0);614
615assert(dynamic_cast<A2*>(a1.getA1()) == 0);616assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());617assert(dynamic_cast<A2*>(a3.getA1()) == 0);618assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());619assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());620
621assert(dynamic_cast<A3*>(a1.getA1()) == 0);622assert(dynamic_cast<A3*>(a2.getA2()) == 0);623assert(dynamic_cast<A3*>(a3.getA1()) == 0);624assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());625assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());626}
627
628} // t11629
630namespace t12631{
632
633struct A1634{
635char _[43981];636virtual ~A1() {}637
638A1* getA1() {return this;}639};640
641struct A2642{
643char _[34981];644virtual ~A2() {}645
646A2* getA2() {return this;}647};648
649struct A3650: private virtual A1,651public virtual A2652{
653char _[93481];654virtual ~A3() {}655
656A1* getA1() {return this;}657A2* getA2() {return this;}658A3* getA3() {return this;}659};660
661void test()662{
663A1 a1;664A2 a2;665A3 a3;666assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());667assert(dynamic_cast<A1*>(a2.getA2()) == 0);668assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());669assert(dynamic_cast<A1*>(a3.getA2()) == 0);670
671assert(dynamic_cast<A2*>(a1.getA1()) == 0);672assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());673assert(dynamic_cast<A2*>(a3.getA1()) == 0);674assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());675assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());676
677assert(dynamic_cast<A3*>(a1.getA1()) == 0);678assert(dynamic_cast<A3*>(a2.getA2()) == 0);679assert(dynamic_cast<A3*>(a3.getA1()) == 0);680assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());681assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());682}
683
684} // t12685
686namespace t13687{
688
689struct A1690{
691char _[43981];692virtual ~A1() {}693
694A1* getA1() {return this;}695};696
697struct A2698{
699char _[34981];700virtual ~A2() {}701
702A2* getA2() {return this;}703};704
705struct A3706: private A1,707private A2708{
709char _[93481];710virtual ~A3() {}711
712A1* getA1() {return this;}713A2* getA2() {return this;}714A3* getA3() {return this;}715};716
717void test()718{
719A1 a1;720A2 a2;721A3 a3;722assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());723assert(dynamic_cast<A1*>(a2.getA2()) == 0);724assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());725assert(dynamic_cast<A1*>(a3.getA2()) == 0);726
727assert(dynamic_cast<A2*>(a1.getA1()) == 0);728assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());729assert(dynamic_cast<A2*>(a3.getA1()) == 0);730assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());731
732assert(dynamic_cast<A3*>(a1.getA1()) == 0);733assert(dynamic_cast<A3*>(a2.getA2()) == 0);734assert(dynamic_cast<A3*>(a3.getA1()) == 0);735assert(dynamic_cast<A3*>(a3.getA2()) == 0);736assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());737}
738
739} // t13740
741namespace t14742{
743
744struct A1745{
746char _[43981];747virtual ~A1() {}748
749A1* getA1() {return this;}750};751
752struct A2753{
754char _[34981];755virtual ~A2() {}756
757A2* getA2() {return this;}758};759
760struct A3761: private virtual A1,762private A2763{
764char _[93481];765virtual ~A3() {}766
767A1* getA1() {return this;}768A2* getA2() {return this;}769A3* getA3() {return this;}770};771
772void test()773{
774A1 a1;775A2 a2;776A3 a3;777assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());778assert(dynamic_cast<A1*>(a2.getA2()) == 0);779assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());780assert(dynamic_cast<A1*>(a3.getA2()) == 0);781
782assert(dynamic_cast<A2*>(a1.getA1()) == 0);783assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());784assert(dynamic_cast<A2*>(a3.getA1()) == 0);785assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());786
787assert(dynamic_cast<A3*>(a1.getA1()) == 0);788assert(dynamic_cast<A3*>(a2.getA2()) == 0);789assert(dynamic_cast<A3*>(a3.getA1()) == 0);790assert(dynamic_cast<A3*>(a3.getA2()) == 0);791assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());792}
793
794} // t14795
796namespace t15797{
798
799struct A1800{
801char _[43981];802virtual ~A1() {}803
804A1* getA1() {return this;}805};806
807struct A2808{
809char _[34981];810virtual ~A2() {}811
812A2* getA2() {return this;}813};814
815struct A3816: private virtual A1,817private virtual A2818{
819char _[93481];820virtual ~A3() {}821
822A1* getA1() {return this;}823A2* getA2() {return this;}824A3* getA3() {return this;}825};826
827void test()828{
829A1 a1;830A2 a2;831A3 a3;832assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());833assert(dynamic_cast<A1*>(a2.getA2()) == 0);834assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());835assert(dynamic_cast<A1*>(a3.getA2()) == 0);836
837assert(dynamic_cast<A2*>(a1.getA1()) == 0);838assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());839assert(dynamic_cast<A2*>(a3.getA1()) == 0);840assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());841
842assert(dynamic_cast<A3*>(a1.getA1()) == 0);843assert(dynamic_cast<A3*>(a2.getA2()) == 0);844assert(dynamic_cast<A3*>(a3.getA1()) == 0);845assert(dynamic_cast<A3*>(a3.getA2()) == 0);846assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());847}
848
849} // t15850
851/*
852
853A1
854|
855A2
856|
857A3
858
859*/
860
861namespace t16862{
863
864struct A1865{
866char _[43981];867virtual ~A1() {}868
869A1* getA1() {return this;}870};871
872struct A2873: public A1874{
875char _[34981];876virtual ~A2() {}877
878A1* getA1() {return this;}879A2* getA2() {return this;}880};881
882struct A3883: public A2884{
885char _[93481];886virtual ~A3() {}887
888A1* getA1() {return this;}889A2* getA2() {return this;}890A3* getA3() {return this;}891};892
893void test()894{
895A1 a1;896A2 a2;897A3 a3;898assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());899assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());900assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());901assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());902assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());903assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());904
905assert(dynamic_cast<A2*>(a1.getA1()) == 0);906assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());907assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());908assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());909assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());910assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());911
912assert(dynamic_cast<A3*>(a1.getA1()) == 0);913assert(dynamic_cast<A3*>(a2.getA1()) == 0);914assert(dynamic_cast<A3*>(a2.getA2()) == 0);915assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());916assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());917assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());918}
919
920} // t16921
922namespace t17923{
924
925struct A1926{
927char _[43981];928virtual ~A1() {}929
930A1* getA1() {return this;}931};932
933struct A2934: public virtual A1935{
936char _[34981];937virtual ~A2() {}938
939A1* getA1() {return this;}940A2* getA2() {return this;}941};942
943struct A3944: public A2945{
946char _[93481];947virtual ~A3() {}948
949A1* getA1() {return this;}950A2* getA2() {return this;}951A3* getA3() {return this;}952};953
954void test()955{
956A1 a1;957A2 a2;958A3 a3;959assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());960assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());961assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());962assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());963assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());964assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());965
966assert(dynamic_cast<A2*>(a1.getA1()) == 0);967assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());968assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());969assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());970assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());971assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());972
973assert(dynamic_cast<A3*>(a1.getA1()) == 0);974assert(dynamic_cast<A3*>(a2.getA1()) == 0);975assert(dynamic_cast<A3*>(a2.getA2()) == 0);976assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());977assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());978assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());979}
980
981} // t17982
983namespace t18984{
985
986struct A1987{
988char _[43981];989virtual ~A1() {}990
991A1* getA1() {return this;}992};993
994struct A2995: private A1996{
997char _[34981];998virtual ~A2() {}999
1000A1* getA1() {return this;}1001A2* getA2() {return this;}1002};1003
1004struct A31005: public A21006{
1007char _[93481];1008virtual ~A3() {}1009
1010A2* getA2() {return this;}1011A3* getA3() {return this;}1012};1013
1014void test()1015{
1016A1 a1;1017A2 a2;1018A3 a3;1019assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1020assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1021assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1022
1023assert(dynamic_cast<A2*>(a1.getA1()) == 0);1024assert(dynamic_cast<A2*>(a2.getA1()) == 0);1025assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1026assert(dynamic_cast<A2*>(a3.getA1()) == 0);1027assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1028assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1029
1030assert(dynamic_cast<A3*>(a1.getA1()) == 0);1031assert(dynamic_cast<A3*>(a2.getA1()) == 0);1032assert(dynamic_cast<A3*>(a2.getA2()) == 0);1033assert(dynamic_cast<A3*>(a3.getA1()) == 0);1034assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1035assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1036}
1037
1038} // t181039
1040namespace t191041{
1042
1043struct A11044{
1045char _[43981];1046virtual ~A1() {}1047
1048A1* getA1() {return this;}1049};1050
1051struct A21052: protected virtual A11053{
1054char _[34981];1055virtual ~A2() {}1056
1057A1* getA1() {return this;}1058A2* getA2() {return this;}1059};1060
1061struct A31062: public A21063{
1064char _[93481];1065virtual ~A3() {}1066
1067A2* getA2() {return this;}1068A3* getA3() {return this;}1069};1070
1071void test()1072{
1073A1 a1;1074A2 a2;1075A3 a3;1076assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1077assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1078assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1079
1080assert(dynamic_cast<A2*>(a1.getA1()) == 0);1081assert(dynamic_cast<A2*>(a2.getA1()) == 0);1082assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1083assert(dynamic_cast<A2*>(a3.getA1()) == 0);1084assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1085assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1086
1087assert(dynamic_cast<A3*>(a1.getA1()) == 0);1088assert(dynamic_cast<A3*>(a2.getA1()) == 0);1089assert(dynamic_cast<A3*>(a2.getA2()) == 0);1090assert(dynamic_cast<A3*>(a3.getA1()) == 0);1091assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1092assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1093}
1094
1095} // t191096
1097namespace t201098{
1099
1100struct A11101{
1102char _[43981];1103virtual ~A1() {}1104
1105A1* getA1() {return this;}1106};1107
1108struct A21109: public virtual A11110{
1111char _[34981];1112virtual ~A2() {}1113
1114A1* getA1() {return this;}1115A2* getA2() {return this;}1116};1117
1118struct A31119: public virtual A21120{
1121char _[93481];1122virtual ~A3() {}1123
1124A1* getA1() {return this;}1125A2* getA2() {return this;}1126A3* getA3() {return this;}1127};1128
1129void test()1130{
1131A1 a1;1132A2 a2;1133A3 a3;1134assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1135assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1136assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());1137assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1138assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());1139assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());1140
1141assert(dynamic_cast<A2*>(a1.getA1()) == 0);1142assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());1143assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1144assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());1145assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1146assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1147
1148assert(dynamic_cast<A3*>(a1.getA1()) == 0);1149assert(dynamic_cast<A3*>(a2.getA1()) == 0);1150assert(dynamic_cast<A3*>(a2.getA2()) == 0);1151assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());1152assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1153assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1154}
1155
1156} // t201157
1158namespace t211159{
1160
1161struct A11162{
1163char _[43981];1164virtual ~A1() {}1165
1166A1* getA1() {return this;}1167};1168
1169struct A21170: private A11171{
1172char _[34981];1173virtual ~A2() {}1174
1175A1* getA1() {return this;}1176A2* getA2() {return this;}1177};1178
1179struct A31180: public virtual A21181{
1182char _[93481];1183virtual ~A3() {}1184
1185A2* getA2() {return this;}1186A3* getA3() {return this;}1187};1188
1189void test()1190{
1191A1 a1;1192A2 a2;1193A3 a3;1194assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1195assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1196assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1197
1198assert(dynamic_cast<A2*>(a1.getA1()) == 0);1199assert(dynamic_cast<A2*>(a2.getA1()) == 0);1200assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1201assert(dynamic_cast<A2*>(a3.getA1()) == 0);1202assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1203assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1204
1205assert(dynamic_cast<A3*>(a1.getA1()) == 0);1206assert(dynamic_cast<A3*>(a2.getA1()) == 0);1207assert(dynamic_cast<A3*>(a2.getA2()) == 0);1208assert(dynamic_cast<A3*>(a3.getA1()) == 0);1209assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1210assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1211}
1212
1213} // t211214
1215namespace t221216{
1217
1218struct A11219{
1220char _[43981];1221virtual ~A1() {}1222
1223A1* getA1() {return this;}1224};1225
1226struct A21227: protected virtual A11228{
1229char _[34981];1230virtual ~A2() {}1231
1232A1* getA1() {return this;}1233A2* getA2() {return this;}1234};1235
1236struct A31237: public virtual A21238{
1239char _[93481];1240virtual ~A3() {}1241
1242A2* getA2() {return this;}1243A3* getA3() {return this;}1244};1245
1246void test()1247{
1248A1 a1;1249A2 a2;1250A3 a3;1251assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1252assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1253assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1254
1255assert(dynamic_cast<A2*>(a1.getA1()) == 0);1256assert(dynamic_cast<A2*>(a2.getA1()) == 0);1257assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1258assert(dynamic_cast<A2*>(a3.getA1()) == 0);1259assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1260assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1261
1262assert(dynamic_cast<A3*>(a1.getA1()) == 0);1263assert(dynamic_cast<A3*>(a2.getA1()) == 0);1264assert(dynamic_cast<A3*>(a2.getA2()) == 0);1265assert(dynamic_cast<A3*>(a3.getA1()) == 0);1266assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1267assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1268}
1269
1270} // t221271
1272namespace t231273{
1274
1275struct A11276{
1277char _[43981];1278virtual ~A1() {}1279
1280A1* getA1() {return this;}1281};1282
1283struct A21284: private A11285{
1286char _[34981];1287virtual ~A2() {}1288
1289A1* getA1() {return this;}1290A2* getA2() {return this;}1291};1292
1293struct A31294: private A21295{
1296char _[93481];1297virtual ~A3() {}1298
1299t23::A1* getA1() {return A2::getA1();}1300A2* getA2() {return this;}1301A3* getA3() {return this;}1302};1303
1304void test()1305{
1306A1 a1;1307A2 a2;1308A3 a3;1309assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1310assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1311assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1312
1313assert(dynamic_cast<A2*>(a1.getA1()) == 0);1314assert(dynamic_cast<A2*>(a2.getA1()) == 0);1315assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1316assert(dynamic_cast<A2*>(a3.getA1()) == 0);1317assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1318
1319assert(dynamic_cast<A3*>(a1.getA1()) == 0);1320assert(dynamic_cast<A3*>(a2.getA1()) == 0);1321assert(dynamic_cast<A3*>(a2.getA2()) == 0);1322assert(dynamic_cast<A3*>(a3.getA1()) == 0);1323assert(dynamic_cast<A3*>(a3.getA2()) == 0);1324assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1325}
1326
1327} // t231328
1329namespace t241330{
1331
1332struct A11333{
1334char _[43981];1335virtual ~A1() {}1336
1337A1* getA1() {return this;}1338};1339
1340struct A21341: protected virtual A11342{
1343char _[34981];1344virtual ~A2() {}1345
1346A1* getA1() {return this;}1347A2* getA2() {return this;}1348};1349
1350struct A31351: private A21352{
1353char _[93481];1354virtual ~A3() {}1355
1356t24::A1* getA1() {return A2::getA1();}1357A2* getA2() {return this;}1358A3* getA3() {return this;}1359};1360
1361void test()1362{
1363A1 a1;1364A2 a2;1365A3 a3;1366assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1367assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1368assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1369
1370assert(dynamic_cast<A2*>(a1.getA1()) == 0);1371assert(dynamic_cast<A2*>(a2.getA1()) == 0);1372assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1373assert(dynamic_cast<A2*>(a3.getA1()) == 0);1374assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1375
1376assert(dynamic_cast<A3*>(a1.getA1()) == 0);1377assert(dynamic_cast<A3*>(a2.getA1()) == 0);1378assert(dynamic_cast<A3*>(a2.getA2()) == 0);1379assert(dynamic_cast<A3*>(a3.getA1()) == 0);1380assert(dynamic_cast<A3*>(a3.getA2()) == 0);1381assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1382}
1383
1384} // t241385
1386namespace t251387{
1388
1389struct A11390{
1391char _[43981];1392virtual ~A1() {}1393
1394A1* getA1() {return this;}1395};1396
1397struct A21398: protected virtual A11399{
1400char _[34981];1401virtual ~A2() {}1402
1403A1* getA1() {return this;}1404A2* getA2() {return this;}1405};1406
1407struct A31408: private virtual A21409{
1410char _[93481];1411virtual ~A3() {}1412
1413t25::A1* getA1() {return A2::getA1();}1414A2* getA2() {return this;}1415A3* getA3() {return this;}1416};1417
1418void test()1419{
1420A1 a1;1421A2 a2;1422A3 a3;1423assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1424assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1425assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1426
1427assert(dynamic_cast<A2*>(a1.getA1()) == 0);1428assert(dynamic_cast<A2*>(a2.getA1()) == 0);1429assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1430assert(dynamic_cast<A2*>(a3.getA1()) == 0);1431assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1432
1433assert(dynamic_cast<A3*>(a1.getA1()) == 0);1434assert(dynamic_cast<A3*>(a2.getA1()) == 0);1435assert(dynamic_cast<A3*>(a2.getA2()) == 0);1436assert(dynamic_cast<A3*>(a3.getA1()) == 0);1437assert(dynamic_cast<A3*>(a3.getA2()) == 0);1438assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1439}
1440
1441} // t251442
1443/*
1444
1445A1 A1
1446| |
1447A2 |
1448\ |
1449A3
1450
1451*/
1452
1453namespace t261454{
1455
1456struct A11457{
1458char _[43981];1459virtual ~A1() {}1460
1461A1* getA1() {return this;}1462};1463
1464struct A21465: public A11466{
1467char _[34981];1468virtual ~A2() {}1469
1470A1* getA1() {return this;}1471A2* getA2() {return this;}1472};1473
1474struct A31475: public A1,1476public A21477{
1478char _[93481];1479virtual ~A3() {}1480
1481A1* getA12() {return A2::getA1();}1482A2* getA2() {return this;}1483A3* getA3() {return this;}1484};1485
1486void test()1487{
1488A1 a1;1489A2 a2;1490A3 a3;1491assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1492assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1493assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());1494assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());1495assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA12());1496
1497assert(dynamic_cast<A2*>(a1.getA1()) == 0);1498assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());1499assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1500assert(dynamic_cast<A2*>(a3.getA12()) == a3.getA2());1501assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1502assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1503
1504assert(dynamic_cast<A3*>(a1.getA1()) == 0);1505assert(dynamic_cast<A3*>(a2.getA1()) == 0);1506assert(dynamic_cast<A3*>(a2.getA2()) == 0);1507assert(dynamic_cast<A3*>(a3.getA12()) == a3.getA3());1508assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1509assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1510}
1511
1512} // t261513
1514namespace t271515{
1516
1517struct A11518{
1519char _[43981];1520virtual ~A1() {}1521
1522A1* getA1() {return this;}1523};1524
1525struct A21526: private A11527{
1528char _[34981];1529virtual ~A2() {}1530
1531A1* getA1() {return this;}1532A2* getA2() {return this;}1533};1534
1535struct A31536: public A1,1537public A21538{
1539char _[93481];1540virtual ~A3() {}1541
1542A1* getA12() {return A2::getA1();}1543A2* getA2() {return this;}1544A3* getA3() {return this;}1545};1546
1547void test()1548{
1549A1 a1;1550A2 a2;1551A3 a3;1552assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1553assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1554assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());1555
1556assert(dynamic_cast<A2*>(a1.getA1()) == 0);1557assert(dynamic_cast<A2*>(a2.getA1()) == 0);1558assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1559assert(dynamic_cast<A2*>(a3.getA12()) == 0);1560assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1561assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1562
1563assert(dynamic_cast<A3*>(a1.getA1()) == 0);1564assert(dynamic_cast<A3*>(a2.getA1()) == 0);1565assert(dynamic_cast<A3*>(a2.getA2()) == 0);1566assert(dynamic_cast<A3*>(a3.getA12()) == 0);1567assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1568assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1569}
1570
1571} // t271572
1573namespace t281574{
1575
1576struct A11577{
1578char _[43981];1579virtual ~A1() {}1580
1581A1* getA1() {return this;}1582};1583
1584struct A21585: public A11586{
1587char _[34981];1588virtual ~A2() {}1589
1590A1* getA1() {return this;}1591A2* getA2() {return this;}1592};1593
1594struct A31595: private A1,1596public A21597{
1598char _[93481];1599virtual ~A3() {}1600
1601A1* getA12() {return A2::getA1();}1602A2* getA2() {return this;}1603A3* getA3() {return this;}1604};1605
1606void test()1607{
1608A1 a1;1609A2 a2;1610A3 a3;1611assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1612assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1613assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());1614assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA12());1615
1616assert(dynamic_cast<A2*>(a1.getA1()) == 0);1617assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());1618assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1619assert(dynamic_cast<A2*>(a3.getA12()) == a3.getA2());1620assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1621assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1622
1623assert(dynamic_cast<A3*>(a1.getA1()) == 0);1624assert(dynamic_cast<A3*>(a2.getA1()) == 0);1625assert(dynamic_cast<A3*>(a2.getA2()) == 0);1626assert(dynamic_cast<A3*>(a3.getA12()) == a3.getA3());1627assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1628assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1629}
1630
1631} // t281632
1633namespace t291634{
1635
1636struct A11637{
1638char _[43981];1639virtual ~A1() {}1640
1641A1* getA1() {return this;}1642};1643
1644struct A21645: public A11646{
1647char _[34981];1648virtual ~A2() {}1649
1650A1* getA1() {return this;}1651A2* getA2() {return this;}1652};1653
1654struct A31655: public A1,1656private A21657{
1658char _[93481];1659virtual ~A3() {}1660
1661A1* getA12() {return A2::getA1();}1662A2* getA2() {return this;}1663A3* getA3() {return this;}1664};1665
1666void test()1667{
1668A1 a1;1669A2 a2;1670A3 a3;1671assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1672assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1673assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());1674assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA12());1675
1676assert(dynamic_cast<A2*>(a1.getA1()) == 0);1677assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());1678assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1679assert(dynamic_cast<A2*>(a3.getA12()) == a3.getA2());1680assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1681
1682assert(dynamic_cast<A3*>(a1.getA1()) == 0);1683assert(dynamic_cast<A3*>(a2.getA1()) == 0);1684assert(dynamic_cast<A3*>(a2.getA2()) == 0);1685assert(dynamic_cast<A3*>(a3.getA12()) == 0);1686assert(dynamic_cast<A3*>(a3.getA2()) == 0);1687assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1688}
1689
1690} // t291691
1692namespace t301693{
1694
1695struct A11696{
1697char _[43981];1698virtual ~A1() {}1699
1700A1* getA1() {return this;}1701};1702
1703struct A21704: public A11705{
1706char _[34981];1707virtual ~A2() {}1708
1709A1* getA1() {return this;}1710A2* getA2() {return this;}1711};1712
1713struct A31714: private A1,1715private A21716{
1717char _[93481];1718virtual ~A3() {}1719
1720A1* getA12() {return A2::getA1();}1721A2* getA2() {return this;}1722A3* getA3() {return this;}1723};1724
1725void test()1726{
1727A1 a1;1728A2 a2;1729A3 a3;1730assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1731assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1732assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());1733assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());1734assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA12());1735
1736assert(dynamic_cast<A2*>(a1.getA1()) == 0);1737assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());1738assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1739assert(dynamic_cast<A2*>(a3.getA12()) == a3.getA2());1740assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1741
1742assert(dynamic_cast<A3*>(a1.getA1()) == 0);1743assert(dynamic_cast<A3*>(a2.getA1()) == 0);1744assert(dynamic_cast<A3*>(a2.getA2()) == 0);1745assert(dynamic_cast<A3*>(a3.getA12()) == 0);1746assert(dynamic_cast<A3*>(a3.getA2()) == 0);1747assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1748}
1749
1750} // t301751
1752namespace t311753{
1754
1755struct A11756{
1757char _[43981];1758virtual ~A1() {}1759
1760A1* getA1() {return this;}1761};1762
1763struct A21764: private A11765{
1766char _[34981];1767virtual ~A2() {}1768
1769A1* getA1() {return this;}1770A2* getA2() {return this;}1771};1772
1773struct A31774: public A1,1775private A21776{
1777char _[93481];1778virtual ~A3() {}1779
1780A1* getA12() {return A2::getA1();}1781A2* getA2() {return this;}1782A3* getA3() {return this;}1783};1784
1785void test()1786{
1787A1 a1;1788A2 a2;1789A3 a3;1790assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1791assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1792assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());1793
1794assert(dynamic_cast<A2*>(a1.getA1()) == 0);1795assert(dynamic_cast<A2*>(a2.getA1()) == 0);1796assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1797assert(dynamic_cast<A2*>(a3.getA12()) == 0);1798assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1799
1800assert(dynamic_cast<A3*>(a1.getA1()) == 0);1801assert(dynamic_cast<A3*>(a2.getA1()) == 0);1802assert(dynamic_cast<A3*>(a2.getA2()) == 0);1803assert(dynamic_cast<A3*>(a3.getA12()) == 0);1804assert(dynamic_cast<A3*>(a3.getA2()) == 0);1805assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1806}
1807
1808} // t311809
1810namespace t321811{
1812
1813struct A11814{
1815char _[43981];1816virtual ~A1() {}1817
1818A1* getA1() {return this;}1819};1820
1821struct A21822: private A11823{
1824char _[34981];1825virtual ~A2() {}1826
1827A1* getA1() {return this;}1828A2* getA2() {return this;}1829};1830
1831struct A31832: private A1,1833public A21834{
1835char _[93481];1836virtual ~A3() {}1837
1838A1* getA12() {return A2::getA1();}1839A2* getA2() {return this;}1840A3* getA3() {return this;}1841};1842
1843void test()1844{
1845A1 a1;1846A2 a2;1847A3 a3;1848assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1849assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1850assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());1851
1852assert(dynamic_cast<A2*>(a1.getA1()) == 0);1853assert(dynamic_cast<A2*>(a2.getA1()) == 0);1854assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1855assert(dynamic_cast<A2*>(a3.getA12()) == 0);1856assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1857
1858assert(dynamic_cast<A3*>(a1.getA1()) == 0);1859assert(dynamic_cast<A3*>(a2.getA1()) == 0);1860assert(dynamic_cast<A3*>(a2.getA2()) == 0);1861assert(dynamic_cast<A3*>(a3.getA12()) == 0);1862assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1863assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1864}
1865
1866} // t321867
1868namespace t331869{
1870
1871struct A11872{
1873char _[43981];1874virtual ~A1() {}1875
1876A1* getA1() {return this;}1877};1878
1879struct A21880: private A11881{
1882char _[34981];1883virtual ~A2() {}1884
1885A1* getA1() {return this;}1886A2* getA2() {return this;}1887};1888
1889struct A31890: private A1,1891private A21892{
1893char _[93481];1894virtual ~A3() {}1895
1896A1* getA12() {return A2::getA1();}1897A2* getA2() {return this;}1898A3* getA3() {return this;}1899};1900
1901void test()1902{
1903A1 a1;1904A2 a2;1905A3 a3;1906assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1907assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1908assert(dynamic_cast<A1*>(a3.getA12()) == a3.getA12());1909
1910assert(dynamic_cast<A2*>(a1.getA1()) == 0);1911assert(dynamic_cast<A2*>(a2.getA1()) == 0);1912assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1913assert(dynamic_cast<A2*>(a3.getA12()) == 0);1914assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1915
1916assert(dynamic_cast<A3*>(a1.getA1()) == 0);1917assert(dynamic_cast<A3*>(a2.getA1()) == 0);1918assert(dynamic_cast<A3*>(a2.getA2()) == 0);1919assert(dynamic_cast<A3*>(a3.getA12()) == 0);1920assert(dynamic_cast<A3*>(a3.getA2()) == 0);1921assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1922}
1923
1924} // t331925
1926/*
1927
1928A1
1929| \
1930A2 \
1931\ |
1932A3
1933
1934*/
1935
1936namespace t341937{
1938
1939struct A11940{
1941char _[43981];1942virtual ~A1() {}1943
1944A1* getA1() {return this;}1945};1946
1947struct A21948: public virtual A11949{
1950char _[34981];1951virtual ~A2() {}1952
1953A1* getA1() {return this;}1954A2* getA2() {return this;}1955};1956
1957struct A31958: public virtual A1,1959public A21960{
1961char _[93481];1962virtual ~A3() {}1963
1964A1* getA1() {return A1::getA1();}1965A2* getA2() {return this;}1966A3* getA3() {return this;}1967};1968
1969void test()1970{
1971A1 a1;1972A2 a2;1973A3 a3;1974assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());1975assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());1976assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());1977assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());1978assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());1979assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());1980
1981assert(dynamic_cast<A2*>(a1.getA1()) == 0);1982assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());1983assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());1984assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());1985assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());1986assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());1987
1988assert(dynamic_cast<A3*>(a1.getA1()) == 0);1989assert(dynamic_cast<A3*>(a2.getA1()) == 0);1990assert(dynamic_cast<A3*>(a2.getA2()) == 0);1991assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());1992assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());1993assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());1994}
1995
1996} // t341997
1998namespace t351999{
2000
2001struct A12002{
2003char _[43981];2004virtual ~A1() {}2005
2006A1* getA1() {return this;}2007};2008
2009struct A22010: private virtual A12011{
2012char _[34981];2013virtual ~A2() {}2014
2015A1* getA1() {return this;}2016A2* getA2() {return this;}2017};2018
2019struct A32020: public virtual A1,2021public A22022{
2023char _[93481];2024virtual ~A3() {}2025
2026A1* getA1() {return A1::getA1();}2027A2* getA2() {return this;}2028A3* getA3() {return this;}2029};2030
2031void test()2032{
2033A1 a1;2034A2 a2;2035A3 a3;2036assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());2037assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());2038assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());2039assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());2040
2041assert(dynamic_cast<A2*>(a1.getA1()) == 0);2042assert(dynamic_cast<A2*>(a2.getA1()) == 0);2043assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());2044assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());2045assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());2046assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());2047
2048assert(dynamic_cast<A3*>(a1.getA1()) == 0);2049assert(dynamic_cast<A3*>(a2.getA1()) == 0);2050assert(dynamic_cast<A3*>(a2.getA2()) == 0);2051assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());2052assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());2053assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());2054}
2055
2056} // t352057
2058namespace t362059{
2060
2061struct A12062{
2063char _[43981];2064virtual ~A1() {}2065
2066A1* getA1() {return this;}2067};2068
2069struct A22070: public virtual A12071{
2072char _[34981];2073virtual ~A2() {}2074
2075A1* getA1() {return this;}2076A2* getA2() {return this;}2077};2078
2079struct A32080: private virtual A1,2081public A22082{
2083char _[93481];2084virtual ~A3() {}2085
2086A1* getA1() {return A1::getA1();}2087A2* getA2() {return this;}2088A3* getA3() {return this;}2089};2090
2091void test()2092{
2093A1 a1;2094A2 a2;2095A3 a3;2096assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());2097assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());2098assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());2099assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());2100assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());2101assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());2102
2103assert(dynamic_cast<A2*>(a1.getA1()) == 0);2104assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());2105assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());2106assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());2107assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());2108assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());2109
2110assert(dynamic_cast<A3*>(a1.getA1()) == 0);2111assert(dynamic_cast<A3*>(a2.getA1()) == 0);2112assert(dynamic_cast<A3*>(a2.getA2()) == 0);2113assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());2114assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());2115assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());2116}
2117
2118} // t362119
2120namespace t372121{
2122
2123struct A12124{
2125char _[43981];2126virtual ~A1() {}2127
2128A1* getA1() {return this;}2129};2130
2131struct A22132: public virtual A12133{
2134char _[34981];2135virtual ~A2() {}2136
2137A1* getA1() {return this;}2138A2* getA2() {return this;}2139};2140
2141struct A32142: public virtual A1,2143private A22144{
2145char _[93481];2146virtual ~A3() {}2147
2148A1* getA1() {return A1::getA1();}2149A2* getA2() {return this;}2150A3* getA3() {return this;}2151};2152
2153void test()2154{
2155A1 a1;2156A2 a2;2157A3 a3;2158assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());2159assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());2160assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());2161assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());2162assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());2163assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());2164
2165assert(dynamic_cast<A2*>(a1.getA1()) == 0);2166assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());2167assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());2168assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());2169assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());2170
2171assert(dynamic_cast<A3*>(a1.getA1()) == 0);2172assert(dynamic_cast<A3*>(a2.getA1()) == 0);2173assert(dynamic_cast<A3*>(a2.getA2()) == 0);2174assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());2175assert(dynamic_cast<A3*>(a3.getA2()) == 0);2176assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());2177}
2178
2179} // t372180
2181namespace t382182{
2183
2184struct A12185{
2186char _[43981];2187virtual ~A1() {}2188
2189A1* getA1() {return this;}2190};2191
2192struct A22193: public virtual A12194{
2195char _[34981];2196virtual ~A2() {}2197
2198A1* getA1() {return this;}2199A2* getA2() {return this;}2200};2201
2202struct A32203: private virtual A1,2204private A22205{
2206char _[93481];2207virtual ~A3() {}2208
2209A1* getA1() {return A1::getA1();}2210A2* getA2() {return this;}2211A3* getA3() {return this;}2212};2213
2214void test()2215{
2216A1 a1;2217A2 a2;2218A3 a3;2219assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());2220assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());2221assert(dynamic_cast<A1*>(a2.getA2()) == a2.getA1());2222assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());2223assert(dynamic_cast<A1*>(a3.getA2()) == a3.getA1());2224
2225assert(dynamic_cast<A2*>(a1.getA1()) == 0);2226assert(dynamic_cast<A2*>(a2.getA1()) == a2.getA2());2227assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());2228assert(dynamic_cast<A2*>(a3.getA1()) == a3.getA2());2229assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());2230
2231assert(dynamic_cast<A3*>(a1.getA1()) == 0);2232assert(dynamic_cast<A3*>(a2.getA1()) == 0);2233assert(dynamic_cast<A3*>(a2.getA2()) == 0);2234assert(dynamic_cast<A3*>(a3.getA1()) == 0);2235assert(dynamic_cast<A3*>(a3.getA2()) == 0);2236assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());2237}
2238
2239} // t382240
2241namespace t392242{
2243
2244struct A12245{
2246char _[43981];2247virtual ~A1() {}2248
2249A1* getA1() {return this;}2250};2251
2252struct A22253: private virtual A12254{
2255char _[34981];2256virtual ~A2() {}2257
2258A1* getA1() {return this;}2259A2* getA2() {return this;}2260};2261
2262struct A32263: public virtual A1,2264private A22265{
2266char _[93481];2267virtual ~A3() {}2268
2269A1* getA1() {return A1::getA1();}2270A2* getA2() {return this;}2271A3* getA3() {return this;}2272};2273
2274void test()2275{
2276A1 a1;2277A2 a2;2278A3 a3;2279assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());2280assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());2281assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());2282assert(dynamic_cast<A1*>(a3.getA3()) == a3.getA1());2283
2284assert(dynamic_cast<A2*>(a1.getA1()) == 0);2285assert(dynamic_cast<A2*>(a2.getA1()) == 0);2286assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());2287assert(dynamic_cast<A2*>(a3.getA1()) == 0);2288assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());2289
2290assert(dynamic_cast<A3*>(a1.getA1()) == 0);2291assert(dynamic_cast<A3*>(a2.getA1()) == 0);2292assert(dynamic_cast<A3*>(a2.getA2()) == 0);2293assert(dynamic_cast<A3*>(a3.getA1()) == a3.getA3());2294assert(dynamic_cast<A3*>(a3.getA2()) == 0);2295assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());2296}
2297
2298} // t392299
2300namespace t402301{
2302
2303struct A12304{
2305char _[43981];2306virtual ~A1() {}2307
2308A1* getA1() {return this;}2309};2310
2311struct A22312: private virtual A12313{
2314char _[34981];2315virtual ~A2() {}2316
2317A1* getA1() {return this;}2318A2* getA2() {return this;}2319};2320
2321struct A32322: private virtual A1,2323public A22324{
2325char _[93481];2326virtual ~A3() {}2327
2328A1* getA1() {return A1::getA1();}2329A2* getA2() {return this;}2330A3* getA3() {return this;}2331};2332
2333void test()2334{
2335A1 a1;2336A2 a2;2337A3 a3;2338assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());2339assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());2340assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());2341
2342assert(dynamic_cast<A2*>(a1.getA1()) == 0);2343assert(dynamic_cast<A2*>(a2.getA1()) == 0);2344assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());2345assert(dynamic_cast<A2*>(a3.getA1()) == 0);2346assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());2347assert(dynamic_cast<A2*>(a3.getA3()) == a3.getA2());2348
2349assert(dynamic_cast<A3*>(a1.getA1()) == 0);2350assert(dynamic_cast<A3*>(a2.getA1()) == 0);2351assert(dynamic_cast<A3*>(a2.getA2()) == 0);2352assert(dynamic_cast<A3*>(a3.getA1()) == 0);2353assert(dynamic_cast<A3*>(a3.getA2()) == a3.getA3());2354assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());2355}
2356
2357} // t402358
2359namespace t412360{
2361
2362struct A12363{
2364char _[43981];2365virtual ~A1() {}2366
2367A1* getA1() {return this;}2368};2369
2370struct A22371: private virtual A12372{
2373char _[34981];2374virtual ~A2() {}2375
2376A1* getA1() {return this;}2377A2* getA2() {return this;}2378};2379
2380struct A32381: private virtual A1,2382private A22383{
2384char _[93481];2385virtual ~A3() {}2386
2387A1* getA1() {return A1::getA1();}2388A2* getA2() {return this;}2389A3* getA3() {return this;}2390};2391
2392void test()2393{
2394A1 a1;2395A2 a2;2396A3 a3;2397assert(dynamic_cast<A1*>(a1.getA1()) == a1.getA1());2398assert(dynamic_cast<A1*>(a2.getA1()) == a2.getA1());2399assert(dynamic_cast<A1*>(a3.getA1()) == a3.getA1());2400
2401assert(dynamic_cast<A2*>(a1.getA1()) == 0);2402assert(dynamic_cast<A2*>(a2.getA1()) == 0);2403assert(dynamic_cast<A2*>(a2.getA2()) == a2.getA2());2404assert(dynamic_cast<A2*>(a3.getA1()) == 0);2405assert(dynamic_cast<A2*>(a3.getA2()) == a3.getA2());2406
2407assert(dynamic_cast<A3*>(a1.getA1()) == 0);2408assert(dynamic_cast<A3*>(a2.getA1()) == 0);2409assert(dynamic_cast<A3*>(a2.getA2()) == 0);2410assert(dynamic_cast<A3*>(a3.getA1()) == 0);2411assert(dynamic_cast<A3*>(a3.getA2()) == 0);2412assert(dynamic_cast<A3*>(a3.getA3()) == a3.getA3());2413}
2414
2415} // t412416
2417int main(int, char**)2418{
2419timer t;2420t1::test();2421t2::test();2422t3::test();2423t4::test();2424t5::test();2425t6::test();2426t7::test();2427t8::test();2428t9::test();2429t10::test();2430t11::test();2431t12::test();2432t13::test();2433t14::test();2434t15::test();2435t16::test();2436t17::test();2437t18::test();2438t19::test();2439t20::test();2440t21::test();2441t22::test();2442t23::test();2443t24::test();2444t25::test();2445t26::test();2446t27::test();2447t28::test();2448t29::test();2449t30::test();2450t31::test();2451t32::test();2452t33::test();2453t34::test();2454t35::test();2455t36::test();2456t37::test();2457t38::test();2458t39::test();2459t40::test();2460t41::test();2461
2462return 0;2463}
2464