Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wselector -verify -Wno-objc-root-class %s |
Fariborz Jahanian | 1e99a77 | 2011-02-04 23:30:23 +0000 | [diff] [blame] | 2 | // rdar://8851684 |
| 3 | |
| 4 | @interface Foo |
| 5 | - (void) foo; |
| 6 | - (void) bar; |
| 7 | @end |
| 8 | |
| 9 | @implementation Foo |
| 10 | - (void) bar |
| 11 | { |
| 12 | } |
| 13 | |
| 14 | - (void) foo |
| 15 | { |
| 16 | SEL a,b,c; |
Fariborz Jahanian | 37bccca | 2013-05-28 23:49:32 +0000 | [diff] [blame] | 17 | a = @selector(b1ar); // expected-warning {{creating selector for nonexistent method 'b1ar'}} |
Fariborz Jahanian | 1e99a77 | 2011-02-04 23:30:23 +0000 | [diff] [blame] | 18 | b = @selector(bar); |
| 19 | } |
| 20 | @end |
| 21 | |
| 22 | @interface I |
| 23 | - length; |
| 24 | @end |
| 25 | |
| 26 | SEL func() |
| 27 | { |
Fariborz Jahanian | 37bccca | 2013-05-28 23:49:32 +0000 | [diff] [blame] | 28 | return @selector(length); // expected-warning {{creating selector for nonexistent method 'length'}} |
Fariborz Jahanian | 1e99a77 | 2011-02-04 23:30:23 +0000 | [diff] [blame] | 29 | } |
Fariborz Jahanian | 4c91d89 | 2011-07-13 19:05:43 +0000 | [diff] [blame] | 30 | |
| 31 | // rdar://9545564 |
| 32 | @class MSPauseManager; |
| 33 | |
| 34 | @protocol MSPauseManagerDelegate |
| 35 | @optional |
| 36 | - (void)pauseManagerDidPause:(MSPauseManager *)manager; |
| 37 | - (int)respondsToSelector:(SEL)aSelector; |
| 38 | @end |
| 39 | |
| 40 | @interface MSPauseManager |
| 41 | { |
| 42 | id<MSPauseManagerDelegate> _delegate; |
| 43 | } |
| 44 | @end |
| 45 | |
| 46 | |
| 47 | @implementation MSPauseManager |
| 48 | - (id) Meth { |
| 49 | if ([_delegate respondsToSelector:@selector(pauseManagerDidPause:)]) |
| 50 | return 0; |
| 51 | return 0; |
| 52 | } |
| 53 | @end |
| 54 | |
Fariborz Jahanian | f11ccc1 | 2013-01-21 22:32:29 +0000 | [diff] [blame] | 55 | // rdar://12938616 |
| 56 | @class NSXPCConnection; |
| 57 | |
| 58 | @interface NSObject |
| 59 | @end |
| 60 | |
| 61 | @interface INTF : NSObject |
| 62 | { |
| 63 | NSXPCConnection *cnx; // Comes in as a parameter. |
| 64 | } |
| 65 | - (void) Meth; |
| 66 | @end |
| 67 | |
| 68 | extern SEL MySelector(SEL s); |
| 69 | |
| 70 | @implementation INTF |
| 71 | - (void) Meth { |
Fariborz Jahanian | 37bccca | 2013-05-28 23:49:32 +0000 | [diff] [blame] | 72 | if( [cnx respondsToSelector:MySelector(@selector( _setQueue: ))] ) // expected-warning {{creating selector for nonexistent method '_setQueue:'}} |
Fariborz Jahanian | f11ccc1 | 2013-01-21 22:32:29 +0000 | [diff] [blame] | 73 | { |
| 74 | } |
| 75 | |
| 76 | if( [cnx respondsToSelector:@selector( _setQueueXX: )] ) // No warning here. |
| 77 | { |
| 78 | } |
Fariborz Jahanian | 48f3cc2 | 2013-01-22 18:35:43 +0000 | [diff] [blame] | 79 | if( [cnx respondsToSelector:(@selector( _setQueueXX: ))] ) // No warning here. |
| 80 | { |
| 81 | } |
Fariborz Jahanian | f11ccc1 | 2013-01-21 22:32:29 +0000 | [diff] [blame] | 82 | } |
| 83 | @end |
Fariborz Jahanian | f98c688 | 2013-05-30 21:48:58 +0000 | [diff] [blame] | 84 | |
| 85 | // rdar://14007194 |
| 86 | @interface UxTechTest : NSObject |
| 87 | - (int) invalidate : (id)Arg; // expected-warning {{multiple selectors named 'invalidate:' found}} |
| 88 | + (int) C_invalidate : (int)arg; // expected-warning {{multiple selectors named 'C_invalidate:' found}} |
| 89 | @end |
| 90 | |
| 91 | @interface UxTechTest(CAT) |
| 92 | - (char) invalidate : (int)arg; // expected-note {{also found}} |
| 93 | + (int) C_invalidate : (char)arg; // expected-note {{also found}} |
| 94 | @end |
| 95 | |
| 96 | @interface NSPort : NSObject |
| 97 | - (double) invalidate : (void*)Arg1; // expected-note {{also found}} |
| 98 | + (int) C_invalidate : (id*)arg; // expected-note {{also found}} |
| 99 | @end |
| 100 | |
| 101 | |
| 102 | @interface USEText : NSPort |
| 103 | - (int) invalidate : (int)arg; // expected-note {{also found}} |
| 104 | @end |
| 105 | |
| 106 | @implementation USEText |
| 107 | - (int) invalidate :(int) arg { return 0; } |
| 108 | @end |
| 109 | |
| 110 | @interface USETextSub : USEText |
| 111 | - (int) invalidate : (id)arg; |
| 112 | @end |