1 | // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s |
2 | // CHECK: -[A .cxx_construct] |
3 | // CHECK: -[A .cxx_destruct] |
4 | // CHECK: -[B .cxx_construct] |
5 | // CHECK-NOT: -[B .cxx_destruct] |
6 | // CHECK-NOT: -[C .cxx_construct] |
7 | // CHECK: -[C .cxx_destruct] |
8 | |
9 | @interface NSObject |
10 | - alloc; |
11 | - init; |
12 | - (void) release; |
13 | @end |
14 | |
15 | extern "C" int printf(const char *, ...); |
16 | |
17 | int count = 17; |
18 | struct X { |
19 | X() : value(count++) { printf( "X::X()\n"); } |
20 | ~X() { printf( "X::~X()\n"); } |
21 | int value; |
22 | }; |
23 | |
24 | struct Y { |
25 | Y() : value(count++) { printf( "Y::Y()\n"); } |
26 | ~Y() { printf( "Y::~Y()\n"); } |
27 | int value; |
28 | }; |
29 | |
30 | @interface Super : NSObject { |
31 | Y yvar; |
32 | Y yvar1; |
33 | Y ya[3]; |
34 | } |
35 | - (void)finalize; |
36 | @end |
37 | |
38 | @interface A : Super { |
39 | X xvar; |
40 | X xvar1; |
41 | X xvar2; |
42 | X xa[2][2]; |
43 | } |
44 | |
45 | - (void)print; |
46 | - (void)finalize; |
47 | @end |
48 | |
49 | @implementation Super |
50 | - (void)print { |
51 | printf( "yvar.value = %d\n", yvar.value); |
52 | printf( "yvar1.value = %d\n", yvar1.value); |
53 | printf( "ya[0..2] = %d %d %d\n", ya[0].value, ya[1].value, ya[2].value); |
54 | } |
55 | - (void)finalize {} |
56 | @end |
57 | |
58 | @implementation A |
59 | - (void)print { |
60 | printf( "xvar.value = %d\n", xvar.value); |
61 | printf( "xvar1.value = %d\n", xvar1.value); |
62 | printf( "xvar2.value = %d\n", xvar2.value); |
63 | printf( "xa[0..1][0..1] = %d %d %d %d\n", |
64 | xa[0][0].value, xa[0][1].value, xa[1][0].value, xa[1][1].value); |
65 | [super print]; |
66 | } |
67 | - (void)finalize { [super finalize]; } |
68 | @end |
69 | |
70 | int main() { |
71 | A *a = [[A alloc] init]; |
72 | [a print]; |
73 | [a release]; |
74 | } |
75 | |
76 | // rdar: // 7468090 |
77 | class S { |
78 | public: |
79 | S& operator = (const S&); |
80 | }; |
81 | |
82 | @interface I { |
83 | S position; |
84 | } |
85 | @property(assign, nonatomic) S position; |
86 | @end |
87 | |
88 | @implementation I |
89 | @synthesize position; |
90 | @end |
91 | |
92 | // This class should have a .cxx_construct but no .cxx_destruct. |
93 | namespace test3 { struct S { S(); }; } |
94 | @implementation B { |
95 | test3::S s; |
96 | } |
97 | @end |
98 | |
99 | // This class should have a .cxx_destruct but no .cxx_construct. |
100 | namespace test4 { struct S { ~S(); }; } |
101 | @implementation C { |
102 | test4::S s; |
103 | } |
104 | @end |
105 | |