OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [dyncast3.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
// Author: Alfred Miniarik 
3
// test of dynamic_cast
4
// runtime detecting of nonpublic
5
// inheritance within a cast
6
// and therefor failing with result 0.
7
 
8
extern "C" void abort();
9
extern "C" int printf (const char *, ...);
10
 
11
static int errors = 0;
12
 
13
void error(int i)
14
{
15
  printf("Error %i\n",i);
16
  errors++;
17
}
18
 
19
struct A {virtual ~A(){}};
20
struct B : private virtual A {};
21
struct C : virtual A {};
22
struct D : B, C {};
23
 
24
int
25
main()
26
{
27
  D d;
28
  A* ap= &d;
29
  if(&d != dynamic_cast(ap)) error(1);
30
  if((B*)&d != dynamic_cast(ap)) error(2);
31
  if((C*)&d != dynamic_cast(ap)) error(3);
32
  return errors ? 1 : 0;
33
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.