2010-04-13 01:03:29 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
|
|
|
|
|
|
|
|
void takevoidptr(void*);
|
|
|
|
|
2008-11-18 06:29:32 +08:00
|
|
|
|
|
|
|
@interface Foo
|
|
|
|
- iMethod;
|
|
|
|
+ cMethod;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface A
|
2010-04-12 14:36:00 +08:00
|
|
|
+ superClassMethod;
|
2010-04-13 01:03:29 +08:00
|
|
|
- (void)instanceMethod;
|
2008-11-18 06:29:32 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface B : A
|
|
|
|
- (void)instanceMethod;
|
|
|
|
+ classMethod;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation B
|
|
|
|
|
|
|
|
- (void)instanceMethod {
|
2010-04-11 16:28:14 +08:00
|
|
|
[super iMethod]; // expected-warning{{'A' may not respond to 'iMethod')}}
|
2010-04-13 01:03:29 +08:00
|
|
|
|
|
|
|
// Use of super in a block is ok and does codegen to the right thing.
|
|
|
|
// rdar://7852959
|
|
|
|
takevoidptr(^{
|
|
|
|
[super instanceMethod];
|
|
|
|
});
|
2008-11-18 06:29:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
+ classMethod {
|
|
|
|
[super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
|
2010-04-12 14:36:00 +08:00
|
|
|
|
|
|
|
id X[] = { [ super superClassMethod] };
|
2010-04-13 01:09:27 +08:00
|
|
|
id Y[] = {
|
|
|
|
[ super.superClassMethod iMethod],
|
|
|
|
super.superClassMethod,
|
|
|
|
(id)super.superClassMethod // not a cast of super: rdar://7853261
|
|
|
|
};
|
2009-07-22 08:43:08 +08:00
|
|
|
return 0;
|
2008-11-18 06:29:32 +08:00
|
|
|
}
|
|
|
|
@end
|
2008-11-19 23:54:23 +08:00
|
|
|
|
|
|
|
@interface XX
|
|
|
|
- m;
|
|
|
|
@end
|
|
|
|
|
|
|
|
void f(id super) {
|
|
|
|
[super m];
|
|
|
|
}
|
|
|
|
void f0(int super) {
|
2009-03-11 11:47:47 +08:00
|
|
|
[super m]; // expected-warning{{receiver type 'int' is not 'id'}} \
|
2009-03-10 05:19:16 +08:00
|
|
|
expected-warning {{method '-m' not found (return type defaults to 'id')}}
|
2008-11-19 23:54:23 +08:00
|
|
|
}
|
2010-10-20 09:32:02 +08:00
|
|
|
void f1(id puper) {
|
|
|
|
[super m]; // expected-error{{use of undeclared identifier 'super'}}
|
2008-11-19 23:54:23 +08:00
|
|
|
}
|
2010-01-23 07:04:44 +08:00
|
|
|
|
|
|
|
// radar 7400691
|
|
|
|
typedef Foo super;
|
|
|
|
|
2010-04-11 16:28:14 +08:00
|
|
|
typedef Foo FooTD;
|
|
|
|
|
2010-01-23 07:04:44 +08:00
|
|
|
void test() {
|
2010-04-11 16:28:14 +08:00
|
|
|
[FooTD cMethod];
|
2010-01-23 07:04:44 +08:00
|
|
|
[super cMethod];
|
|
|
|
}
|
2010-04-12 14:20:33 +08:00
|
|
|
|
|
|
|
struct SomeStruct {
|
|
|
|
int X;
|
|
|
|
};
|
|
|
|
|
|
|
|
int test2() {
|
|
|
|
struct SomeStruct super = { 0 };
|
|
|
|
return super.X;
|
|
|
|
}
|
2010-04-12 14:27:57 +08:00
|
|
|
|
|
|
|
int test3() {
|
|
|
|
id super = 0;
|
|
|
|
[(B*)super instanceMethod];
|
|
|
|
int *s1 = (int*)super;
|
2010-04-12 14:36:00 +08:00
|
|
|
|
|
|
|
id X[] = { [ super superClassMethod] };
|
2010-04-12 14:27:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|