summaryrefslogtreecommitdiff
path: root/clang/test/SemaObjCXX/properties.mm
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaObjCXX/properties.mm
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaObjCXX/properties.mm')
-rw-r--r--clang/test/SemaObjCXX/properties.mm108
1 files changed, 108 insertions, 0 deletions
diff --git a/clang/test/SemaObjCXX/properties.mm b/clang/test/SemaObjCXX/properties.mm
new file mode 100644
index 0000000..3c6b138
--- /dev/null
+++ b/clang/test/SemaObjCXX/properties.mm
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-objc-root-class %s
+
+struct X {
+ void f() const;
+ ~X();
+};
+
+@interface A {
+ X x_;
+}
+
+- (const X&)x;
+- (void)setx:(const X&)other;
+@end
+
+@implementation A
+
+- (const X&)x { return x_; }
+- (void)setx:(const X&)other { x_ = other; }
+- (void)method {
+ self.x.f();
+}
+@end
+
+// rdar://problem/10444030
+@interface Test2
+- (void) setY: (int) y;
+- (int) z;
+@end
+void test2(Test2 *a) {
+ auto y = a.y; // expected-error {{expected getter method not found on object of type 'Test2 *'}}
+ auto z = a.z;
+}
+
+// rdar://problem/10672108
+@interface Test3
+- (int) length;
+@end
+void test3(Test3 *t) {
+ char vla[t.length] = {}; // expected-error {{variable-sized object may not be initialized}}
+ char *heaparray = new char[t.length];
+}
+
+// <rdar://problem/10672501>
+namespace std {
+ template<typename T> void count();
+}
+
+@interface Test4
+- (X&) prop;
+@end
+
+void test4(Test4 *t) {
+ (void)const_cast<const X&>(t.prop);
+ (void)dynamic_cast<X&>(t.prop);
+ (void)reinterpret_cast<int&>(t.prop);
+}
+
+@interface Test5 {
+@public
+ int count;
+}
+@property int count;
+@end
+
+void test5(Test5* t5) {
+ if (t5.count < 2) { }
+ if (t5->count < 2) { }
+}
+
+
+@interface Test6
++ (Class)class;
+- (Class)class;
+@end
+
+void test6(Test6 *t6) {
+ Class x = t6.class;
+ Class x2 = Test6.class;
+}
+
+template<typename T>
+void test6_template(T *t6) {
+ Class x = t6.class;
+}
+
+template void test6_template(Test6*);
+
+// rdar://problem/10965735
+struct Test7PointerMaker {
+ operator char *() const;
+};
+@interface Test7
+- (char*) implicit_property;
+- (char) bad_implicit_property;
+- (Test7PointerMaker) implicit_struct_property;
+@property int *explicit_property;
+@property int bad_explicit_property;
+@property Test7PointerMaker explicit_struct_property;
+@end
+void test7(Test7 *ptr) {
+ delete ptr.implicit_property;
+ delete ptr.bad_implicit_property; // expected-error {{cannot delete expression of type 'char'}}
+ delete ptr.explicit_property;
+ delete ptr.bad_explicit_property; // expected-error {{cannot delete expression of type 'int'}}
+ delete ptr.implicit_struct_property;
+ delete ptr.explicit_struct_property;
+}