This patch implements some of the more obscure type-checking involving
'id' quallified with protocols and static types which have categories and
inheritance which implement these protocols.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45294 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/objc-comptypes-5.m b/test/Sema/objc-comptypes-5.m
new file mode 100644
index 0000000..646c6e5
--- /dev/null
+++ b/test/Sema/objc-comptypes-5.m
@@ -0,0 +1,37 @@
+// RUN: clang -fsyntax-only -verify %s
+
+extern void foo();
+#include <objc/objc.h>
+
+@protocol MyProtocol
+- (void) method;
+@end
+
+@interface MyClass
+@end
+
+@interface MyClass (Addition) <MyProtocol>
+- (void) method;
+@end
+
+@interface MyOtherClass : MyClass
+@end
+
+int main()
+{
+  id <MyProtocol> obj_id_p = nil;
+  MyClass *obj_c_cat_p = nil;
+  MyOtherClass *obj_c_super_p = nil;
+
+  obj_c_cat_p = obj_id_p;   // expected-error {{incompatible types assigning 'id<MyProtocol>' to 'MyClass *'}}
+  obj_c_super_p = obj_id_p;  // expected-error {{incompatible types assigning 'id<MyProtocol>' to 'MyOtherClass *'}}
+  obj_id_p = obj_c_cat_p;  /* Ok */
+  obj_id_p = obj_c_super_p; /* Ok */
+
+  if (obj_c_cat_p == obj_id_p) foo(); /* Ok */
+  if (obj_c_super_p == obj_id_p) foo() ; /* Ok */
+  if (obj_id_p == obj_c_cat_p)  foo(); /* Ok */
+  if (obj_id_p == obj_c_super_p)  foo(); /* Ok */
+
+  return 0;
+}