xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/arc-property.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -fobjc-exceptions -verify -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc// rdar://9309489
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuc@interface MyClass {
5*f4a2713aSLionel Sambuc        id __weak myString; // expected-error {{existing instance variable 'myString' for strong property 'myString' may not be __weak}}
6*f4a2713aSLionel Sambuc        id StrongIvar;
7*f4a2713aSLionel Sambuc        id __weak myString2; // expected-error {{existing instance variable 'myString2' for strong property 'myString2' may not be __weak}}
8*f4a2713aSLionel Sambuc        id __weak myString3;
9*f4a2713aSLionel Sambuc        id StrongIvar5; // expected-error {{existing instance variable 'StrongIvar5' for __weak property 'myString5' must be __weak}}
10*f4a2713aSLionel Sambuc}
11*f4a2713aSLionel Sambuc@property (strong) id myString; // expected-note {{property declared here}}
12*f4a2713aSLionel Sambuc@property (strong) id myString1;
13*f4a2713aSLionel Sambuc@property (retain) id myString2; // expected-note {{property declared here}}
14*f4a2713aSLionel Sambuc//
15*f4a2713aSLionel Sambuc@property (weak) id myString3;
16*f4a2713aSLionel Sambuc@property (weak) id myString4;
17*f4a2713aSLionel Sambuc@property __weak id myString5; // expected-note {{property declared here}}
18*f4a2713aSLionel Sambuc@end
19*f4a2713aSLionel Sambuc
20*f4a2713aSLionel Sambuc@implementation MyClass
21*f4a2713aSLionel Sambuc@synthesize myString; // expected-note {{property synthesized here}}
22*f4a2713aSLionel Sambuc@synthesize myString1 = StrongIvar; // OK
23*f4a2713aSLionel Sambuc@synthesize myString2 = myString2; // expected-note {{property synthesized here}}
24*f4a2713aSLionel Sambuc//
25*f4a2713aSLionel Sambuc@synthesize myString3; // OK
26*f4a2713aSLionel Sambuc@synthesize myString4; // OK
27*f4a2713aSLionel Sambuc@synthesize myString5 = StrongIvar5; // expected-note {{property synthesized here}}
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambuc@end
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc// rdar://9340692
32*f4a2713aSLionel Sambuc@interface Foo {
33*f4a2713aSLionel Sambuc@public
34*f4a2713aSLionel Sambuc    id __unsafe_unretained x; // expected-error {{existing instance variable 'x' for __weak property 'x' must be __weak}}
35*f4a2713aSLionel Sambuc    id __strong y;  // expected-error {{existing instance variable 'y' for __weak property 'y' must be __weak}}
36*f4a2713aSLionel Sambuc    id __autoreleasing z; // expected-error {{instance variables cannot have __autoreleasing ownership}}
37*f4a2713aSLionel Sambuc}
38*f4a2713aSLionel Sambuc@property(weak) id x; // expected-note {{property declared here}}
39*f4a2713aSLionel Sambuc@property(weak) id y; // expected-note {{property declared here}}
40*f4a2713aSLionel Sambuc@property(weak) id z;
41*f4a2713aSLionel Sambuc@end
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc@implementation Foo
44*f4a2713aSLionel Sambuc@synthesize x; // expected-note {{property synthesized here}}
45*f4a2713aSLionel Sambuc@synthesize y; // expected-note {{property synthesized here}}
46*f4a2713aSLionel Sambuc@synthesize z;  // suppressed
47*f4a2713aSLionel Sambuc@end
48*f4a2713aSLionel Sambuc
49*f4a2713aSLionel Sambuc// rdar://problem/10904479
50*f4a2713aSLionel Sambuc// Don't crash.
51*f4a2713aSLionel Sambuc@interface Test2
52*f4a2713aSLionel Sambuc// Minor FIXME: kill the redundant error
53*f4a2713aSLionel Sambuc@property (strong) UndeclaredClass *test2;  // expected-error {{unknown type name 'UndeclaredClass'}} expected-error {{must be of object type}}
54*f4a2713aSLionel Sambuc@end
55*f4a2713aSLionel Sambuc@implementation Test2
56*f4a2713aSLionel Sambuc@synthesize test2;
57*f4a2713aSLionel Sambuc@end
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc// rdar://problem/11144407
60*f4a2713aSLionel Sambuc@interface Test3
61*f4a2713aSLionel Sambuc@property (strong) id exception;
62*f4a2713aSLionel Sambuc@end
63*f4a2713aSLionel Sambucvoid test3(Test3 *t3) {
64*f4a2713aSLionel Sambuc  @throw t3.exception;
65*f4a2713aSLionel Sambuc}
66