xref: /minix3/external/bsd/llvm/dist/clang/test/ARCMT/check-api.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-macosx10.7 %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc#include "Common.h"
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc@interface NSInvocation : NSObject
6*f4a2713aSLionel Sambuc- (void)getReturnValue:(void *)retLoc;
7*f4a2713aSLionel Sambuc- (void)setReturnValue:(void *)retLoc;
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuc- (void)getArgument:(void *)argumentLocation atIndex:(int)idx;
10*f4a2713aSLionel Sambuc- (void)setArgument:(void *)argumentLocation atIndex:(int)idx;
11*f4a2713aSLionel Sambuc@end
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc@interface Test
14*f4a2713aSLionel Sambuc@end
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc@implementation Test {
17*f4a2713aSLionel Sambuc  id strong_id;
18*f4a2713aSLionel Sambuc  __weak id weak_id;
19*f4a2713aSLionel Sambuc  __unsafe_unretained id unsafe_id;
20*f4a2713aSLionel Sambuc  int arg;
21*f4a2713aSLionel Sambuc}
22*f4a2713aSLionel Sambuc- (void) test:(NSInvocation *)invok {
23*f4a2713aSLionel Sambuc  [invok getReturnValue:&strong_id]; // expected-error {{NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}}
24*f4a2713aSLionel Sambuc  [invok getReturnValue:&weak_id]; // expected-error {{NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}}
25*f4a2713aSLionel Sambuc  [invok getReturnValue:&unsafe_id];
26*f4a2713aSLionel Sambuc  [invok getReturnValue:&arg];
27*f4a2713aSLionel Sambuc
28*f4a2713aSLionel Sambuc  [invok setReturnValue:&strong_id]; // expected-error {{NSInvocation's setReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}}
29*f4a2713aSLionel Sambuc  [invok setReturnValue:&weak_id]; // expected-error {{NSInvocation's setReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}}
30*f4a2713aSLionel Sambuc  [invok setReturnValue:&unsafe_id];
31*f4a2713aSLionel Sambuc  [invok setReturnValue:&arg];
32*f4a2713aSLionel Sambuc
33*f4a2713aSLionel Sambuc  [invok getArgument:&strong_id atIndex:0]; // expected-error {{NSInvocation's getArgument is not safe to be used with an object with ownership other than __unsafe_unretained}}
34*f4a2713aSLionel Sambuc  [invok getArgument:&weak_id atIndex:0]; // expected-error {{NSInvocation's getArgument is not safe to be used with an object with ownership other than __unsafe_unretained}}
35*f4a2713aSLionel Sambuc  [invok getArgument:&unsafe_id atIndex:0];
36*f4a2713aSLionel Sambuc  [invok getArgument:&arg atIndex:0];
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc  [invok setArgument:&strong_id atIndex:0]; // expected-error {{NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained}}
39*f4a2713aSLionel Sambuc  [invok setArgument:&weak_id atIndex:0]; // expected-error {{NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained}}
40*f4a2713aSLionel Sambuc  [invok setArgument:&unsafe_id atIndex:0];
41*f4a2713aSLionel Sambuc  [invok setArgument:&arg atIndex:0];
42*f4a2713aSLionel Sambuc}
43*f4a2713aSLionel Sambuc@end
44