summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.other/dyncast4.C
blob: a49ef4b672641e95ed3d92d6574495a7f8a2284a (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
// { dg-do run  }
// Author: Alfred Miniarik <a8601248@unet.univie.ac.at>

// Even in a derived class, a private base cannot be dynamically downcasted
// from.

extern "C" void abort();

struct A {
  virtual ~A () {}
};

struct B : private A {
  B* a2b (A* objp)
  {
    return dynamic_cast<B*> (objp);
  }
};

int
main ()
{
  B b;
  A* aptr = (A*) &b;
  if (dynamic_cast <B*> (aptr)) abort ();
  if (b.a2b (aptr)) abort();
  return 0;
}