Clang Project

clang_source_code/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp
1// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o -
2// RUN: %clang_cc1 -triple %ms_abi_triple -fno-rtti -emit-llvm %s -o -
3
4struct A {
5  virtual void Method() = 0;
6};
7
8struct B : public A {
9  virtual void Method() { }
10};
11
12typedef void (A::*fn_type_a)(void);
13typedef void (B::*fn_type_b)(void);
14
15int main(int argc, char **argv)
16{
17  fn_type_a f = reinterpret_cast<fn_type_a>(&B::Method);
18  fn_type_b g = reinterpret_cast<fn_type_b>(f);
19  B b;
20  (b.*g)();
21  return 0;
22}
23