2009-10-22 02:38:00 +08:00
|
|
|
// RUN: clang-cc -emit-llvm -o - %s
|
|
|
|
|
|
|
|
extern "C" int printf(...);
|
|
|
|
|
2009-10-23 06:57:31 +08:00
|
|
|
struct F {
|
|
|
|
F() : iF(1), fF(2.0) {}
|
|
|
|
int iF;
|
|
|
|
float fF;
|
|
|
|
};
|
|
|
|
|
2009-10-22 05:01:47 +08:00
|
|
|
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 {
|
2009-10-22 02:38:00 +08:00
|
|
|
public:
|
2009-10-22 07:45:42 +08:00
|
|
|
A() : f(1.0), d(2.0), Ai(3) {}
|
2009-10-22 02:38:00 +08:00
|
|
|
float f;
|
|
|
|
double d;
|
|
|
|
int Ai;
|
2009-10-23 06:57:31 +08:00
|
|
|
F Af;
|
2009-10-22 02:38:00 +08:00
|
|
|
};
|
|
|
|
|
2009-11-05 00:49:01 +08:00
|
|
|
template <typename T> struct TT {
|
|
|
|
int T::t::*pti;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct I {
|
|
|
|
typedef I t;
|
|
|
|
int x;
|
|
|
|
};
|
|
|
|
|
2009-10-23 06:57:31 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-10-27 05:58:25 +08:00
|
|
|
void test_aggr_pdata_1(A* pa) {
|
|
|
|
F A::* af = &A::Af;
|
|
|
|
pr(pa->*af);
|
|
|
|
|
|
|
|
(pa->*af).iF = 100;
|
|
|
|
(pa->*af).fF = 200.00;
|
|
|
|
printf(" %d %f\n", (pa->*af).iF, (pa->*af).fF);
|
|
|
|
pr(pa->*af);
|
|
|
|
|
|
|
|
(pa->*af).iF++;
|
|
|
|
(pa->*af).fF--;
|
|
|
|
--(pa->*af).fF;
|
|
|
|
pr(pa->*af);
|
|
|
|
}
|
|
|
|
|
2009-10-22 02:38:00 +08:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
A a1;
|
2009-11-05 00:49:01 +08:00
|
|
|
TT<I> tt;
|
|
|
|
I i;
|
2009-10-22 02:38:00 +08:00
|
|
|
int A::* pa = &A::Ai;
|
|
|
|
float A::* pf = &A::f;
|
|
|
|
double A::* pd = &A::d;
|
2009-11-05 00:49:01 +08:00
|
|
|
tt.pti = &I::x;
|
2009-10-22 02:38:00 +08:00
|
|
|
printf("%d %d %d\n", &A::Ai, &A::f, &A::d);
|
2009-10-22 05:01:47 +08:00
|
|
|
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);
|
2009-10-22 07:45:42 +08:00
|
|
|
printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd);
|
2009-11-05 00:49:01 +08:00
|
|
|
printf("%d\n", i.*tt.pti);
|
2009-10-23 06:57:31 +08:00
|
|
|
test_aggr_pdata(a1);
|
2009-10-27 05:58:25 +08:00
|
|
|
test_aggr_pdata_1(&a1);
|
2009-10-22 02:38:00 +08:00
|
|
|
}
|