1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -Wsuper-class-method-mismatch -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc@interface Root 4*f4a2713aSLionel Sambuc-(void) method_r: (char)ch : (float*)f1 : (int*) x; // expected-note {{previous declaration is here}} 5*f4a2713aSLionel Sambuc@end 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc@class Sub; 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc@interface Base : Root 10*f4a2713aSLionel Sambuc-(void) method: (int*) x; // expected-note {{previous declaration is here}} 11*f4a2713aSLionel Sambuc-(void) method1: (Base*) x; // expected-note {{previous declaration is here}} 12*f4a2713aSLionel Sambuc-(void) method2: (Sub*) x; // expected-note{{passing argument to parameter 'x' here}} 13*f4a2713aSLionel Sambuc+ method3: (int)x1 : (Base *)x2 : (float)x3; // expected-note {{previous declaration is here}} 14*f4a2713aSLionel Sambuc+ mathod4: (id)x1; 15*f4a2713aSLionel Sambuc- method5: (int) x : (double) d; // expected-note {{previous declaration is here}} 16*f4a2713aSLionel Sambuc- method6: (int) x : (float) d; // expected-note {{previous declaration is here}} 17*f4a2713aSLionel Sambuc@end 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambucstruct A { 20*f4a2713aSLionel Sambuc int x,y,z; 21*f4a2713aSLionel Sambuc}; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc@interface Sub : Base 24*f4a2713aSLionel Sambuc-(void) method: (struct A*) a; // expected-warning {{method parameter type 'struct A *' does not match super class method parameter type 'int *'}} 25*f4a2713aSLionel Sambuc-(void) method1: (Sub*) x; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'Base *'}} 26*f4a2713aSLionel Sambuc-(void) method2: (Base*) x; // no need to warn. At call point we warn if need be. 27*f4a2713aSLionel Sambuc+ method3: (int)x1 : (Sub *)x2 : (float)x3; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'Base *'}} 28*f4a2713aSLionel Sambuc+ mathod4: (Base*)x1; 29*f4a2713aSLionel Sambuc-(void) method_r: (char)ch : (float*)f1 : (Sub*) x; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'int *'}} 30*f4a2713aSLionel Sambuc- method5: (int) x : (float) d; // expected-warning {{method parameter type 'float' does not match super class method parameter type 'double'}} 31*f4a2713aSLionel Sambuc- method6: (int) x : (double) d; // expected-warning {{method parameter type 'double' does not match super class method parameter type 'float'}} 32*f4a2713aSLionel Sambuc@end 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambucvoid f(Base *base, Sub *sub) { 35*f4a2713aSLionel Sambuc int x; 36*f4a2713aSLionel Sambuc [base method:&x]; // warn. if base is actually 'Sub' it will use -[Sub method] with wrong arguments 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc Base *b; 39*f4a2713aSLionel Sambuc [base method1:b]; // if base is actuall 'Sub' it will use [Sub method1] with wrong argument. 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambuc [base method2:b]; // expected-warning {{}} 42*f4a2713aSLionel Sambuc 43*f4a2713aSLionel Sambuc Sub *s; 44*f4a2713aSLionel Sambuc [base method2:s]; // if base is actually 'Sub' OK. Either way OK. 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc} 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambuc 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc 51