Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | \
      2 // RUN: FileCheck %s
      3 // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -emit-llvm %s -o - | \
      4 // RUN: FileCheck %s
      5 
      6 extern "C" int printf(...);
      7 
      8 struct B {
      9   B() : B1(3.14), B2(3.15), auB2(3.16)  {}
     10   float B1;
     11   float B2;
     12   void pr() {
     13     printf("B1 = %f B2 = %f auB1 = %f\n", B1, B2, auB1);
     14   }
     15 
     16   B& operator=(const B& arg) { B1 = arg.B1; B2 = arg.B2;
     17                                auB1 = arg.auB1; return *this; }
     18   union {
     19     float auB1;
     20     float auB2;
     21   };
     22 };
     23 
     24 struct M {
     25   M() : M1(10), M2(11) , auM1(12) {}
     26   int M1;
     27   int M2;
     28   void pr() {
     29     printf("M1 = %d M2 = %d auM1 = %d auM2 = %d\n", M1, M2, auM1, auM2);
     30   }
     31   union {
     32     int auM1;
     33     int auM2;
     34   };
     35 };
     36 
     37 struct N  : B {
     38   N() : N1(20), N2(21) {}
     39   int N1;
     40   int N2;
     41   void pr() {
     42     printf("N1 = %d N2 = %d\n", N1, N2);
     43     for (unsigned i = 0; i < 3; i++)
     44       for (unsigned j = 0; j < 2; j++)
     45         printf("arr_b[%d][%d] = %f\n", i,j,arr_b[i][j].B1);
     46     B::pr();
     47   }
     48   N& operator=(const N& arg) {
     49     N1 = arg.N1; N2 = arg.N2;
     50     for (unsigned i = 0; i < 3; i++)
     51       for (unsigned j = 0; j < 2; j++)
     52         arr_b[i][j] = arg.arr_b[i][j];
     53     return *this;
     54   }
     55   B arr_b[3][2];
     56 };
     57 
     58 struct Q  : B {
     59   Q() : Q1(30), Q2(31) {}
     60   int Q1;
     61   int Q2;
     62   void pr() {
     63     printf("Q1 = %d Q2 = %d\n", Q1, Q2);
     64   }
     65 };
     66 
     67 
     68 struct X : M , N {
     69   X() : d(0.0), d1(1.1), d2(1.2), d3(1.3) {}
     70   double d;
     71   double d1;
     72   double d2;
     73   double d3;
     74   void pr() {
     75     printf("d = %f d1 = %f d2 = %f d3 = %f\n", d, d1,d2,d3);
     76     M::pr(); N::pr();
     77     q1.pr(); q2.pr();
     78   }
     79 
     80  Q q1, q2;
     81 };
     82 
     83 
     84 X srcX;
     85 X dstX;
     86 X dstY;
     87 
     88 int main() {
     89   dstY = dstX = srcX;
     90   srcX.pr();
     91   dstX.pr();
     92   dstY.pr();
     93 }
     94 
     95 // CHECK: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.X* @_ZN1XaSERKS_
     96