1 // RUN: %clang_cc1 -arcmt-action=check -verify -triple x86_64-apple-darwin10 %s
3 #if __has_feature(objc_arr)
4 #define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
6 #define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
9 typedef struct _NSZone NSZone;
11 typedef unsigned NSUInteger;
14 - (BOOL)isEqual:(id)object;
15 - (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
16 - (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
17 - (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
18 - (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
20 - (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
24 - (id)copyWithZone:(NSZone *)zone;
27 @protocol NSMutableCopying
28 - (id)mutableCopyWithZone:(NSZone *)zone;
31 @interface NSObject <NSObject> {}
35 + (id)allocWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
44 + (id)copyWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
45 + (id)mutableCopyWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
48 extern void NSRecycleZone(NSZone *zone);
50 NS_AUTOMATED_REFCOUNT_UNAVAILABLE
51 @interface NSAutoreleasePool : NSObject { // expected-note 13 {{marked unavailable here}}
59 + (void)addObject:(id)anObject;
61 - (void)addObject:(id)anObject;
70 int main (int argc, const char * argv[]) {
71 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
72 NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}}
76 // the following pool was not released in this scope, don't touch it.
77 chunkPool = [[NSAutoreleasePool alloc] init]; // expected-error {{'NSAutoreleasePool' is unavailable}}
87 NSAutoreleasePool * pool; // expected-error {{'NSAutoreleasePool' is unavailable}}
89 for (int i=0; i != 10; ++i) {
90 id x = pool; // We won't touch a NSAutoreleasePool if we can't safely
91 // remove all the references to it.
94 pool = [[NSAutoreleasePool alloc] init]; // expected-error {{'NSAutoreleasePool' is unavailable}}
100 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \
101 // expected-note {{scope begins here}}
103 // 'x' is declared inside the "pool scope" but used outside it, if we create
104 // a @autorelease scope it will be undefined outside it so don't touch the pool.
105 int x = 0; // expected-note {{declared here}}
107 [pool release]; // expected-note {{scope ends here}}
109 ++x; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}}
113 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \
114 // expected-note {{scope begins here}}
116 struct S { int x; }; // expected-note {{declared here}}
118 [pool release]; // expected-note {{scope ends here}}
120 struct S *var; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}}
125 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \
126 // expected-note {{scope begins here}}
128 enum { Bar }; // expected-note {{declared here}}
130 [pool release]; // expected-note {{scope ends here}}
132 int x = Bar; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}}
136 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \
137 // expected-note {{scope begins here}}
139 typedef int Bar; // expected-note {{declared here}}
141 [pool release]; // expected-note {{scope ends here}}
143 Bar x; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}}