[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / CodeGenCXX / ptr-to-datamember.cpp
bloba6f523e2d7dd01b446cd24128027340e3783005e
1 // RUN: %clang_cc1 -emit-llvm -o - %s
3 extern "C" int printf(...);
5 struct F {
6 F() : iF(1), fF(2.0) {}
7 int iF;
8 float fF;
9 };
11 struct V {
12 double d;
13 int iV;
16 struct B : virtual V{
17 double d;
18 int iB;
21 struct B1 : virtual V{
22 double d;
23 int iB1;
26 class A : public B, public B1 {
27 public:
28 A() : f(1.0), d(2.0), Ai(3) {}
29 float f;
30 double d;
31 int Ai;
32 F Af;
33 };
35 template <typename T> struct TT {
36 int T::t::*pti;
39 struct I {
40 typedef I t;
41 int x;
44 void pr(const F& b) {
45 printf(" %d %f\n", b.iF, b.fF);
48 void test_aggr_pdata(A& a1) {
49 F A::* af = &A::Af;
50 pr(a1.*af);
52 (a1.*af).iF = 100;
53 (a1.*af).fF = 200.00;
54 printf(" %d %f\n", (a1.*af).iF, (a1.*af).fF);
55 pr(a1.*af);
57 (a1.*af).iF++;
58 (a1.*af).fF--;
59 --(a1.*af).fF;
60 pr(a1.*af);
63 void test_aggr_pdata_1(A* pa) {
64 F A::* af = &A::Af;
65 pr(pa->*af);
67 (pa->*af).iF = 100;
68 (pa->*af).fF = 200.00;
69 printf(" %d %f\n", (pa->*af).iF, (pa->*af).fF);
70 pr(pa->*af);
72 (pa->*af).iF++;
73 (pa->*af).fF--;
74 --(pa->*af).fF;
75 pr(pa->*af);
78 int main()
80 A a1;
81 TT<I> tt;
82 I i;
83 int A::* pa = &A::Ai;
84 float A::* pf = &A::f;
85 double A::* pd = &A::d;
86 tt.pti = &I::x;
87 printf("%d %d %d\n", &A::Ai, &A::f, &A::d);
88 printf("%d\n", &A::B::iB);
89 printf("%d\n", &A::B1::iB1);
90 printf("%d\n", &A::f);
91 printf("%d\n", &A::B::iV);
92 printf("%d\n", &A::B1::iV);
93 printf("%d\n", &A::B::V::iV);
94 printf("%d\n", &A::B1::V::iV);
95 printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd);
96 printf("%d\n", i.*tt.pti);
97 test_aggr_pdata(a1);
98 test_aggr_pdata_1(&a1);