1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambucvoid takevoidptr(void*); 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc@interface Foo 7*f4a2713aSLionel Sambuc- iMethod; 8*f4a2713aSLionel Sambuc+ cMethod; 9*f4a2713aSLionel Sambuc@end 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc@interface A 12*f4a2713aSLionel Sambuc+ superClassMethod; 13*f4a2713aSLionel Sambuc- (void)instanceMethod; 14*f4a2713aSLionel Sambuc@end 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc@interface B : A 17*f4a2713aSLionel Sambuc- (void)instanceMethod; 18*f4a2713aSLionel Sambuc+ classMethod; 19*f4a2713aSLionel Sambuc@end 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambuc@implementation B 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc- (void)instanceMethod { 24*f4a2713aSLionel Sambuc [super iMethod]; // expected-warning{{'A' may not respond to 'iMethod'}} 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc // Use of super in a block is ok and does codegen to the right thing. 27*f4a2713aSLionel Sambuc // rdar://7852959 28*f4a2713aSLionel Sambuc takevoidptr(^{ 29*f4a2713aSLionel Sambuc [super instanceMethod]; 30*f4a2713aSLionel Sambuc }); 31*f4a2713aSLionel Sambuc} 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambuc+ classMethod { 34*f4a2713aSLionel Sambuc [super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}} 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc id X[] = { [ super superClassMethod] }; 37*f4a2713aSLionel Sambuc id Y[] = { 38*f4a2713aSLionel Sambuc [ super.superClassMethod iMethod], 39*f4a2713aSLionel Sambuc super.superClassMethod, 40*f4a2713aSLionel Sambuc (id)super.superClassMethod // not a cast of super: rdar://7853261 41*f4a2713aSLionel Sambuc }; 42*f4a2713aSLionel Sambuc return 0; 43*f4a2713aSLionel Sambuc} 44*f4a2713aSLionel Sambuc@end 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc@interface XX 47*f4a2713aSLionel Sambuc- m; 48*f4a2713aSLionel Sambuc@end 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambucvoid f(id super) { 51*f4a2713aSLionel Sambuc [super m]; 52*f4a2713aSLionel Sambuc} 53*f4a2713aSLionel Sambucvoid f0(int super) { 54*f4a2713aSLionel Sambuc [super m]; // expected-warning{{receiver type 'int' is not 'id'}} 55*f4a2713aSLionel Sambuc} 56*f4a2713aSLionel Sambucvoid f1(id puper) { // expected-note {{'puper' declared here}} 57*f4a2713aSLionel Sambuc [super m]; // expected-error{{use of undeclared identifier 'super'}} 58*f4a2713aSLionel Sambuc} 59*f4a2713aSLionel Sambuc 60*f4a2713aSLionel Sambuc// radar 7400691 61*f4a2713aSLionel Sambuctypedef Foo super; 62*f4a2713aSLionel Sambuc 63*f4a2713aSLionel Sambuctypedef Foo FooTD; 64*f4a2713aSLionel Sambuc 65*f4a2713aSLionel Sambucvoid test() { 66*f4a2713aSLionel Sambuc [FooTD cMethod]; 67*f4a2713aSLionel Sambuc [super cMethod]; 68*f4a2713aSLionel Sambuc} 69*f4a2713aSLionel Sambuc 70*f4a2713aSLionel Sambucstruct SomeStruct { 71*f4a2713aSLionel Sambuc int X; 72*f4a2713aSLionel Sambuc}; 73*f4a2713aSLionel Sambuc 74*f4a2713aSLionel Sambucint test2() { 75*f4a2713aSLionel Sambuc struct SomeStruct super = { 0 }; 76*f4a2713aSLionel Sambuc return super.X; 77*f4a2713aSLionel Sambuc} 78*f4a2713aSLionel Sambuc 79*f4a2713aSLionel Sambucint test3() { 80*f4a2713aSLionel Sambuc id super = 0; 81*f4a2713aSLionel Sambuc [(B*)super instanceMethod]; 82*f4a2713aSLionel Sambuc int *s1 = (int*)super; 83*f4a2713aSLionel Sambuc 84*f4a2713aSLionel Sambuc id X[] = { [ super superClassMethod] }; 85*f4a2713aSLionel Sambuc return 0; 86*f4a2713aSLionel Sambuc} 87