summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjC
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-10-26 00:53:53 +0000
committerJohn McCall <rjmccall@apple.com>2010-10-26 00:53:53 +0000
commit710d2a831ce15564368d742bcd1244b12f64f195 (patch)
tree1bb822830bc00136f66efa1dc3fbf615f973d874 /clang/test/SemaObjC
parent90b2ac269608a52c73634ea997301d604068b41e (diff)
downloadbcm5719-llvm-710d2a831ce15564368d742bcd1244b12f64f195.tar.gz
bcm5719-llvm-710d2a831ce15564368d742bcd1244b12f64f195.zip
Pending further discussion, re-enable warnings for Objective C
covariant/contravariant overrides and implementations, but do so under control of a new flag (-Wno-objc-covariant-overrides, which yes does cover contravariance too). *At least* the covariance cases will probably be enabled by default shortly, but that's not totally uncontroversial. llvm-svn: 117346
Diffstat (limited to 'clang/test/SemaObjC')
-rw-r--r--clang/test/SemaObjC/method-conflict-1.m5
-rw-r--r--clang/test/SemaObjC/method-conflict-2.m44
-rw-r--r--clang/test/SemaObjC/method-typecheck-3.m8
3 files changed, 51 insertions, 6 deletions
diff --git a/clang/test/SemaObjC/method-conflict-1.m b/clang/test/SemaObjC/method-conflict-1.m
index b8789fa807e..fb62e2ef354 100644
--- a/clang/test/SemaObjC/method-conflict-1.m
+++ b/clang/test/SemaObjC/method-conflict-1.m
@@ -7,12 +7,13 @@
@interface MyClass : NSObject {
}
-- (void)myMethod:(NSArray *)object;
+- (void)myMethod:(NSArray *)object; // expected-note {{previous definition is here}}
- (void)myMethod1:(NSObject *)object; // expected-note {{previous definition is here}}
@end
@implementation MyClass
-- (void)myMethod:(NSObject *)object {
+// Warn about this contravariant use for now:
+- (void)myMethod:(NSObject *)object { // expected-warning {{conflicting parameter types in implementation of 'myMethod:': 'NSArray *' vs 'NSObject *'}}
}
- (void)myMethod1:(NSArray *)object { // expected-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
}
diff --git a/clang/test/SemaObjC/method-conflict-2.m b/clang/test/SemaObjC/method-conflict-2.m
new file mode 100644
index 00000000000..fd472824559
--- /dev/null
+++ b/clang/test/SemaObjC/method-conflict-2.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -Wno-objc-covariant-overrides -fsyntax-only -verify %s
+
+@interface A @end
+@interface B : A @end
+
+@interface Test1 {}
+- (void) test1:(A*) object; // expected-note {{previous definition is here}}
+- (void) test2:(B*) object;
+@end
+
+@implementation Test1
+- (void) test1:(B*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
+- (void) test2:(A*) object {}
+@end
+
+@interface Test2 {}
+- (void) test1:(id) object; // expected-note {{previous definition is here}}
+- (void) test2:(A*) object;
+@end
+
+@implementation Test2
+- (void) test1:(A*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
+- (void) test2:(id) object {}
+@end
+
+@interface Test3 {}
+- (A*) test1;
+- (B*) test2; // expected-note {{previous definition is here}}
+@end
+
+@implementation Test3
+- (B*) test1 { return 0; }
+- (A*) test2 { return 0; } // expected-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
+@end
+
+// The particular case of overriding with an id return is white-listed.
+@interface Test4 {}
+- (id) test1;
+- (A*) test2;
+@end
+@implementation Test4
+- (A*) test1 { return 0; }
+- (id) test2 { return 0; }
+@end
diff --git a/clang/test/SemaObjC/method-typecheck-3.m b/clang/test/SemaObjC/method-typecheck-3.m
index 629889c3ad5..23036e65d51 100644
--- a/clang/test/SemaObjC/method-typecheck-3.m
+++ b/clang/test/SemaObjC/method-typecheck-3.m
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
@interface A
-- (id)obj;
-- (A*)a;
+- (id)obj; // expected-note {{previous definition is here}}
+- (A*)a; // expected-note {{previous definition is here}}
- (void)takesA: (A*)a; // expected-note {{previous definition is here}}
- (void)takesId: (id)a; // expected-note {{previous definition is here}}
@end
@@ -12,8 +12,8 @@
@end
@implementation B
-- (B*)obj {return self;}
-- (B*)a { return self;}
+- (B*)obj {return self;} // expected-warning {{conflicting return type in implementation of 'obj'}}
+- (B*)a { return self;} // expected-warning {{conflicting return type in implementation of 'a'}}
- (void)takesA: (B*)a // expected-warning {{conflicting parameter types in implementation of 'takesA:'}}
{}
- (void)takesId: (B*)a // expected-warning {{conflicting parameter types in implementation of 'takesId:'}}
OpenPOWER on IntegriCloud