aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/objc.dg/call-super-2.m
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/objc.dg/call-super-2.m
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/objc.dg/call-super-2.m')
-rw-r--r--gcc-4.9/gcc/testsuite/objc.dg/call-super-2.m146
1 files changed, 146 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/objc.dg/call-super-2.m b/gcc-4.9/gcc/testsuite/objc.dg/call-super-2.m
new file mode 100644
index 000000000..10c625272
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/objc.dg/call-super-2.m
@@ -0,0 +1,146 @@
+/* Check if casting 'self' or 'super' affects message lookup in the correct way. */
+/* Contributed by Ziemowit Laski <zlaski@apple.com>. */
+/* { dg-do compile } */
+
+#include "../objc-obj-c++-shared/TestsuiteObject.h"
+#include "../objc-obj-c++-shared/runtime.h"
+#include <stddef.h>
+
+/* FIXME: This is temporary. At the moment, the compiler, when
+ compiling for the GNU runtime and doing method checks, only
+ recognizes objc_get_class(), and not objc_getClass(). So
+ temporarily force objc_get_class() to be used. */
+#ifndef __NEXT_RUNTIME__
+# define objc_getClass(C) objc_get_class(C)
+#endif
+
+@protocol Func
++ (int) class_func0;
+- (int) instance_func0;
+@end
+
+@interface Derived: TestsuiteObject
++ (int) class_func1;
++ (int) class_func2;
++ (int) class_func3;
++ (int) class_func4;
++ (int) class_func5;
++ (int) class_func6;
++ (int) class_func7;
+- (int) instance_func1;
+- (int) instance_func2;
+- (int) instance_func3;
+- (int) instance_func4;
+- (int) instance_func5;
+- (int) instance_func6;
+- (int) instance_func7;
+@end
+
+@interface Derived (Categ)
++ (int) categ_class_func1;
++ (int) categ_class_func2;
+- (int) categ_instance_func1;
+- (int) categ_instance_func2;
+@end
+
+@implementation Derived
++ (int) class_func1
+{
+ int i = (size_t)[self class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
+ return i + (size_t)[super class_func0]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
+}
++ (int) class_func2
+{
+ int i = [(id <Func>)self class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
+ i += [(id <Func>)super class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
+ i += [(Class <Func>)self class_func0];
+ return i + [(Class <Func>)super class_func0];
+}
++ (int) class_func3
+{
+ return [(TestsuiteObject <Func> *)super class_func0];
+}
++ (int) class_func4
+{
+ return [(Derived <Func> *)super class_func0];
+}
++ (int) class_func5
+{
+ int i = (size_t)[Derived class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
+ return i + (size_t)[TestsuiteObject class_func0]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
+}
++ (int) class_func6
+{
+ return (size_t)[objc_getClass("TestsuiteObject") class_func1]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func1." } */
+}
++ (int) class_func7
+{
+ return [objc_getClass("Derived") class_func1];
+}
+- (int) instance_func1
+{
+ int i = (size_t)[self instance_func0]; /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
+ return i + (size_t)[super instance_func0]; /* { dg-warning ".TestsuiteObject. may not respond to .\\-instance_func0." } */
+}
+- (int) instance_func2
+{
+ return [(id <Func>)super instance_func0];
+}
+- (int) instance_func3
+{
+ return [(TestsuiteObject <Func> *)super instance_func0];
+}
+- (int) instance_func4
+{
+ return [(Derived <Func> *)super instance_func0];
+}
+- (int) instance_func5
+{
+ int i = (size_t)[Derived instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+instance_func1." } */
+ return i + (size_t)[TestsuiteObject instance_func1]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+instance_func1." } */
+}
+- (int) instance_func6
+{
+ return (size_t)[objc_getClass("TestsuiteObject") class_func1]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func1." } */
+}
+- (int) instance_func7
+{
+ return [objc_getClass("Derived") class_func1];
+}
+@end
+
+@implementation Derived (Categ)
++ (int) categ_class_func1
+{
+ int i = (size_t)[self class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
+ i += [self class_func1];
+ i += [self categ_class_func2];
+ i += (size_t)[self categ_instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+categ_instance_func1." } */
+ return i + (size_t)[super class_func0]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
+}
++ (int) categ_class_func2
+{
+ int i = [(id <Func>)self class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
+ i += [(id <Func>)super class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
+ i += [(Class <Func>)self class_func0];
+ return i + [(Class <Func>)super class_func0];
+}
+- (int) categ_instance_func1
+{
+ int i = (size_t)[self instance_func0]; /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
+ i += [(Derived <Func> *)self categ_instance_func2];
+ i += (size_t)[(TestsuiteObject <Func> *)self categ_instance_func2]; /* { dg-warning ".TestsuiteObject. may not respond to .\\-categ_instance_func2." } */
+ /* { dg-warning ".\\-categ_instance_func2. not found in protocol" "" { target *-*-* } 132 } */
+ i += (size_t)[(id <Func>)self categ_instance_func2]; /* { dg-warning ".\\-categ_instance_func2. not found in protocol" } */
+ i += [(id)self categ_instance_func2];
+ return i + (size_t)[super instance_func0]; /* { dg-warning ".TestsuiteObject. may not respond to .\\-instance_func0." } */
+}
+- (int) categ_instance_func2
+{
+ return [(id <Func>)super instance_func0];
+}
+@end
+
+/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */
+/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */
+/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */