brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · bf8af60 Raw
48 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -triple armv7k-apple-darwin-watchos -fdump-record-layouts %s | FileCheck %s2 3// WatchOS, 64-bit iOS, and WebAssembly use the C++11 definition of POD to4// determine whether we can reuse the tail padding of a struct (POD is5// "trivially copyable and standard layout"). The definition of standard6// layout changed some time around C++17; check that we still use the old7// ABI rule.8 9// B is not standard-layout, but it was under C++11's rule, so we pack10// C::d into its tail padding anyway.11struct A { int : 0; };12struct B : A { int n; char c[3]; };13struct C : B { char d; };14int c = sizeof(C);15static_assert(!__is_standard_layout(B));16 17// CHECK:*** Dumping AST Record Layout18// CHECK:          0 | struct C19// CHECK-NEXT:     0 |   struct B (base)20// CHECK-NEXT:     0 |     struct A (base) (empty)21// CHECK-NEXT:   0:- |       int 22// CHECK-NEXT:     0 |     int n23// CHECK-NEXT:     4 |     char[3] c24// CHECK-NEXT:     8 |   char d25// 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 under29// C++11's rule, so we pack G::d into its tail padding anyway.30struct D {};31struct E : D {};32struct F : D, E { int n; char c[3]; };33struct G : F { G(const G&); char d; };34int g = sizeof(G);35static_assert(!__is_standard_layout(F));36 37// CHECK:*** Dumping AST Record Layout38// CHECK:          0 | struct G39// 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 n44// CHECK-NEXT:     4 |     char[3] c45// CHECK-NEXT:     8 |   char d46// CHECK-NEXT:       | [sizeof=12, dsize=9, align=4,47// CHECK-NEXT:       |  nvsize=9, nvalign=4]48