annotate clang/test/SemaObjC/warn-strict-selector-match.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -Wstrict-selector-match -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 @interface Foo
anatofuz
parents:
diff changeset
4 -(int) method; // expected-note {{using}}
anatofuz
parents:
diff changeset
5 @end
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 @interface Bar
anatofuz
parents:
diff changeset
8 -(float) method; // expected-note {{also found}}
anatofuz
parents:
diff changeset
9 @end
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 int main() { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found}}
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 @interface Object @end
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 @interface Class1
anatofuz
parents:
diff changeset
16 - (void)setWindow:(Object *)wdw; // expected-note 2 {{using}}
anatofuz
parents:
diff changeset
17 @end
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 @interface Class2
anatofuz
parents:
diff changeset
20 - (void)setWindow:(Class1 *)window; // expected-note 2 {{also found}}
anatofuz
parents:
diff changeset
21 @end
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 id foo(void) {
anatofuz
parents:
diff changeset
24 Object *obj = 0;
anatofuz
parents:
diff changeset
25 id obj2 = obj;
anatofuz
parents:
diff changeset
26 [obj setWindow:0]; // expected-warning {{Object' may not respond to 'setWindow:'}} \
anatofuz
parents:
diff changeset
27 // expected-warning {{multiple methods named 'setWindow:' found}}
anatofuz
parents:
diff changeset
28 [obj2 setWindow:0]; // expected-warning {{multiple methods named 'setWindow:' found}}
anatofuz
parents:
diff changeset
29 return obj;
anatofuz
parents:
diff changeset
30 }
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 @protocol MyObject
anatofuz
parents:
diff changeset
33 - (id)initWithData:(Object *)data; // expected-note {{also found}}
anatofuz
parents:
diff changeset
34 @end
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 @protocol SomeOther
anatofuz
parents:
diff changeset
37 - (id)initWithData:(int)data; // expected-note {{also found}}
anatofuz
parents:
diff changeset
38 @end
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 @protocol MyCoding
anatofuz
parents:
diff changeset
41 - (id)initWithData:(id<MyObject, MyCoding>)data; // expected-note {{using}}
anatofuz
parents:
diff changeset
42 @end
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 @interface NTGridDataObject: Object <MyCoding>
anatofuz
parents:
diff changeset
45 {
anatofuz
parents:
diff changeset
46 Object<MyCoding> *_data;
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data;
anatofuz
parents:
diff changeset
49 @end
anatofuz
parents:
diff changeset
50
anatofuz
parents:
diff changeset
51 @implementation NTGridDataObject
anatofuz
parents:
diff changeset
52 - (id)initWithData:(id<MyObject, MyCoding>)data { // expected-note {{also found}}
anatofuz
parents:
diff changeset
53 return data;
anatofuz
parents:
diff changeset
54 }
anatofuz
parents:
diff changeset
55 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
anatofuz
parents:
diff changeset
56 {
anatofuz
parents:
diff changeset
57 NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found}}
anatofuz
parents:
diff changeset
58 return result;
anatofuz
parents:
diff changeset
59 }
anatofuz
parents:
diff changeset
60 @end
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 @interface Base
anatofuz
parents:
diff changeset
63 - (unsigned)port;
anatofuz
parents:
diff changeset
64 @end
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 @interface Derived: Base
anatofuz
parents:
diff changeset
67 - (Object *)port;
anatofuz
parents:
diff changeset
68 + (Protocol *)port;
anatofuz
parents:
diff changeset
69 @end
anatofuz
parents:
diff changeset
70
anatofuz
parents:
diff changeset
71 void foo1(void) {
anatofuz
parents:
diff changeset
72 [(Class)0 port]; // OK - gcc issues warning but there is only one Class method so no ambiguity to warn
anatofuz
parents:
diff changeset
73 }
anatofuz
parents:
diff changeset
74
anatofuz
parents:
diff changeset
75 // rdar://19265430
anatofuz
parents:
diff changeset
76 @interface NSObject
anatofuz
parents:
diff changeset
77 - (id)class;
anatofuz
parents:
diff changeset
78 - (id) alloc;
anatofuz
parents:
diff changeset
79 @end
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 @class NSString;
anatofuz
parents:
diff changeset
82
anatofuz
parents:
diff changeset
83 @interface A : NSObject
anatofuz
parents:
diff changeset
84 - (instancetype)initWithType:(NSString *)whatever; // expected-note {{also found}}
anatofuz
parents:
diff changeset
85 @end
anatofuz
parents:
diff changeset
86
anatofuz
parents:
diff changeset
87 @interface Test : NSObject
anatofuz
parents:
diff changeset
88 @end
anatofuz
parents:
diff changeset
89
anatofuz
parents:
diff changeset
90 @implementation Test
anatofuz
parents:
diff changeset
91 + (instancetype)foo
anatofuz
parents:
diff changeset
92 {
anatofuz
parents:
diff changeset
93 return [[[self class] alloc] initWithType:3]; // expected-warning {{multiple methods named 'initWithType:'}}
anatofuz
parents:
diff changeset
94 }
anatofuz
parents:
diff changeset
95
anatofuz
parents:
diff changeset
96 - (instancetype)initWithType:(unsigned int)whatever // expected-note {{using}}
anatofuz
parents:
diff changeset
97 {
anatofuz
parents:
diff changeset
98 return 0;
anatofuz
parents:
diff changeset
99 }
anatofuz
parents:
diff changeset
100 @end