| 1 |
// { dg-do run } |
| 2 |
// Copyright (C) 1999 Free Software Foundation, Inc. |
| 3 |
// Contributed by Nathan Sidwell 6 Jun 1999 <[email protected]> |
| 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<A *>(bd1); |
| 26 |
if(ad1) abort(); |
| 27 |
ad2 = dynamic_cast<A *>(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 |
} |