xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/member-function-pointer-calls.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1  // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
2  // RUN: %clang_cc1 %s -triple=x86_64-windows-gnu -emit-llvm -o - | FileCheck %s -check-prefix MINGW64
3  struct A {
vf1A4    virtual int vf1() { return 1; }
vf2A5    virtual int vf2() { return 2; }
6  };
7  
f(A * a,int (A::* fp)())8  int f(A* a, int (A::*fp)()) {
9    return (a->*fp)();
10  }
11  
12  // CHECK-LABEL: define i32 @_Z2g1v()
13  // CHECK: ret i32 1
14  // MINGW64-LABEL: define i32 @_Z2g1v()
15  // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
g1()16  int g1() {
17    A a;
18    return f(&a, &A::vf1);
19  }
20  
21  // CHECK-LABEL: define i32 @_Z2g2v()
22  // CHECK: ret i32 2
23  // MINGW64-LABEL: define i32 @_Z2g2v()
24  // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
g2()25  int g2() {
26    A a;
27    return f(&a, &A::vf2);
28  }
29