From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/objc.dg/call-super-2.m | 138 +++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 gcc/testsuite/objc.dg/call-super-2.m (limited to 'gcc/testsuite/objc.dg/call-super-2.m') diff --git a/gcc/testsuite/objc.dg/call-super-2.m b/gcc/testsuite/objc.dg/call-super-2.m new file mode 100644 index 000000000..190c407f7 --- /dev/null +++ b/gcc/testsuite/objc.dg/call-super-2.m @@ -0,0 +1,138 @@ +/* Check if casting 'self' or 'super' affects message lookup in the correct way. */ +/* Contributed by Ziemowit Laski . */ +/* { dg-do compile } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include "../objc-obj-c++-shared/next-mapping.h" +#include + +@protocol Func ++ (int) class_func0; +- (int) instance_func0; +@end + +@interface Derived: Object ++ (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 ".Object. may not respond to .\\+class_func0." } */ +} ++ (int) class_func2 +{ + int i = [(id )self class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */ + i += [(id )super class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */ + i += [(Class )self class_func0]; + return i + [(Class )super class_func0]; +} ++ (int) class_func3 +{ + return [(Object *)super class_func0]; +} ++ (int) class_func4 +{ + return [(Derived *)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)[Object class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */ +} ++ (int) class_func6 +{ + return (size_t)[objc_get_class("Object") class_func1]; /* { dg-warning ".Object. may not respond to .\\+class_func1." } */ +} ++ (int) class_func7 +{ + return [objc_get_class("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 ".Object. may not respond to .\\-instance_func0." } */ +} +- (int) instance_func2 +{ + return [(id )super instance_func0]; +} +- (int) instance_func3 +{ + return [(Object *)super instance_func0]; +} +- (int) instance_func4 +{ + return [(Derived *)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)[Object instance_func1]; /* { dg-warning ".Object. may not respond to .\\+instance_func1." } */ +} +- (int) instance_func6 +{ + return (size_t)[objc_get_class("Object") class_func1]; /* { dg-warning ".Object. may not respond to .\\+class_func1." } */ +} +- (int) instance_func7 +{ + return [objc_get_class("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 ".Object. may not respond to .\\+class_func0." } */ +} ++ (int) categ_class_func2 +{ + int i = [(id )self class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */ + i += [(id )super class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */ + i += [(Class )self class_func0]; + return i + [(Class )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 *)self categ_instance_func2]; + i += (size_t)[(Object *)self categ_instance_func2]; /* { dg-warning ".Object. may not respond to .\\-categ_instance_func2." } */ + /* { dg-warning ".\\-categ_instance_func2. not found in protocol" "" { target *-*-* } 124 } */ + i += (size_t)[(id )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 ".Object. may not respond to .\\-instance_func0." } */ +} +- (int) categ_instance_func2 +{ + return [(id )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 } */ -- cgit v1.2.3