// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s
-// XFAIL: *
-#include "Common.h"
+#if __has_feature(objc_arc)
+#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
+#else
+#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
+#endif
+
+typedef int BOOL;
+typedef unsigned NSUInteger;
+
+@protocol NSObject
+- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{unavailable here}}
+- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note 4 {{unavailable here}}
+- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+@end
+
+@interface NSObject <NSObject> {}
+- (id)init;
+
++ (id)new;
++ (id)alloc;
+- (void)dealloc;
+
+- (void)finalize;
+
+- (id)copy;
+- (id)mutableCopy;
+@end
typedef const struct __CFString * CFStringRef;
extern const CFStringRef kUTTypePlainText;
void test1(A *a, BOOL b, struct UnsafeS *unsafeS) {
[[a delegate] release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \
- // expected-error {{ARC forbids explicit message send}}
+ // expected-error {{ARC forbids explicit message send}} \
+ // expected-error {{unavailable}}
[a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \
- // expected-error {{ARC forbids explicit message send}}
+ // expected-error {{ARC forbids explicit message send}} \
+ // expected-error {{unavailable}}
[unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \
// expected-error {{ARC forbids explicit message send}}
id foo = [unsafeS->unsafeObj retain]; // no warning.
[global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \
- // expected-error {{ARC forbids explicit message send}}
+ // expected-error {{ARC forbids explicit message send}} \
+ // expected-error {{unavailable}}
[global_foo release]; // expected-error {{it is not safe to remove 'release' message on a global variable}} \
- // expected-error {{ARC forbids explicit message send}}
+ // expected-error {{ARC forbids explicit message send}} \
+ // expected-error {{unavailable}}
[a dealloc];
[a retain];
[a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}}
// rdar://9504750
void rdar9504750(id p) {
- RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}}
+ RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} \
+ // expected-error {{unavailable}}
}
// rdar://8939557