[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / empty-classes.cpp
bloba02517f87a2220f91fbce93bd002fd1c42ff0898
1 // RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
3 // CHECK: %"struct.rdar20621065::B" = type { float, float }
5 struct Empty { };
7 struct A {
8 explicit A(unsigned a = 0xffffffff) : a(a) { }
10 unsigned a;
13 struct B : A, Empty {
14 B() : A(), Empty() { }
17 struct C : A, Empty {
18 C() : A(), Empty() { }
19 C(const C& other) : A(0x12345678), Empty(other) { }
22 struct D : A, Empty {
23 D& operator=(const D& other) {
24 a = 0x87654321;
25 Empty::operator=(other);
27 return *this;
31 #define CHECK(x) if (!(x)) return __LINE__
33 // PR7012
34 // CHECK-LABEL: define{{.*}} i32 @_Z1fv()
35 int f() {
36 B b1;
38 // Check that A::a is not overwritten by the Empty default constructor.
39 CHECK(b1.a == 0xffffffff);
41 C c1;
42 C c2(c1);
44 // Check that A::a has the value set in the C::C copy constructor.
45 CHECK(c2.a == 0x12345678);
47 D d1, d2;
48 d2 = d1;
50 // Check that A::as has the value set in the D copy assignment operator.
51 CHECK(d2.a == 0x87654321);
53 // Success!
54 // CHECK: ret i32 0
55 return 0;
58 namespace PR8796 {
59 struct FreeCell {
61 union ThingOrCell {
62 FreeCell t;
63 FreeCell cell;
65 struct Things {
66 ThingOrCell things;
68 Things x;
71 #ifdef HARNESS
72 extern "C" void printf(const char *, ...);
74 int main() {
75 int result = f();
77 if (result == 0)
78 printf("success!\n");
79 else
80 printf("test on line %d failed!\n", result);
82 return result;
84 #endif
86 namespace rdar20621065 {
87 struct A {
88 float array[0];
91 struct B : A {
92 float left;
93 float right;
96 // Type checked at the top of the file.
97 B b;
100 // This test used to crash when CGRecordLayout::getNonVirtualBaseLLVMFieldNo was called.
101 namespace record_layout {
102 struct X0 {
103 int x[0];
106 template<typename>
107 struct X2 : X0 {
110 template<typename>
111 struct X3 : X2<int> {
112 X3() : X2<int>() {}
116 void test0() {
117 X3<int>();