Galina Kistanova | 0ccb31c | 2011-06-03 22:24:54 +0000 | [diff] [blame] | 1 | // REQUIRES: x86-registered-target,x86-64-registered-target |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 3 | // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 5 | // RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s |
Fariborz Jahanian | 183d718 | 2009-08-14 00:01:54 +0000 | [diff] [blame] | 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); |
Fariborz Jahanian | c28bbc2 | 2009-08-21 22:34:55 +0000 | [diff] [blame] | 44 | for (unsigned i = 0; i < 3; i++) |
| 45 | for (unsigned j = 0; j < 2; j++) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 46 | printf("arr_b[%d][%d] = %f\n", i,j,arr_b[i][j].B1); |
Fariborz Jahanian | 183d718 | 2009-08-14 00:01:54 +0000 | [diff] [blame] | 47 | B::pr(); |
| 48 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 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 | } |
Fariborz Jahanian | c28bbc2 | 2009-08-21 22:34:55 +0000 | [diff] [blame] | 56 | B arr_b[3][2]; |
Fariborz Jahanian | 183d718 | 2009-08-14 00:01:54 +0000 | [diff] [blame] | 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 | |
Anders Carlsson | d99edc4 | 2009-09-26 03:55:37 +0000 | [diff] [blame] | 96 | // CHECK-LP64: .globl __ZN1XaSERKS_ |
| 97 | // CHECK-LP64: .weak_definition __ZN1XaSERKS_ |
| 98 | // CHECK-LP64: __ZN1XaSERKS_: |
| 99 | // CHECK-LP64: .globl __ZN1QaSERKS_ |
| 100 | // CHECK-LP64: .weak_definition __ZN1QaSERKS_ |
| 101 | // CHECK-LP64: __ZN1QaSERKS_: |
Fariborz Jahanian | 183d718 | 2009-08-14 00:01:54 +0000 | [diff] [blame] | 102 | |
Anders Carlsson | d99edc4 | 2009-09-26 03:55:37 +0000 | [diff] [blame] | 103 | // CHECK-LP32: .globl __ZN1XaSERKS_ |
| 104 | // CHECK-LP32: .weak_definition __ZN1XaSERKS_ |
| 105 | // CHECK-LP32: __ZN1XaSERKS_: |
| 106 | // CHECK-LP32: .globl __ZN1QaSERKS_ |
| 107 | // CHECK-LP32: .weak_definition __ZN1QaSERKS_ |
| 108 | // CHECK-LP32: __ZN1QaSERKS_: |
Fariborz Jahanian | 183d718 | 2009-08-14 00:01:54 +0000 | [diff] [blame] | 109 | |