1 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \ 2 // RUN: | FileCheck %s 3 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \ 4 // RUN: | FileCheck %s 5 6 extern "C" int printf(const char *fmt, ...); 7 8 struct __declspec(align(8)) B0 { B0() {printf("B0 : %p\n", this);} }; 9 struct __declspec(align(8)) B1 { B1() {printf("B1 : %p\n", this);} }; 10 struct __declspec(align(8)) B2 { B2() {printf("B2 : %p\n", this);} }; 11 struct __declspec(align(8)) B3 { B3() {printf("B3 : %p\n", this);} }; 12 struct __declspec(align(8)) B4 { B4() {printf("B4 : %p\n", this);} }; 13 14 struct C0 { int a; C0() : a(0xf00000C0) {printf("C0 : %p\n", this);} }; 15 struct C1 { int a; C1() : a(0xf00000C1) {printf("C1 : %p\n", this);} }; 16 struct C2 { int a; C2() : a(0xf00000C2) {printf("C2 : %p\n", this);} }; 17 struct C3 { int a; C3() : a(0xf00000C3) {printf("C3 : %p\n", this);} }; 18 struct C4 { int a; C4() : a(0xf00000C4) {printf("C4 : %p\n", this);} }; 19 20 struct A : B0 { 21 int a; 22 A() : a(0xf000000A) {printf("X : %p\n", this);} 23 }; 24 25 // CHECK: *** Dumping AST Record Layout 26 // CHECK: *** Dumping AST Record Layout 27 // CHECK-NEXT: 0 | struct A 28 // CHECK-NEXT: 0 | struct B0 (base) (empty) 29 // CHECK-NEXT: 0 | int a 30 // CHECK-NEXT: | [sizeof=8, align=8 31 // CHECK-NEXT: | nvsize=8, nvalign=8] 32 33 struct B : B0 { 34 B0 b0; 35 int a; 36 B() : a(0xf000000B) {printf("X : %p\n", this);} 37 }; 38 39 // CHECK: *** Dumping AST Record Layout 40 // CHECK-NEXT: 0 | struct B 41 // CHECK-NEXT: 0 | struct B0 (base) (empty) 42 // CHECK-NEXT: 0 | struct B0 b0 (empty) 43 // CHECK-NEXT: | [sizeof=8, align=8 44 // CHECK-NEXT: | nvsize=0, nvalign=8] 45 // CHECK: 8 | int a 46 // CHECK-NEXT: | [sizeof=16, align=8 47 // CHECK-NEXT: | nvsize=16, nvalign=8] 48 49 struct C : B0, B1, B2, B3, B4 { 50 int a; 51 C() : a(0xf000000C) {printf("X : %p\n", this);} 52 }; 53 54 // CHECK: *** Dumping AST Record Layout 55 // CHECK: *** Dumping AST Record Layout 56 // CHECK: *** Dumping AST Record Layout 57 // CHECK: *** Dumping AST Record Layout 58 // CHECK: *** Dumping AST Record Layout 59 // CHECK-NEXT: 0 | struct C 60 // CHECK-NEXT: 0 | struct B0 (base) (empty) 61 // CHECK-NEXT: 8 | struct B1 (base) (empty) 62 // CHECK-NEXT: 16 | struct B2 (base) (empty) 63 // CHECK-NEXT: 24 | struct B3 (base) (empty) 64 // CHECK-NEXT: 32 | struct B4 (base) (empty) 65 // CHECK-NEXT: 32 | int a 66 // CHECK-NEXT: | [sizeof=40, align=8 67 // CHECK-NEXT: | nvsize=40, nvalign=8] 68 69 struct D { 70 B0 b0; 71 C0 c0; 72 C1 c1; 73 C2 c2; 74 B1 b1; 75 int a; 76 D() : a(0xf000000D) {printf("X : %p\n", this);} 77 }; 78 79 // CHECK: *** Dumping AST Record Layout 80 // CHECK: *** Dumping AST Record Layout 81 // CHECK: *** Dumping AST Record Layout 82 // CHECK: *** Dumping AST Record Layout 83 // CHECK-NEXT: 0 | struct D 84 // CHECK-NEXT: 0 | struct B0 b0 (empty) 85 // CHECK-NEXT: | [sizeof=8, align=8 86 // CHECK-NEXT: | nvsize=0, nvalign=8] 87 // CHECK: 8 | struct C0 c0 88 // CHECK-NEXT: 8 | int a 89 // CHECK-NEXT: | [sizeof=4, align=4 90 // CHECK-NEXT: | nvsize=4, nvalign=4] 91 // CHECK: 12 | struct C1 c1 92 // CHECK-NEXT: 12 | int a 93 // CHECK-NEXT: | [sizeof=4, align=4 94 // CHECK-NEXT: | nvsize=4, nvalign=4] 95 // CHECK: 16 | struct C2 c2 96 // CHECK-NEXT: 16 | int a 97 // CHECK-NEXT: | [sizeof=4, align=4 98 // CHECK-NEXT: | nvsize=4, nvalign=4] 99 // CHECK: 24 | struct B1 b1 (empty) 100 // CHECK-NEXT: | [sizeof=8, align=8 101 // CHECK-NEXT: | nvsize=0, nvalign=8] 102 // CHECK: 32 | int a 103 // CHECK-NEXT: | [sizeof=40, align=8 104 // CHECK-NEXT: | nvsize=40, nvalign=8] 105 106 struct E : B0, C0, C1, C2, B1 { 107 int a; 108 E() : a(0xf000000E) {printf("X : %p\n", this);} 109 }; 110 111 // CHECK: *** Dumping AST Record Layout 112 // CHECK-NEXT: 0 | struct E 113 // CHECK-NEXT: 0 | struct B0 (base) (empty) 114 // CHECK-NEXT: 0 | struct C0 (base) 115 // CHECK-NEXT: 0 | int a 116 // CHECK-NEXT: 4 | struct C1 (base) 117 // CHECK-NEXT: 4 | int a 118 // CHECK-NEXT: 8 | struct C2 (base) 119 // CHECK-NEXT: 8 | int a 120 // CHECK-NEXT: 16 | struct B1 (base) (empty) 121 // CHECK-NEXT: 16 | int a 122 // CHECK-NEXT: | [sizeof=24, align=8 123 // CHECK-NEXT: | nvsize=24, nvalign=8] 124 125 struct F : C0, B0, B1, C1 { 126 int a; 127 F() : a(0xf000000F) {printf("X : %p\n", this);} 128 }; 129 130 // CHECK: *** Dumping AST Record Layout 131 // CHECK-NEXT: 0 | struct F 132 // CHECK-NEXT: 0 | struct C0 (base) 133 // CHECK-NEXT: 0 | int a 134 // CHECK-NEXT: 8 | struct B0 (base) (empty) 135 // CHECK-NEXT: 16 | struct B1 (base) (empty) 136 // CHECK-NEXT: 16 | struct C1 (base) 137 // CHECK-NEXT: 16 | int a 138 // CHECK-NEXT: 20 | int a 139 // CHECK-NEXT: | [sizeof=24, align=8 140 // CHECK-NEXT: | nvsize=24, nvalign=8] 141 142 struct G : B0, B1, B2, B3, B4 { 143 __declspec(align(32)) int a; 144 G() : a(0xf0000011) {printf("X : %p\n", this);} 145 }; 146 147 // CHECK: *** Dumping AST Record Layout 148 // CHECK-NEXT: 0 | struct G 149 // CHECK-NEXT: 0 | struct B0 (base) (empty) 150 // CHECK-NEXT: 8 | struct B1 (base) (empty) 151 // CHECK-NEXT: 16 | struct B2 (base) (empty) 152 // CHECK-NEXT: 24 | struct B3 (base) (empty) 153 // CHECK-NEXT: 32 | struct B4 (base) (empty) 154 // CHECK-NEXT: 32 | int a 155 // CHECK-NEXT: | [sizeof=64, align=32 156 // CHECK-NEXT: | nvsize=64, nvalign=32] 157 158 struct __declspec(align(32)) H : B0, B1, B2, B3, B4 { 159 int a; 160 H() : a(0xf0000011) {printf("X : %p\n", this);} 161 }; 162 163 // CHECK: *** Dumping AST Record Layout 164 // CHECK-NEXT: 0 | struct H 165 // CHECK-NEXT: 0 | struct B0 (base) (empty) 166 // CHECK-NEXT: 8 | struct B1 (base) (empty) 167 // CHECK-NEXT: 16 | struct B2 (base) (empty) 168 // CHECK-NEXT: 24 | struct B3 (base) (empty) 169 // CHECK-NEXT: 32 | struct B4 (base) (empty) 170 // CHECK-NEXT: 32 | int a 171 // CHECK-NEXT: | [sizeof=64, align=32 172 // CHECK-NEXT: | nvsize=40, nvalign=32] 173 174 int a[ 175 sizeof(A)+ 176 sizeof(B)+ 177 sizeof(C)+ 178 sizeof(D)+ 179 sizeof(E)+ 180 sizeof(F)+ 181 sizeof(G)+ 182 sizeof(H)]; 183