xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/arc-peformselector.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
2*f4a2713aSLionel Sambuc// rdar://9659270
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuc@interface NSObject
5*f4a2713aSLionel Sambuc- (id)copy; // expected-note {{method 'copy' declared here}}
6*f4a2713aSLionel Sambuc- (id) test __attribute__((ns_returns_retained)); // expected-note {{method 'test' declared here}}
7*f4a2713aSLionel Sambuc+ (id) new ; // expected-note {{method 'new' declared here}}
8*f4a2713aSLionel Sambuc- (id) init __attribute__((ns_returns_not_retained));
9*f4a2713aSLionel Sambuc- (id)PlusZero;
10*f4a2713aSLionel Sambuc- (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
11*f4a2713aSLionel Sambuc@end
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc@interface I : NSObject
14*f4a2713aSLionel Sambuc{
15*f4a2713aSLionel Sambuc  SEL sel1;
16*f4a2713aSLionel Sambuc}
17*f4a2713aSLionel Sambuc- (id)performSelector:(SEL)aSelector;
18*f4a2713aSLionel Sambuc- (id)performSelector:(SEL)aSelector withObject:(id)object;
19*f4a2713aSLionel Sambuc- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
20*f4a2713aSLionel Sambuc@end
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc@implementation I
23*f4a2713aSLionel Sambuc- (id) Meth {
24*f4a2713aSLionel Sambuc  return [self performSelector : @selector(copy)]; // expected-error {{performSelector names a selector which retains the object}}
25*f4a2713aSLionel Sambuc  return [self performSelector : @selector(test)]; // expected-error {{performSelector names a selector which retains the object}}
26*f4a2713aSLionel Sambuc  return [self performSelector : @selector(new)]; // expected-error {{performSelector names a selector which retains the object}}
27*f4a2713aSLionel Sambuc  return [self performSelector : @selector(init)];
28*f4a2713aSLionel Sambuc  return [self performSelector : sel1]; // expected-warning {{performSelector may cause a leak because its selector is unknown}} \
29*f4a2713aSLionel Sambuc					// expected-note {{used here}}
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc  return [self performSelector : @selector(PlusZero)];
32*f4a2713aSLionel Sambuc  return [self performSelector : @selector(PlusOne)]; // expected-error {{performSelector names a selector which retains the object}}
33*f4a2713aSLionel Sambuc}
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc- (id)performSelector:(SEL)aSelector { return 0; }
36*f4a2713aSLionel Sambuc- (id)performSelector:(SEL)aSelector withObject:(id)object { return 0; }
37*f4a2713aSLionel Sambuc- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2 { return 0; }
38*f4a2713aSLionel Sambuc@end
39