class-layout.cpp revision 9cbe4f0ba01ec304e1e3d071c071f7bca33631c0
1// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s 2 3// An extra byte should be allocated for an empty class. 4namespace Test1 { 5 // CHECK: %"struct.Test1::A" = type { i8 } 6 struct A { } *a; 7} 8 9namespace Test2 { 10 // No need to add tail padding here. 11 // CHECK: %"struct.Test2::A" = type { i8*, i32 } 12 struct A { void *a; int b; } *a; 13} 14 15namespace Test3 { 16 // C should have a vtable pointer. 17 // CHECK: %"struct.Test3::A" = type { i32 (...)**, i32 } 18 struct A { virtual void f(); int a; } *a; 19} 20 21namespace Test4 { 22 // Test from PR5589. 23 // CHECK: %"struct.Test4::B" = type { %"struct.Test4::A", i16, double } 24 // CHECK: %"struct.Test4::A" = type { i32, i8, float } 25 struct A { 26 int a; 27 char c; 28 float b; 29 }; 30 struct B : public A { 31 short d; 32 double e; 33 } *b; 34} 35 36namespace Test5 { 37 struct A { 38 virtual void f(); 39 char a; 40 }; 41 42 // CHECK: %"struct.Test5::B" = type { [9 x i8], i8, i8, [5 x i8] } 43 struct B : A { 44 char b : 1; 45 char c; 46 } *b; 47} 48