1 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fms-extensions -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 -fms-extensions -fdump-record-layouts -fsyntax-only %s 2>/dev/null \ 4 // RUN: | FileCheck %s 5 6 namespace test1 { 7 8 struct A { 9 int a; 10 }; 11 struct B { 12 int b; 13 }; 14 struct C {}; 15 struct __declspec(align(16)) D {}; 16 struct __declspec(empty_bases) X : A, D, B, C { 17 }; 18 19 // CHECK: *** Dumping AST Record Layout 20 // CHECK-NEXT: 0 | struct test1::A 21 // CHECK-NEXT: 0 | int a 22 // CHECK-NEXT: | [sizeof=4, align=4, 23 // CHECK-NEXT: | nvsize=4, nvalign=4] 24 25 // CHECK: *** Dumping AST Record Layout 26 // CHECK-NEXT: 0 | struct test1::D (empty) 27 // CHECK-NEXT: | [sizeof=16, align=16, 28 // CHECK-NEXT: | nvsize=0, nvalign=16] 29 30 // CHECK: *** Dumping AST Record Layout 31 // CHECK-NEXT: 0 | struct test1::B 32 // CHECK-NEXT: 0 | int b 33 // CHECK-NEXT: | [sizeof=4, align=4, 34 // CHECK-NEXT: | nvsize=4, nvalign=4] 35 36 // CHECK: *** Dumping AST Record Layout 37 // CHECK-NEXT: 0 | struct test1::C (empty) 38 // CHECK-NEXT: | [sizeof=1, align=1, 39 // CHECK-NEXT: | nvsize=0, nvalign=1] 40 41 // CHECK: *** Dumping AST Record Layout 42 // CHECK-NEXT: 0 | struct test1::X 43 // CHECK-NEXT: 0 | struct test1::A (base) 44 // CHECK-NEXT: 0 | int a 45 // CHECK-NEXT: 0 | struct test1::D (base) (empty) 46 // CHECK-NEXT: 0 | struct test1::C (base) (empty) 47 // CHECK-NEXT: 4 | struct test1::B (base) 48 // CHECK-NEXT: 4 | int b 49 // CHECK-NEXT: | [sizeof=16, align=16, 50 // CHECK-NEXT: | nvsize=16, nvalign=16] 51 52 int _ = sizeof(X); 53 } 54 55 namespace test2 { 56 struct A { 57 int a; 58 }; 59 struct __declspec(empty_bases) B {}; 60 struct C : A { 61 B b; 62 }; 63 64 struct D {}; 65 struct E { 66 int e; 67 }; 68 struct F : D, E {}; 69 70 struct G : C, F {}; 71 72 int _ = sizeof(G); 73 74 // CHECK: *** Dumping AST Record Layout 75 // CHECK-NEXT: 0 | struct test2::A 76 // CHECK-NEXT: 0 | int a 77 // CHECK-NEXT: | [sizeof=4, align=4, 78 // CHECK-NEXT: | nvsize=4, nvalign=4] 79 80 // CHECK: *** Dumping AST Record Layout 81 // CHECK-NEXT: 0 | struct test2::B (empty) 82 // CHECK-NEXT: | [sizeof=1, align=1, 83 // CHECK-NEXT: | nvsize=0, nvalign=1] 84 85 // CHECK: *** Dumping AST Record Layout 86 // CHECK-NEXT: 0 | struct test2::C 87 // CHECK-NEXT: 0 | struct test2::A (base) 88 // CHECK-NEXT: 0 | int a 89 // CHECK-NEXT: 4 | struct test2::B b (empty) 90 // CHECK-NEXT: | [sizeof=8, align=4, 91 // CHECK-NEXT: | nvsize=8, nvalign=4] 92 93 // CHECK: *** Dumping AST Record Layout 94 // CHECK-NEXT: 0 | struct test2::D (empty) 95 // CHECK-NEXT: | [sizeof=1, align=1, 96 // CHECK-NEXT: | nvsize=0, nvalign=1] 97 98 // CHECK: *** Dumping AST Record Layout 99 // CHECK-NEXT: 0 | struct test2::E 100 // CHECK-NEXT: 0 | int e 101 // CHECK-NEXT: | [sizeof=4, align=4, 102 // CHECK-NEXT: | nvsize=4, nvalign=4] 103 104 // CHECK: *** Dumping AST Record Layout 105 // CHECK-NEXT: 0 | struct test2::F 106 // CHECK-NEXT: 0 | struct test2::D (base) (empty) 107 // CHECK-NEXT: 0 | struct test2::E (base) 108 // CHECK-NEXT: 0 | int e 109 // CHECK-NEXT: | [sizeof=4, align=4, 110 // CHECK-NEXT: | nvsize=4, nvalign=4] 111 112 // CHECK: *** Dumping AST Record Layout 113 // CHECK-NEXT: 0 | struct test2::G 114 // CHECK-NEXT: 0 | struct test2::C (base) 115 // CHECK-NEXT: 0 | struct test2::A (base) 116 // CHECK-NEXT: 0 | int a 117 // CHECK-NEXT: 4 | struct test2::B b (empty) 118 // CHECK-NEXT: 8 | struct test2::F (base) 119 // CHECK-NEXT: 8 | struct test2::D (base) (empty) 120 // CHECK-NEXT: 8 | struct test2::E (base) 121 // CHECK-NEXT: 8 | int e 122 // CHECK-NEXT: | [sizeof=12, align=4, 123 // CHECK-NEXT: | nvsize=12, nvalign=4] 124 } 125 126 namespace test3 { 127 struct A { 128 int a; 129 }; 130 struct B {}; 131 struct C : A { 132 B b; 133 }; 134 135 struct D {}; 136 struct E { 137 int e; 138 }; 139 struct F : D, E {}; 140 141 struct __declspec(empty_bases) G : C, F {}; 142 143 int _ = sizeof(G); 144 145 // CHECK: *** Dumping AST Record Layout 146 // CHECK-NEXT: 0 | struct test3::A 147 // CHECK-NEXT: 0 | int a 148 // CHECK-NEXT: | [sizeof=4, align=4, 149 // CHECK-NEXT: | nvsize=4, nvalign=4] 150 151 // CHECK: *** Dumping AST Record Layout 152 // CHECK-NEXT: 0 | struct test3::B (empty) 153 // CHECK-NEXT: | [sizeof=1, align=1, 154 // CHECK-NEXT: | nvsize=0, nvalign=1] 155 156 // CHECK: *** Dumping AST Record Layout 157 // CHECK-NEXT: 0 | struct test3::C 158 // CHECK-NEXT: 0 | struct test3::A (base) 159 // CHECK-NEXT: 0 | int a 160 // CHECK-NEXT: 4 | struct test3::B b (empty) 161 // CHECK-NEXT: | [sizeof=8, align=4, 162 // CHECK-NEXT: | nvsize=8, nvalign=4] 163 164 // CHECK: *** Dumping AST Record Layout 165 // CHECK-NEXT: 0 | struct test3::D (empty) 166 // CHECK-NEXT: | [sizeof=1, align=1, 167 // CHECK-NEXT: | nvsize=0, nvalign=1] 168 169 // CHECK: *** Dumping AST Record Layout 170 // CHECK-NEXT: 0 | struct test3::E 171 // CHECK-NEXT: 0 | int e 172 // CHECK-NEXT: | [sizeof=4, align=4, 173 // CHECK-NEXT: | nvsize=4, nvalign=4] 174 175 // CHECK: *** Dumping AST Record Layout 176 // CHECK-NEXT: 0 | struct test3::F 177 // CHECK-NEXT: 0 | struct test3::D (base) (empty) 178 // CHECK-NEXT: 0 | struct test3::E (base) 179 // CHECK-NEXT: 0 | int e 180 // CHECK-NEXT: | [sizeof=4, align=4, 181 // CHECK-NEXT: | nvsize=4, nvalign=4] 182 183 // CHECK: *** Dumping AST Record Layout 184 // CHECK-NEXT: 0 | struct test3::G 185 // CHECK-NEXT: 0 | struct test3::C (base) 186 // CHECK-NEXT: 0 | struct test3::A (base) 187 // CHECK-NEXT: 0 | int a 188 // CHECK-NEXT: 4 | struct test3::B b (empty) 189 // CHECK-NEXT: 8 | struct test3::F (base) 190 // CHECK-NEXT: 8 | struct test3::D (base) (empty) 191 // CHECK-NEXT: 8 | struct test3::E (base) 192 // CHECK-NEXT: 8 | int e 193 // CHECK-NEXT: | [sizeof=12, align=4, 194 // CHECK-NEXT: | nvsize=12, nvalign=4] 195 } 196 197 namespace test4 { 198 struct A { 199 int a; 200 }; 201 struct B {}; 202 struct C : A { 203 B b; 204 }; 205 206 struct __declspec(empty_bases) D {}; 207 struct E { 208 int e; 209 }; 210 struct F : D, E {}; 211 212 struct G : C, F {}; 213 214 int _ = sizeof(G); 215 216 // CHECK: *** Dumping AST Record Layout 217 // CHECK-NEXT: 0 | struct test4::A 218 // CHECK-NEXT: 0 | int a 219 // CHECK-NEXT: | [sizeof=4, align=4, 220 // CHECK-NEXT: | nvsize=4, nvalign=4] 221 222 // CHECK: *** Dumping AST Record Layout 223 // CHECK-NEXT: 0 | struct test4::B (empty) 224 // CHECK-NEXT: | [sizeof=1, align=1, 225 // CHECK-NEXT: | nvsize=0, nvalign=1] 226 227 // CHECK: *** Dumping AST Record Layout 228 // CHECK-NEXT: 0 | struct test4::C 229 // CHECK-NEXT: 0 | struct test4::A (base) 230 // CHECK-NEXT: 0 | int a 231 // CHECK-NEXT: 4 | struct test4::B b (empty) 232 // CHECK-NEXT: | [sizeof=8, align=4, 233 // CHECK-NEXT: | nvsize=8, nvalign=4] 234 235 // CHECK: *** Dumping AST Record Layout 236 // CHECK-NEXT: 0 | struct test4::D (empty) 237 // CHECK-NEXT: | [sizeof=1, align=1, 238 // CHECK-NEXT: | nvsize=0, nvalign=1] 239 240 // CHECK: *** Dumping AST Record Layout 241 // CHECK-NEXT: 0 | struct test4::E 242 // CHECK-NEXT: 0 | int e 243 // CHECK-NEXT: | [sizeof=4, align=4, 244 // CHECK-NEXT: | nvsize=4, nvalign=4] 245 246 // CHECK: *** Dumping AST Record Layout 247 // CHECK-NEXT: 0 | struct test4::F 248 // CHECK-NEXT: 0 | struct test4::D (base) (empty) 249 // CHECK-NEXT: 0 | struct test4::E (base) 250 // CHECK-NEXT: 0 | int e 251 // CHECK-NEXT: | [sizeof=4, align=4, 252 // CHECK-NEXT: | nvsize=4, nvalign=4] 253 254 // CHECK: *** Dumping AST Record Layout 255 // CHECK-NEXT: 0 | struct test4::G 256 // CHECK-NEXT: 0 | struct test4::C (base) 257 // CHECK-NEXT: 0 | struct test4::A (base) 258 // CHECK-NEXT: 0 | int a 259 // CHECK-NEXT: 4 | struct test4::B b (empty) 260 // CHECK-NEXT: 8 | struct test4::F (base) 261 // CHECK-NEXT: 8 | struct test4::D (base) (empty) 262 // CHECK-NEXT: 8 | struct test4::E (base) 263 // CHECK-NEXT: 8 | int e 264 // CHECK-NEXT: | [sizeof=12, align=4, 265 // CHECK-NEXT: | nvsize=12, nvalign=4] 266 } 267