1 | // RUN: %clang_cc1 -fsyntax-only -triple armv7k-apple-darwin-watchos -fdump-record-layouts %s | FileCheck %s |
2 | |
3 | // WatchOS, 64-bit iOS, and WebAssembly use the C++11 definition of POD to |
4 | // determine whether we can reuse the tail padding of a struct (POD is |
5 | // "trivially copyable and standard layout"). The definition of standard |
6 | // layout changed some time around C++17; check that we still use the old |
7 | // ABI rule. |
8 | |
9 | // B is not standard-layout, but it was under C++11's rule, so we pack |
10 | // C::d into its tail padding anyway. |
11 | struct A { int : 0; }; |
12 | struct B : A { int n; char c[3]; }; |
13 | struct C : B { char d; }; |
14 | int c = sizeof(C); |
15 | static_assert(!__is_standard_layout(B)); |
16 | |
17 | // CHECK:*** Dumping AST Record Layout |
18 | // CHECK: 0 | struct C |
19 | // CHECK-NEXT: 0 | struct B (base) |
20 | // CHECK-NEXT: 0 | struct A (base) (empty) |
21 | // CHECK-NEXT: 0:- | int |
22 | // CHECK-NEXT: 0 | int n |
23 | // CHECK-NEXT: 4 | char [3] c |
24 | // CHECK-NEXT: 8 | char d |
25 | // CHECK-NEXT: | [sizeof=12, dsize=9, align=4, |
26 | // CHECK-NEXT: | nvsize=9, nvalign=4] |
27 | |
28 | // F is not standard-layout due to the repeated D base class, but it was under |
29 | // C++11's rule, so we pack G::d into its tail padding anyway. |
30 | struct D {}; |
31 | struct E : D {}; |
32 | struct F : D, E { int n; char c[3]; }; |
33 | struct G : F { G(const G&); char d; }; |
34 | int g = sizeof(G); |
35 | static_assert(!__is_standard_layout(F)); |
36 | |
37 | // CHECK:*** Dumping AST Record Layout |
38 | // CHECK: 0 | struct G |
39 | // CHECK-NEXT: 0 | struct F (base) |
40 | // CHECK-NEXT: 0 | struct D (base) (empty) |
41 | // CHECK-NEXT: 1 | struct E (base) (empty) |
42 | // CHECK-NEXT: 1 | struct D (base) (empty) |
43 | // CHECK-NEXT: 0 | int n |
44 | // CHECK-NEXT: 4 | char [3] c |
45 | // CHECK-NEXT: 8 | char d |
46 | // CHECK-NEXT: | [sizeof=12, dsize=9, align=4, |
47 | // CHECK-NEXT: | nvsize=9, nvalign=4] |
48 | |