summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/proto-init-mimatch-1.m
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/objc.dg/proto-init-mimatch-1.m')
-rw-r--r--gcc/testsuite/objc.dg/proto-init-mimatch-1.m35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/objc.dg/proto-init-mimatch-1.m b/gcc/testsuite/objc.dg/proto-init-mimatch-1.m
new file mode 100644
index 000000000..64e52e812
--- /dev/null
+++ b/gcc/testsuite/objc.dg/proto-init-mimatch-1.m
@@ -0,0 +1,35 @@
+/* Test to warn on protocol mismatch in a variety of initializations. */
+
+/* { dg-do compile } */
+
+typedef struct objc_class *Class;
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+@protocol NSObject
+@end
+
+@interface NSObject <NSObject>
+@end
+
+@protocol NSCopying
+- (void)copyWithZone;
+@end
+
+@interface Foo:NSObject <NSCopying>
+@end
+
+
+extern id <NSObject> NSCopyObject();
+
+@implementation Foo
+- (void)copyWithZone {
+ Foo *copy = NSCopyObject(); /* { dg-warning "type \\'id <NSObject>\\' does not conform to the \\'NSCopying\\' protocol" } */
+
+ Foo<NSObject,NSCopying> *g = NSCopyObject(); /* { dg-warning "type \\'id <NSObject>\\' does not conform to the \\'NSCopying\\' protocol" } */
+
+ id<NSObject,NSCopying> h = NSCopyObject(); /* { dg-warning "type \\'id <NSObject>\\' does not conform to the \\'NSCopying\\' protocol" } */
+}
+@end