summaryrefslogtreecommitdiff
path: root/clang/test/SemaObjC/id-isa-ref.m
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/SemaObjC/id-isa-ref.m
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/SemaObjC/id-isa-ref.m')
-rw-r--r--clang/test/SemaObjC/id-isa-ref.m35
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/id-isa-ref.m b/clang/test/SemaObjC/id-isa-ref.m
new file mode 100644
index 0000000..c2debb0
--- /dev/null
+++ b/clang/test/SemaObjC/id-isa-ref.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef struct objc_object {
+ struct objc_class *isa;
+} *id;
+
+@interface NSObject {
+ struct objc_class *isa;
+}
+@end
+@interface Whatever : NSObject
++self;
+@end
+
+static void func() {
+
+ id x;
+
+ // rdar://8290002
+ [(*x).isa self]; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
+ [x->isa self]; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
+
+ Whatever *y;
+
+ // GCC allows this, with the following warning:
+ // instance variable 'isa' is @protected; this will be a hard error in the future
+ //
+ // FIXME: see if we can avoid the 2 warnings that follow the error.
+ [(*y).isa self]; // expected-error {{instance variable 'isa' is protected}} \
+ expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
+ expected-warning{{method '-self' not found (return type defaults to 'id')}}
+ [y->isa self]; // expected-error {{instance variable 'isa' is protected}} \
+ expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
+ expected-warning{{method '-self' not found (return type defaults to 'id')}}
+}