xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/member-function-pointer-calls.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
2*f4a2713aSLionel Sambuc struct A {
3*f4a2713aSLionel Sambuc   virtual int vf1() { return 1; }
4*f4a2713aSLionel Sambuc   virtual int vf2() { return 2; }
5*f4a2713aSLionel Sambuc };
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc int f(A* a, int (A::*fp)()) {
8*f4a2713aSLionel Sambuc   return (a->*fp)();
9*f4a2713aSLionel Sambuc }
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g1v()
12*f4a2713aSLionel Sambuc // CHECK: ret i32 1
13*f4a2713aSLionel Sambuc int g1() {
14*f4a2713aSLionel Sambuc   A a;
15*f4a2713aSLionel Sambuc   return f(&a, &A::vf1);
16*f4a2713aSLionel Sambuc }
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z2g2v()
19*f4a2713aSLionel Sambuc // CHECK: ret i32 2
20*f4a2713aSLionel Sambuc int g2() {
21*f4a2713aSLionel Sambuc   A a;
22*f4a2713aSLionel Sambuc   return f(&a, &A::vf2);
23*f4a2713aSLionel Sambuc }
24