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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.old-deja/] [g++.mike/] [dyncast7.C] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
// { dg-do run  }
2
// { dg-options "-fexceptions" }
3
 
4
#include 
5
#include 
6
 
7
class A {
8
public:
9
  virtual void j () {}
10
};
11
 
12
class B : public A { };
13
 
14
void x (A& a) {
15
  // These should all work.
16
  const B& b2 = dynamic_cast(a);
17
  const B& b3 = dynamic_cast((const A&)a);
18
  const B& b4 = dynamic_cast(a);
19
}
20
 
21
int main() {
22
  try {
23
    B b;
24
    x (b);
25
  } catch (std::exception& e) {
26
    // If we get a bad_cast, it is wrong.
27
    return 1;
28
  }
29
}

powered by: WebSVN 2.1.0

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