FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / dyncast3.C
blob5b33767ff131a9e00f90bcc4e41911a2d49d0eca
1 // Author: Alfred Miniarik <a8601248@unet.univie.ac.at>
2 // test of dynamic_cast
3 // runtime detecting of nonpublic
4 // inheritance within a cast
5 // and therefor failing with result 0.
7 extern "C" void abort();
8 extern "C" int printf (const char *, ...);
10 static int errors = 0;
12 void error(int i)
14   printf("Error %i\n",i);
15   errors++;
18 struct A {virtual ~A(){}};
19 struct B : private virtual A {};
20 struct C : virtual A {};
21 struct D : B, C {};
23 int 
24 main()
26   D d;
27   A* ap= &d;
28   if(&d != dynamic_cast<D*>(ap)) error(1);
29   if((B*)&d != dynamic_cast<B*>(ap)) error(2);
30   if((C*)&d != dynamic_cast<C*>(ap)) error(3);
31   return errors ? 1 : 0;