diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-23 14:22:18 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-23 14:22:18 +0000 |
| commit | 73490b890977362d28dd6326843a1ecae413921d (patch) | |
| tree | 3fdd91eae574e32453a4baf462961c742df2691a /test/CodeGenCXX/ptr-to-datamember.cpp | |
| parent | a5f348eb914e67b51914117fac117c18c1f8d650 (diff) | |
Diffstat (limited to 'test/CodeGenCXX/ptr-to-datamember.cpp')
| -rw-r--r-- | test/CodeGenCXX/ptr-to-datamember.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/CodeGenCXX/ptr-to-datamember.cpp b/test/CodeGenCXX/ptr-to-datamember.cpp new file mode 100644 index 000000000000..eee03c060f91 --- /dev/null +++ b/test/CodeGenCXX/ptr-to-datamember.cpp @@ -0,0 +1,70 @@ +// RUN: clang-cc -emit-llvm -o - %s + +extern "C" int printf(...); + +struct F { + F() : iF(1), fF(2.0) {} + int iF; + float fF; +}; + +struct V { + double d; + int iV; +}; + +struct B : virtual V{ + double d; + int iB; +}; + +struct B1 : virtual V{ + double d; + int iB1; +}; + +class A : public B, public B1 { +public: + A() : f(1.0), d(2.0), Ai(3) {} + float f; + double d; + int Ai; + F Af; +}; + +void pr(const F& b) { + printf(" %d %f\n", b.iF, b.fF); +} + +void test_aggr_pdata(A& a1) { + F A::* af = &A::Af; + pr(a1.*af); + + (a1.*af).iF = 100; + (a1.*af).fF = 200.00; + printf(" %d %f\n", (a1.*af).iF, (a1.*af).fF); + pr(a1.*af); + + (a1.*af).iF++; + (a1.*af).fF--; + --(a1.*af).fF; + pr(a1.*af); +} + +int main() +{ + A a1; + int A::* pa = &A::Ai; + float A::* pf = &A::f; + double A::* pd = &A::d; + printf("%d %d %d\n", &A::Ai, &A::f, &A::d); + printf("%d\n", &A::B::iB); + printf("%d\n", &A::B1::iB1); + printf("%d\n", &A::f); + printf("%d\n", &A::B::iV); + printf("%d\n", &A::B1::iV); + printf("%d\n", &A::B::V::iV); + printf("%d\n", &A::B1::V::iV); + printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd); + test_aggr_pdata(a1); +} |
