1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-objc-root-class %s 2 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(); 22} 23@end 24 25// 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 *'}} 32 auto z = a.z; 33} 34 35// rdar://problem/10672108 36@interface Test3 37- (int) length; 38@end 39void test3(Test3 *t) { 40 char vla[t.length] = {}; // expected-error {{variable-sized object may not be initialized}} 41 char *heaparray = new char[t.length]; 42} 43 44// <rdar://problem/10672501> 45namespace std { 46 template<typename T> void count(); 47} 48 49@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 { 60@public 61 int count; 62} 63@property int count; 64@end 65 66void test5(Test5* t5) { 67 if (t5.count < 2) { } 68 if (t5->count < 2) { } 69} 70 71 72@interface Test6 73+ (Class)class; 74- (Class)class; 75@end 76 77void test6(Test6 *t6) { 78 Class x = t6.class; 79 Class x2 = Test6.class; 80} 81 82template<typename T> 83void test6_template(T *t6) { 84 Class x = t6.class; 85} 86 87template void test6_template(Test6*); 88 89// rdar://problem/10965735 90struct Test7PointerMaker { 91 operator char *() const; 92}; 93@interface Test7 94- (char*) implicit_property; 95- (char) bad_implicit_property; 96- (Test7PointerMaker) implicit_struct_property; 97@property int *explicit_property; 98@property int bad_explicit_property; 99@property Test7PointerMaker explicit_struct_property; 100@end 101void test7(Test7 *ptr) { 102 delete ptr.implicit_property; 103 delete ptr.bad_implicit_property; // expected-error {{cannot delete expression of type 'char'}} 104 delete ptr.explicit_property; 105 delete ptr.bad_explicit_property; // expected-error {{cannot delete expression of type 'int'}} 106 delete ptr.implicit_struct_property; 107 delete ptr.explicit_struct_property; 108} 109