summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjC/warn-superclass-method-mismatch.m
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-08-04 01:07:16 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-08-04 01:07:16 +0000
commit10ff786e1eb8d114a1740db498ec1864a8cc4b2c (patch)
treec06f92ceff74a8f8fed591dc809c1ef3318861f6 /clang/test/SemaObjC/warn-superclass-method-mismatch.m
parent1624df626d1067056a7d6e7a49f4a6b9db0c8a1e (diff)
downloadbcm5719-llvm-10ff786e1eb8d114a1740db498ec1864a8cc4b2c.tar.gz
bcm5719-llvm-10ff786e1eb8d114a1740db498ec1864a8cc4b2c.zip
Compare matching selectors in current and
super class(s) and warn on any parameter type mismatch if potentially unsafe. llvm-svn: 78029
Diffstat (limited to 'clang/test/SemaObjC/warn-superclass-method-mismatch.m')
-rw-r--r--clang/test/SemaObjC/warn-superclass-method-mismatch.m46
1 files changed, 46 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 00000000000..eb75eade0a1
--- /dev/null
+++ b/clang/test/SemaObjC/warn-superclass-method-mismatch.m
@@ -0,0 +1,46 @@
+// RUN: clang-cc -fsyntax-only -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;
++ method3: (int)x1 : (Base *)x2 : (float)x3; // expected-note {{previous declaration is here}}
++ mathod4: (id)x1;
+@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 *'}}
+@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.
+
+}
+
+
+
+
OpenPOWER on IntegriCloud