[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Layout / aix-virtual-function-and-base-with-double.cpp
blobd3bc4418db1fe567b6f590ee16f0b015a6d5c07d
1 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
2 // RUN: -fsyntax-only %s | \
3 // RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s
5 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
6 // RUN: -fsyntax-only %s | \
7 // RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s
9 namespace test1 {
10 struct A {
11 double d1;
12 virtual void boo() {}
15 struct B {
16 double d2;
17 A a;
20 struct C : public A {
21 double d3;
24 int i = sizeof(B);
25 int j = sizeof(C);
27 // CHECK: *** Dumping AST Record Layout
28 // CHECK-NEXT: 0 | struct test1::A
29 // CHECK-NEXT: 0 | (A vtable pointer)
30 // CHECK32-NEXT: 4 | double d1
31 // CHECK32-NEXT: | [sizeof=12, dsize=12, align=4, preferredalign=4,
32 // CHECK32-NEXT: | nvsize=12, nvalign=4, preferrednvalign=4]
33 // CHECK64-NEXT: 8 | double d1
34 // CHECK64-NEXT: | [sizeof=16, dsize=16, align=8, preferredalign=8,
35 // CHECK64-NEXT: | nvsize=16, nvalign=8, preferrednvalign=8]
37 // CHECK: *** Dumping AST Record Layout
38 // CHECK-NEXT: 0 | struct test1::B
39 // CHECK-NEXT: 0 | double d2
40 // CHECK-NEXT: 8 | struct test1::A a
41 // CHECK-NEXT: 8 | (A vtable pointer)
42 // CHECK32-NEXT: 12 | double d1
43 // CHECK32-NEXT: | [sizeof=24, dsize=20, align=4, preferredalign=8,
44 // CHECK32-NEXT: | nvsize=20, nvalign=4, preferrednvalign=8]
45 // CHECK64-NEXT: 16 | double d1
46 // CHECK64-NEXT: | [sizeof=24, dsize=24, align=8, preferredalign=8,
47 // CHECK64-NEXT: | nvsize=24, nvalign=8, preferrednvalign=8]
49 // CHECK: *** Dumping AST Record Layout
50 // CHECK-NEXT: 0 | struct test1::C
51 // CHECK-NEXT: 0 | struct test1::A (primary base)
52 // CHECK-NEXT: 0 | (A vtable pointer)
53 // CHECK32-NEXT: 4 | double d1
54 // CHECK32-NEXT: 12 | double d3
55 // CHECK32-NEXT: | [sizeof=20, dsize=20, align=4, preferredalign=4,
56 // CHECK32-NEXT: | nvsize=20, nvalign=4, preferrednvalign=4]
57 // CHECK64-NEXT: 8 | double d1
58 // CHECK64-NEXT: 16 | double d3
59 // CHECK64-NEXT: | [sizeof=24, dsize=24, align=8, preferredalign=8,
60 // CHECK64-NEXT: | nvsize=24, nvalign=8, preferrednvalign=8]
62 } // namespace test1
64 namespace test2 {
65 struct A {
66 long long l1;
69 struct B : public virtual A {
70 double d2;
73 #pragma pack(2)
74 struct C : public virtual A {
75 double __attribute__((aligned(4))) d3;
78 int i = sizeof(B);
79 int j = sizeof(C);
81 // CHECK: *** Dumping AST Record Layout
82 // CHECK-NEXT: 0 | struct test2::A
83 // CHECK-NEXT: 0 | long long l1
84 // CHECK-NEXT: | [sizeof=8, dsize=8, align=8, preferredalign=8,
85 // CHECK-NEXT: | nvsize=8, nvalign=8, preferrednvalign=8]
87 // CHECK: *** Dumping AST Record Layout
88 // CHECK-NEXT: 0 | struct test2::B
89 // CHECK-NEXT: 0 | (B vtable pointer)
90 // CHECK32-NEXT: 4 | double d2
91 // CHECK64-NEXT: 8 | double d2
92 // CHECK-NEXT: 16 | struct test2::A (virtual base)
93 // CHECK-NEXT: 16 | long long l1
94 // CHECK-NEXT: | [sizeof=24, dsize=24, align=8, preferredalign=8,
95 // CHECK32-NEXT: | nvsize=12, nvalign=4, preferrednvalign=4]
96 // CHECK64-NEXT: | nvsize=16, nvalign=8, preferrednvalign=8]
98 // CHECK: *** Dumping AST Record Layout
99 // CHECK-NEXT: 0 | struct test2::C
100 // CHECK-NEXT: 0 | (C vtable pointer)
101 // CHECK32-NEXT: 4 | double d3
102 // CHECK32-NEXT: 12 | struct test2::A (virtual base)
103 // CHECK32-NEXT: 12 | long long l1
104 // CHECK32-NEXT: | [sizeof=20, dsize=20, align=2, preferredalign=2,
105 // CHECK32-NEXT: | nvsize=12, nvalign=2, preferrednvalign=2]
106 // CHECK64-NEXT: 8 | double d3
107 // CHECK64-NEXT: 16 | struct test2::A (virtual base)
108 // CHECK64-NEXT: 16 | long long l1
109 // CHECK64-NEXT: | [sizeof=24, dsize=24, align=2, preferredalign=2,
110 // CHECK64-NEXT: | nvsize=16, nvalign=2, preferrednvalign=2]
112 } // namespace test2