1 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin9 | FileCheck %s
3 struct A { int a; void f(); virtual void vf(); };
4 struct B { int b; virtual void g(); };
8 void (A::*volatile vpa)();
12 // CHECK: @pa2 = global %0 { i64 ptrtoint (void ()* @_ZN1A1fEv to i64), i64 0 }, align 8
13 void (A::*pa2)() = &A::f;
15 // CHECK: @pa3 = global %0 { i64 1, i64 0 }, align 8
16 void (A::*pa3)() = &A::vf;
18 // CHECK: @pc2 = global %0 { i64 ptrtoint (void ()* @_ZN1A1fEv to i64), i64 16 }, align 8
19 void (C::*pc2)() = &C::f;
21 // CHECK: @pc3 = global %0 { i64 1, i64 0 }, align 8
22 void (A::*pc3)() = &A::vf;
25 // CHECK: store i64 0, i64* getelementptr inbounds (%0* @pa, i32 0, i32 0)
26 // CHECK: store i64 0, i64* getelementptr inbounds (%0* @pa, i32 0, i32 1)
29 // CHECK: volatile store i64 0, i64* getelementptr inbounds (%0* @vpa, i32 0, i32 0)
30 // CHECK: volatile store i64 0, i64* getelementptr inbounds (%0* @vpa, i32 0, i32 1)
33 // CHECK: store i64 {{.*}}, i64* getelementptr inbounds (%0* @pc, i32 0, i32 0)
34 // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = add i64 {{.*}}, 16
35 // CHECK: store i64 [[ADJ]], i64* getelementptr inbounds (%0* @pc, i32 0, i32 1)
38 // CHECK: store i64 {{.*}}, i64* getelementptr inbounds (%0* @pa, i32 0, i32 0)
39 // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = sub i64 {{.*}}, 16
40 // CHECK: store i64 [[ADJ]], i64* getelementptr inbounds (%0* @pa, i32 0, i32 1)
41 pa = static_cast<void (A::*)()>(pc);
45 // CHECK: [[pa2ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa2, i32 0, i32 0
46 // CHECK: store i64 ptrtoint (void ()* @_ZN1A1fEv to i64), i64* [[pa2ptr]]
47 // CHECK: [[pa2adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa2, i32 0, i32 1
48 // CHECK: store i64 0, i64* [[pa2adj]]
49 void (A::*pa2)() = &A::f;
51 // CHECK: [[pa3ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 0
52 // CHECK: store i64 1, i64* [[pa3ptr]]
53 // CHECK: [[pa3adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 1
54 // CHECK: store i64 0, i64* [[pa3adj]]
55 void (A::*pa3)() = &A::vf;
58 void f3(A *a, A &ar) {
74 bool (A::*pmf)(int*) const;
77 B1() : pmf(&A::foo), pa(&a) {}
78 bool operator()() const { return (pa->*pmf)(new int); }
81 void bar(B1 b2) { while (b2()) ; }
87 virtual void bar(foo *);
94 void (foo::*ptr1)(void *) = (void (foo::*)(void *))&foo::bar;
95 void (*ptr2)(void *) = (void (*)(void *))&baz;
97 void (foo::*ptr3)(void) = (void (foo::*)(void))&foo::bar;
104 bool f(void (A::*f)()) {
112 bool f(void (A::*f)(), void (A::*g)()) {
117 namespace BoolMemberPointer {
120 bool f(void (A::*f)()) {
124 bool g(void (A::*f)()) {
135 virtual void baz(void);
138 void foo::baz(void) {
139 void (foo::*ptr)(void) = &foo::baz;
143 namespace MemberPointerImpCast {
147 struct B : public A {
149 void f(B* obj, void (A::*method)()) {