From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/SemaObjC/method-conflict-1.m | 83 +++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 clang/test/SemaObjC/method-conflict-1.m (limited to 'clang/test/SemaObjC/method-conflict-1.m') diff --git a/clang/test/SemaObjC/method-conflict-1.m b/clang/test/SemaObjC/method-conflict-1.m new file mode 100644 index 0000000..ca91ebd --- /dev/null +++ b/clang/test/SemaObjC/method-conflict-1.m @@ -0,0 +1,83 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s + +// This test case tests the default behavior. + +// rdar://7933061 + +@interface NSObject @end + +@interface NSArray : NSObject @end + +@interface MyClass : NSObject { +} +- (void)myMethod:(NSArray *)object; +- (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}} +@end + +@implementation MyClass +- (void)myMethod:(NSObject *)object { +} +- (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}} +} +@end + + +@protocol MyProtocol @end + +@interface MyOtherClass : NSObject { +} +- (void)myMethod:(id )object; // broken-note {{previous definition is here}} +- (void)myMethod1:(id )object; // broken-note {{previous definition is here}} +@end + +@implementation MyOtherClass +- (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id' vs 'MyClass *'}} +} +- (void)myMethod1:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id' vs 'MyClass *'}} +} +@end + + + +@interface A @end +@interface B : A @end + +@interface Test1 {} +- (void) test1:(A*) object; // broken-note {{previous definition is here}} +- (void) test2:(B*) object; +@end + +@implementation Test1 +- (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}} +- (void) test2:(A*) object {} +@end + +// rdar://problem/8597621 wants id -> A* to be an exception +@interface Test2 {} +- (void) test1:(id) object; // broken-note {{previous definition is here}} +- (void) test2:(A*) object; +@end +@implementation Test2 +- (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}} +- (void) test2:(id) object {} +@end + +@interface Test3 {} +- (A*) test1; +- (B*) test2; // broken-note {{previous definition is here}} +@end + +@implementation Test3 +- (B*) test1 { return 0; } +- (A*) test2 { return 0; } // broken-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 -> A* is rdar://problem/8596987 +- (id) test2 { return 0; } +@end -- cgit v1.2.3