blob: 34f1712f8b583d5dfb11783f0d61991ffe5d9bff [file] [log] [blame]
Fariborz Jahanian6b308f62010-08-09 23:27:58 +00001// RUN: %clang_cc1 -Wstrict-selector-match -fsyntax-only -verify %s
2
3@interface Foo
4-(int) method; // expected-note {{using}}
5@end
6
7@interface Bar
8-(float) method; // expected-note {{also found}}
9@end
10
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000011int main() { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found}}
Fariborz Jahanian6b308f62010-08-09 23:27:58 +000012
13@interface Object @end
14
15@interface Class1
16- (void)setWindow:(Object *)wdw; // expected-note {{using}}
17@end
18
19@interface Class2
20- (void)setWindow:(Class1 *)window; // expected-note {{also found}}
21@end
22
23id foo(void) {
24 Object *obj = 0;
25 id obj2 = obj;
26 [obj setWindow:0]; // expected-warning {{Object' may not respond to 'setWindow:'}}
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000027 [obj2 setWindow:0]; // expected-warning {{multiple methods named 'setWindow:' found}}
Fariborz Jahanian6b308f62010-08-09 23:27:58 +000028 return obj;
29}
30
31@protocol MyObject
32- (id)initWithData:(Object *)data; // expected-note {{using}} \
33 // expected-note {{passing argument to parameter 'data' here}}
34@end
35
36@protocol SomeOther
37- (id)initWithData:(int)data; // expected-note {{also found}}
38@end
39
40@protocol MyCoding
41- (id)initWithData:(id<MyObject, MyCoding>)data; // expected-note {{also found}}
42@end
43
44@interface NTGridDataObject: Object <MyCoding>
45{
46 Object<MyCoding> *_data;
47}
48+ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data;
49@end
50
51@implementation NTGridDataObject
52- (id)initWithData:(id<MyObject, MyCoding>)data {
53 return data;
54}
55+ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
56{
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000057 NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found}} \
Fariborz Jahanian6b308f62010-08-09 23:27:58 +000058 expected-warning {{sending 'id<MyObject,MyCoding>' to parameter of incompatible type 'Object *'}}
59 return result;
60}
61@end
62
63@interface Base
64- (unsigned)port;
65@end
66
67@interface Derived: Base
68- (Object *)port;
69+ (Protocol *)port;
70@end
71
72void foo1(void) {
73 [(Class)0 port]; // OK - gcc issues warning but there is only one Class method so no ambiguity to warn
74}
75