summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/method-6.m
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/objc.dg/method-6.m')
-rw-r--r--gcc/testsuite/objc.dg/method-6.m26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/objc.dg/method-6.m b/gcc/testsuite/objc.dg/method-6.m
new file mode 100644
index 00000000000..212958b55c7
--- /dev/null
+++ b/gcc/testsuite/objc.dg/method-6.m
@@ -0,0 +1,26 @@
+/* Check that sending messages to variables of type 'Class' does not involve instance methods. */
+/* Author: Ziemowit Laski <zlaski@apple.com> */
+/* { dg-do compile } */
+
+#include <objc/Protocol.h>
+
+@interface Base
+- (unsigned)port;
+- (id)starboard;
+@end
+
+@interface Derived: Base
+- (Object *)port;
++ (Protocol *)port;
+@end
+
+id foo(void) {
+ Class receiver;
+ id p = [receiver port]; /* there should be no warnings here! */
+ p = [receiver starboard]; /* { dg-warning ".Class. may not respond to .\\+starboard." } */
+ /* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 20 } */
+ /* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 20 } */
+ /* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 20 } */
+ p = [Class port]; /* { dg-error ".Class. is not an Objective\\-C class name or alias" } */
+ return p;
+}