blob: d8d92e568796519262f0e307f27243f3bc4fb947 [file] [log] [blame]
John McCalld5c98ae2011-11-15 01:35:18 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
Douglas Gregora57a66e2011-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 McCalld5c98ae2011-11-15 01:35:18 +000022}
Douglas Gregora57a66e2011-02-08 02:14:35 +000023@end
24
John McCalld5c98ae2011-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 McCall9b80c212012-01-11 00:14:46 +000034
35// rdar://problem/10672108
36@interface Test3
37- (int) length;
38@end
39void test3(Test3 *t) {
John McCallfd3b6642012-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 McCall9b80c212012-01-11 00:14:46 +000042}
Eli Friedman42b199c2012-01-12 00:44:34 +000043
Douglas Gregorbf3a8262012-01-12 16:11:24 +000044// <rdar://problem/10672501>
45namespace std {
46 template<typename T> void count();
Eli Friedman42b199c2012-01-12 00:44:34 +000047}
Douglas Gregorbf3a8262012-01-12 16:11:24 +000048
Douglas Gregorccff3012012-01-13 16:56:26 +000049@interface Test4
50- (X&) prop;
51@end
52
53void test4(Test4 *t) {
54 (void)const_cast<const X&>(t.prop);
55 (void)dynamic_cast<X&>(t.prop);
56 (void)reinterpret_cast<int&>(t.prop);
57}
58
59@interface Test5 {
Douglas Gregorbf3a8262012-01-12 16:11:24 +000060@public
61 int count;
62}
63@property int count;
64@end
65
Douglas Gregorccff3012012-01-13 16:56:26 +000066void test5(Test5* t5) {
67 if (t5.count < 2) { }
68 if (t5->count < 2) { }
Douglas Gregorbf3a8262012-01-12 16:11:24 +000069}
70