1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-objc-root-class %s
13 - (void)setx:(const X&)other;
18 - (const X&)x { return x_; }
19 - (void)setx:(const X&)other { x_ = other; }
26 - (void) setY: (int) y;
29 void test2(Test2 *a) {
30 auto y = a.y; // expected-error {{no getter method for read from property}}
37 void test3(Test3 *t) {
38 char vla[t.length] = {}; // expected-error {{variable-sized object may not be initialized}} \
39 expected-warning {{variable length arrays in C++ are a Clang extension}}
40 char *heaparray = new char[t.length];
44 template<typename T> void count();
51 void test4(Test4 *t) {
52 (void)const_cast<const X&>(t.prop);
53 (void)dynamic_cast<X&>(t.prop);
54 (void)reinterpret_cast<int&>(t.prop);
64 void test5(Test5* t5) {
66 if (t5->count < 2) { }
75 void test6(Test6 *t6) {
77 Class x2 = Test6.class;
81 void test6_template(T *t6) {
85 template void test6_template(Test6*);
87 struct Test7PointerMaker {
88 operator char *() const;
91 - (char*) implicit_property;
92 - (char) bad_implicit_property;
93 - (Test7PointerMaker) implicit_struct_property;
94 @property int *explicit_property;
95 @property int bad_explicit_property;
96 @property Test7PointerMaker explicit_struct_property;
98 void test7(Test7 *ptr) {
99 delete ptr.implicit_property;
100 delete ptr.bad_implicit_property; // expected-error {{cannot delete expression of type 'char'}}
101 delete ptr.explicit_property;
102 delete ptr.bad_explicit_property; // expected-error {{cannot delete expression of type 'int'}}
103 delete ptr.implicit_struct_property;
104 delete ptr.explicit_struct_property;
107 // Make sure the returned value from property assignment is void,
108 // because there isn't any other viable way to handle it for
109 // non-trivial classes.
117 NonTrivial2(const NonTrivial2&);
119 @interface TestNonTrivial
120 @property(assign, nonatomic) NonTrivial1 p1;
121 @property(assign, nonatomic) NonTrivial2 p2;
123 TestNonTrivial *TestNonTrivialObj;
125 extern void* VoidType;
126 extern decltype(TestNonTrivialObj.p1 = NonTrivial1())* VoidType;
127 extern decltype(TestNonTrivialObj.p2 = NonTrivial2())* VoidType;
132 char operator[](int i) const { return _data[i]; }
136 @property test9::CString name;
139 char test(Test9 *t) {
145 struct A { operator const char*(); };
146 struct B { operator const char*(); };
149 @property test10::A a;
150 @property test10::B b;
154 void test(Test10 *t) {
157 (void) "help"[t.index];
158 (void) t.index["help"];
164 @interface PropertyOfItself
165 @property (readonly, nonatomic) PropertyOfItself x; // expected-error {{interface type cannot be statically allocated}}
167 @implementation PropertyOfItself
175 typedef struct CGSize CGSize;
181 typedef struct CGRect CGRect;
183 typedef CGRect NSRect;
184 void HappySetFrame(NSRect frame) {}
186 __attribute__((objc_root_class))
188 @property CGRect frame;
191 @implementation NSObject
194 HappySetFrame({{0,0}, {13,14}});
195 [self setFrame: {{0,0}, {13,14}}];
196 self.frame = {{0,0}, {13,14}};
197 self.frame = (CGRect){{3,5}, {13,14}};