copy-assign-synthesis-1.cpp revision 0ccb31c389a09216a5b60cf05bd01516ddbe8d4f
10ccb31c389a09216a5b60cf05bd01516ddbe8d4fGalina Kistanova// REQUIRES: x86-registered-target,x86-64-registered-target 2a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s 34fcfde4d5c8f25e40720972a5543d538a0dcb220Daniel Dunbar// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s 4a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s 54fcfde4d5c8f25e40720972a5543d538a0dcb220Daniel Dunbar// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s 6183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 7183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanianextern "C" int printf(...); 8183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 9183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanianstruct B { 10183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian B() : B1(3.14), B2(3.15), auB2(3.16) {} 11183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian float B1; 12183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian float B2; 13183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian void pr() { 14183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian printf("B1 = %f B2 = %f auB1 = %f\n", B1, B2, auB1); 15183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian } 16183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 17183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian B& operator=(const B& arg) { B1 = arg.B1; B2 = arg.B2; 18183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian auB1 = arg.auB1; return *this; } 19183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian union { 20183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian float auB1; 21183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian float auB2; 22183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian }; 23183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian}; 24183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 25183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanianstruct M { 26183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian M() : M1(10), M2(11) , auM1(12) {} 27183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian int M1; 28183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian int M2; 29183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian void pr() { 30183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian printf("M1 = %d M2 = %d auM1 = %d auM2 = %d\n", M1, M2, auM1, auM2); 31183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian } 32183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian union { 33183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian int auM1; 34183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian int auM2; 35183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian }; 36183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian}; 37183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 38183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanianstruct N : B { 39183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian N() : N1(20), N2(21) {} 40183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian int N1; 41183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian int N2; 42183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian void pr() { 43183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian printf("N1 = %d N2 = %d\n", N1, N2); 44c28bbc2d2271aab6c5d79ef2758604221cd92a4bFariborz Jahanian for (unsigned i = 0; i < 3; i++) 45c28bbc2d2271aab6c5d79ef2758604221cd92a4bFariborz Jahanian for (unsigned j = 0; j < 2; j++) 461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump printf("arr_b[%d][%d] = %f\n", i,j,arr_b[i][j].B1); 47183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian B::pr(); 48183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian } 491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump N& operator=(const N& arg) { 501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump N1 = arg.N1; N2 = arg.N2; 511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump for (unsigned i = 0; i < 3; i++) 521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump for (unsigned j = 0; j < 2; j++) 531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump arr_b[i][j] = arg.arr_b[i][j]; 541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return *this; 551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 56c28bbc2d2271aab6c5d79ef2758604221cd92a4bFariborz Jahanian B arr_b[3][2]; 57183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian}; 58183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 59183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanianstruct Q : B { 60183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian Q() : Q1(30), Q2(31) {} 61183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian int Q1; 62183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian int Q2; 63183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian void pr() { 64183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian printf("Q1 = %d Q2 = %d\n", Q1, Q2); 65183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian } 66183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian}; 67183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 68183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 69183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanianstruct X : M , N { 70183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian X() : d(0.0), d1(1.1), d2(1.2), d3(1.3) {} 71183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian double d; 72183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian double d1; 73183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian double d2; 74183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian double d3; 75183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian void pr() { 76183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian printf("d = %f d1 = %f d2 = %f d3 = %f\n", d, d1,d2,d3); 77183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian M::pr(); N::pr(); 78183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian q1.pr(); q2.pr(); 79183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian } 80183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 81183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian Q q1, q2; 82183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian}; 83183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 84183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 85183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz JahanianX srcX; 86183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz JahanianX dstX; 87183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz JahanianX dstY; 88183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 89183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanianint main() { 90183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian dstY = dstX = srcX; 91183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian srcX.pr(); 92183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian dstX.pr(); 93183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian dstY.pr(); 94183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian} 95183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 96d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP64: .globl __ZN1XaSERKS_ 97d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP64: .weak_definition __ZN1XaSERKS_ 98d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP64: __ZN1XaSERKS_: 99d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP64: .globl __ZN1QaSERKS_ 100d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP64: .weak_definition __ZN1QaSERKS_ 101d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP64: __ZN1QaSERKS_: 102183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 103d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP32: .globl __ZN1XaSERKS_ 104d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP32: .weak_definition __ZN1XaSERKS_ 105d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP32: __ZN1XaSERKS_: 106d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP32: .globl __ZN1QaSERKS_ 107d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP32: .weak_definition __ZN1QaSERKS_ 108d99edc44300b36732a14c294c93899ba28d479eaAnders Carlsson// CHECK-LP32: __ZN1QaSERKS_: 109183d7181fd59842ac969cbc6fe0376f85dc63ae4Fariborz Jahanian 110