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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [dyncast5.C] - Blame information for rev 305

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 305 jeremybenn
// { dg-do run  }
2
// Copyright (C) 1999 Free Software Foundation, Inc.
3
// Contributed by Nathan Sidwell 6 Jun 1999 
4
 
5
// dynamic cast can only cast to public unambiguous bases
6
 
7
extern "C" void abort ();
8
 
9
struct A {virtual ~A(){} int m; };
10
struct B {virtual ~B(){} int m; };
11
 
12
struct C1 : A {int m;};
13
struct C2 : A {int m;};
14
 
15
// A is ambiguous, but private in one branch
16
struct D1 : B, C1, private C2 {int m;};
17
// A is ambiguous, and public in both branches
18
struct D2 : B, C1, C2 {int m;};
19
 
20
void fn(B *bd1, B *bd2)
21
{
22
  A *ad1;
23
  A *ad2;
24
 
25
  ad1 = dynamic_cast(bd1);
26
  if(ad1) abort();
27
  ad2 = dynamic_cast(bd2);
28
  if(ad2) abort();
29
}
30
 
31
int main()
32
{
33
  D1 d1;
34
  D2 d2;
35
 
36
  fn((B *)&d1, (B *)&d2);
37
  return 0;
38
}

powered by: WebSVN 2.1.0

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