blob: 62fddc9b7cdaf883801fc2d4c11b790726aa611a [file] [log] [blame]
John McCall32509f12011-11-15 01:35:18 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
Douglas Gregor5e6fcd42011-02-08 02:14:35 +00002
3struct X {
4 void f() const;
5 ~X();
6};
7
8@interface A {
9 X x_;
10}
11
12- (const X&)x;
13- (void)setx:(const X&)other;
14@end
15
16@implementation A
17
18- (const X&)x { return x_; }
19- (void)setx:(const X&)other { x_ = other; }
20- (void)method {
21 self.x.f();
John McCall32509f12011-11-15 01:35:18 +000022}
Douglas Gregor5e6fcd42011-02-08 02:14:35 +000023@end
24
John McCall32509f12011-11-15 01:35:18 +000025// rdar://problem/10444030
26@interface Test2
27- (void) setY: (int) y;
28- (int) z;
29@end
30void test2(Test2 *a) {
31 auto y = a.y; // expected-error {{expected getter method not found on object of type 'Test2 *'}} expected-error {{variable 'y' with type 'auto' has incompatible initializer of type}}
32 auto z = a.z;
33}
John McCall806054d2012-01-11 00:14:46 +000034
35// rdar://problem/10672108
36@interface Test3
37- (int) length;
38@end
39void test3(Test3 *t) {
John McCall52f220d2012-01-11 01:35:55 +000040 char vla[t.length] = {}; // expected-error {{variable-sized object may not be initialized}}
41 char *heaparray = new char[t.length];
John McCall806054d2012-01-11 00:14:46 +000042}
Eli Friedmaned0b31f2012-01-12 00:44:34 +000043
44@interface Test4
45- (X&) prop;
46@end
47void test4(Test4 *t) {
48 (void)const_cast<const X&>(t.prop);
49 (void)dynamic_cast<X&>(t.prop);
50 (void)reinterpret_cast<int&>(t.prop);
51}