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