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