150
|
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
|
|
2 // rdar://9659270
|
|
3
|
|
4 @interface NSObject
|
|
5 - (id)copy; // expected-note {{method 'copy' declared here}}
|
|
6 - (id) test __attribute__((ns_returns_retained)); // expected-note {{method 'test' declared here}}
|
|
7 + (id) new ; // expected-note {{method 'new' declared here}}
|
|
8 - (id) init __attribute__((ns_returns_not_retained));
|
|
9 - (id)PlusZero;
|
|
10 - (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
|
|
11 - (id)self;
|
|
12 @end
|
|
13
|
|
14 @interface I : NSObject
|
|
15 {
|
|
16 SEL sel1;
|
|
17 }
|
|
18 - (id)performSelector:(SEL)aSelector;
|
|
19 - (id)performSelector:(SEL)aSelector withObject:(id)object;
|
|
20 - (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
|
|
21
|
|
22 - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(double)delay inModes:(I *)modes;
|
|
23
|
|
24 @end
|
|
25
|
|
26 @implementation I
|
|
27 - (id) Meth {
|
|
28 return [self performSelector : @selector(copy)]; // expected-error {{performSelector names a selector which retains the object}}
|
|
29 return [self performSelector : @selector(test)]; // expected-error {{performSelector names a selector which retains the object}}
|
|
30 return [self performSelector : @selector(new)]; // expected-error {{performSelector names a selector which retains the object}}
|
|
31 return [self performSelector : @selector(init)];
|
|
32 return [self performSelector : sel1]; // expected-warning {{performSelector may cause a leak because its selector is unknown}} \
|
|
33 // expected-note {{used here}}
|
|
34 return [self performSelector: (@selector(PlusZero))];
|
|
35
|
|
36 return [self performSelector : @selector(PlusZero)];
|
|
37 return [self performSelector : @selector(PlusOne)]; // expected-error {{performSelector names a selector which retains the object}}
|
|
38
|
|
39 // Avoid the unknown selector warning for more complicated performSelector
|
|
40 // variations because it produces too many false positives.
|
|
41 [self performSelector: sel1 withObject:0 afterDelay:0 inModes:0];
|
|
42
|
|
43 return [self performSelector: @selector(self)]; // No error, -self is not +1!
|
|
44 }
|
|
45
|
|
46 - (id)performSelector:(SEL)aSelector { return 0; }
|
|
47 - (id)performSelector:(SEL)aSelector withObject:(id)object { return 0; }
|
|
48 - (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2 { return 0; }
|
|
49 - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(double)delay inModes:(I *)modes { }
|
|
50 @end
|