diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaObjC/warn-superclass-method-mismatch.m | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaObjC/warn-superclass-method-mismatch.m')
-rw-r--r-- | clang/test/SemaObjC/warn-superclass-method-mismatch.m | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/warn-superclass-method-mismatch.m b/clang/test/SemaObjC/warn-superclass-method-mismatch.m new file mode 100644 index 0000000..5205473 --- /dev/null +++ b/clang/test/SemaObjC/warn-superclass-method-mismatch.m @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -fsyntax-only -Wsuper-class-method-mismatch -verify %s + +@interface Root +-(void) method_r: (char)ch : (float*)f1 : (int*) x; // expected-note {{previous declaration is here}} +@end + +@class Sub; + +@interface Base : Root +-(void) method: (int*) x; // expected-note {{previous declaration is here}} +-(void) method1: (Base*) x; // expected-note {{previous declaration is here}} +-(void) method2: (Sub*) x; // expected-note{{passing argument to parameter 'x' here}} ++ method3: (int)x1 : (Base *)x2 : (float)x3; // expected-note {{previous declaration is here}} ++ mathod4: (id)x1; +- method5: (int) x : (double) d; // expected-note {{previous declaration is here}} +- method6: (int) x : (float) d; // expected-note {{previous declaration is here}} +@end + +struct A { + int x,y,z; +}; + +@interface Sub : Base +-(void) method: (struct A*) a; // expected-warning {{method parameter type 'struct A *' does not match super class method parameter type 'int *'}} +-(void) method1: (Sub*) x; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'Base *'}} +-(void) method2: (Base*) x; // no need to warn. At call point we warn if need be. ++ method3: (int)x1 : (Sub *)x2 : (float)x3; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'Base *'}} ++ mathod4: (Base*)x1; +-(void) method_r: (char)ch : (float*)f1 : (Sub*) x; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'int *'}} +- method5: (int) x : (float) d; // expected-warning {{method parameter type 'float' does not match super class method parameter type 'double'}} +- method6: (int) x : (double) d; // expected-warning {{method parameter type 'double' does not match super class method parameter type 'float'}} +@end + +void f(Base *base, Sub *sub) { + int x; + [base method:&x]; // warn. if base is actually 'Sub' it will use -[Sub method] with wrong arguments + + Base *b; + [base method1:b]; // if base is actuall 'Sub' it will use [Sub method1] with wrong argument. + + [base method2:b]; // expected-warning {{}} + + Sub *s; + [base method2:s]; // if base is actually 'Sub' OK. Either way OK. + +} + + + + |