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