]> granicus.if.org Git - clang/commitdiff
Another test for objective-c type comparison.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 20 Dec 2007 22:53:29 +0000 (22:53 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 20 Dec 2007 22:53:29 +0000 (22:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45271 91177308-0d34-0410-b5e6-96231b3b80d8

test/Sema/objc-comptypes-2.m [new file with mode: 0644]

diff --git a/test/Sema/objc-comptypes-2.m b/test/Sema/objc-comptypes-2.m
new file mode 100644 (file)
index 0000000..3a60bed
--- /dev/null
@@ -0,0 +1,36 @@
+// RUN: clang -fsyntax-only -verify %s
+
+#include <objc/objc.h>
+
+@protocol MyProtocol
+- (void) foo;
+@end
+
+@interface MyClass
+@end
+
+int main()
+{
+  id obj = nil;
+  id<MyProtocol> obj_p = nil;
+  MyClass *obj_c = nil;
+  Class obj_C = Nil;
+
+  /* All these casts should generate no warnings.  */
+
+  obj = (id)obj_p;
+  obj = (id)obj_c;
+  obj = (id)obj_C;
+  obj_c = (MyClass *)obj;
+  obj_c = (MyClass *)obj_p;
+  obj_c = (MyClass *)obj_C;
+  obj_p = (id<MyProtocol>)obj;
+  obj_p = (id<MyProtocol>)obj_c;
+  obj_p = (id<MyProtocol>)obj_C;
+  obj_C = (Class)obj;
+  obj_C = (Class)obj_p;
+  obj_C = (Class)obj_c;
+  
+
+  return 0;
+}