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