xref: /aosp_15_r20/external/clang/test/SemaObjC/method-lookup-3.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li
3*67e74705SXin Litypedef struct { int y; } Abstract;
4*67e74705SXin Li
5*67e74705SXin Litypedef struct { int x; } Alternate;
6*67e74705SXin Li
7*67e74705SXin Li#define INTERFERE_TYPE Alternate*
8*67e74705SXin Li
9*67e74705SXin Li@protocol A
10*67e74705SXin Li@property Abstract *x; // expected-note {{using}}
11*67e74705SXin Li@end
12*67e74705SXin Li
13*67e74705SXin Li@interface B
14*67e74705SXin Li@property Abstract *y; // expected-note {{using}}
15*67e74705SXin Li@end
16*67e74705SXin Li
17*67e74705SXin Li@interface B (Category)
18*67e74705SXin Li@property Abstract *z; // expected-note {{using}}
19*67e74705SXin Li@end
20*67e74705SXin Li
21*67e74705SXin Li@interface InterferencePre
22*67e74705SXin Li-(void) x; // expected-note {{also found}}
23*67e74705SXin Li-(void) y; // expected-note {{also found}}
24*67e74705SXin Li-(void) z; // expected-note {{also found}}
25*67e74705SXin Li-(void) setX: (INTERFERE_TYPE) arg;
26*67e74705SXin Li-(void) setY: (INTERFERE_TYPE) arg;
27*67e74705SXin Li-(void) setZ: (INTERFERE_TYPE) arg;
28*67e74705SXin Li@end
29*67e74705SXin Li
30*67e74705SXin Livoid f0(id a0) {
31*67e74705SXin Li  Abstract *l = [a0 x]; // expected-warning {{multiple methods named 'x' found}}
32*67e74705SXin Li}
33*67e74705SXin Li
34*67e74705SXin Livoid f1(id a0) {
35*67e74705SXin Li  Abstract *l = [a0 y]; // expected-warning {{multiple methods named 'y' found}}
36*67e74705SXin Li}
37*67e74705SXin Li
38*67e74705SXin Livoid f2(id a0) {
39*67e74705SXin Li  Abstract *l = [a0 z]; // expected-warning {{multiple methods named 'z' found}}
40*67e74705SXin Li}
41*67e74705SXin Li
42*67e74705SXin Livoid f3(id a0, Abstract *a1) {
43*67e74705SXin Li  [ a0 setX: a1];
44*67e74705SXin Li}
45*67e74705SXin Li
46*67e74705SXin Livoid f4(id a0, Abstract *a1) {
47*67e74705SXin Li  [ a0 setY: a1];
48*67e74705SXin Li}
49*67e74705SXin Li
50*67e74705SXin Livoid f5(id a0, Abstract *a1) {
51*67e74705SXin Li  [ a0 setZ: a1];
52*67e74705SXin Li}
53*67e74705SXin Li
54*67e74705SXin Li// pr7861
55*67e74705SXin Livoid f6(id<A> a0) {
56*67e74705SXin Li  Abstract *l = [a0 x];
57*67e74705SXin Li}
58*67e74705SXin Li
59*67e74705SXin Listruct test3a { int x, y; };
60*67e74705SXin Listruct test3b { unsigned x, y; };
61*67e74705SXin Li@interface Test3A - (struct test3a) test3; @end
62*67e74705SXin Li@interface Test3B - (struct test3b) test3; @end
63*67e74705SXin Livoid test3(id x) {
64*67e74705SXin Li  (void) [x test3];
65*67e74705SXin Li}
66*67e74705SXin Li
67*67e74705SXin Listruct test4a { int x, y; };
68*67e74705SXin Listruct test4b { float x, y; };
69*67e74705SXin Li@interface Test4A - (struct test4a) test4; @end //expected-note{{using}}
70*67e74705SXin Li@interface Test4B - (struct test4b) test4; @end //expected-note{{also found}}
71*67e74705SXin Livoid test4(id x) {
72*67e74705SXin Li  (void) [x test4]; //expected-warning {{multiple methods named 'test4' found}}
73*67e74705SXin Li}
74*67e74705SXin Li
75*67e74705SXin Li// rdar://19265296
76*67e74705SXin Li#pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
77*67e74705SXin Li@interface NSObject
78*67e74705SXin Li+ (id)alloc;
79*67e74705SXin Li+ (id)class;
80*67e74705SXin Li- (id) init;
81*67e74705SXin Li@end
82*67e74705SXin Li
83*67e74705SXin Li@class NSString;
84*67e74705SXin Li@interface A : NSObject
85*67e74705SXin Li- (instancetype)initWithType:(NSString *)whatever;
86*67e74705SXin Li@end
87*67e74705SXin Li
88*67e74705SXin Li@interface Test : NSObject @end
89*67e74705SXin Li
90*67e74705SXin Li@implementation Test
91*67e74705SXin Li+ (instancetype)foo
92*67e74705SXin Li{
93*67e74705SXin Li    return [[[self class] alloc] initWithType:3];
94*67e74705SXin Li}
95*67e74705SXin Li- (instancetype)initWithType:(int)whatever
96*67e74705SXin Li{
97*67e74705SXin Li    return [super init];
98*67e74705SXin Li}
99*67e74705SXin Li@end
100