llvm-project/clang/test/Sema/attr-osobject.mm
George Karpenkov 3a50a9fe74 [attributes] Extend os_returns_(not_?)_retained attributes to parameters
When applied to out-parameters, the attributes specify the expected lifetime of the written-into object.

Additionally, introduce OSReturnsRetainedOn(Non)Zero attributes, which
specify that an ownership transfer happens depending on a return code.

Differential Revision: https://reviews.llvm.org/D56292

llvm-svn: 350942
2019-01-11 18:02:08 +00:00

16 lines
710 B
Plaintext

// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
struct S {};
@interface I
@property (readonly) S* prop __attribute__((os_returns_retained));
- (S*) generateS __attribute__((os_returns_retained));
- (void) takeS:(S*) __attribute__((os_consumed)) s;
@end
typedef __attribute__((os_returns_retained)) id (^blockType)(); // expected-warning{{'os_returns_retained' attribute only applies to functions, Objective-C methods, Objective-C properties, and parameters}}
__auto_type b = ^ id (id filter) __attribute__((os_returns_retained)) { // expected-warning{{'os_returns_retained' attribute only applies to functions, Objective-C methods, Objective-C properties, and parameters}}
return filter;
};