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