summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.robertl/eb46.C
blob: cbe482e90b8060489dec70f2a12de2f380c9c53e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// { dg-do run  }
#include <iostream>

class A1 {
        friend class B;
 public:
        virtual void foo() {}
};

class A2 : public virtual A1 {friend class B;};

class A3 : public virtual A1, private A2 {friend class B;};

class B
{
 public:
        B(A1* a) : itsA(dynamic_cast<A2*>(a)) {}
        A2* itsA;
};

int main()
{
        A1* a=new A3;
        B b(a);

        if (b.itsA) 
	  std::cout << "cast ok" << std::endl; 
	else 
	  std::cout << "cast failed" << std::endl;
        return 0;
}