blob: fe9ed6b912b9c5d9e9cae4a1d2e8dad628564196 [file] [log] [blame]
George Karpenkov1657f362018-11-30 02:18:37 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3struct S {
4 __attribute__((os_returns_retained)) S* method_returns_retained() {
5 return nullptr;
6 }
7};
8__attribute__((os_returns_retained)) S *ret_retained() {
9 return nullptr;
10}
11
12__attribute__((os_returns_retained)) S ret_retained_value() { // expected-warning{{'os_returns_retained' attribute only applies to functions that return a pointer}}
13 return {};
14}
15
16__attribute__((os_returns_not_retained)) S *ret_not_retained() {
17 return nullptr;
18}
19
20__attribute__((os_returns_not_retained)) S ret_not_retained_value() { // expected-warning{{'os_returns_not_retained' attribute only applies to functions that return a pointer}}
21 return {};
22}
23
24void accept_consumed_arg(__attribute__((os_consumed)) S *arg) {}
25
26void accept_consumed_arg_by_value(__attribute__((os_consumed)) S arg) {} // expected-warning{{os_consumed attribute only applies to pointer parameters}}
27
28void accept_consumed_arg_no_extra_arg(__attribute__((os_consumed(10))) S *arg) {} // expected-error{{'os_consumed' attribute takes no arguments}}
29
30struct __attribute__((os_consumed)) NoAttrOnStruct {}; // expected-warning{{'os_consumed' attribute only applies to parameters}}
31
32__attribute__((os_returns_retained(10))) S* returns_retained_no_extra_arg() { // expected-error{{'os_returns_retained' attribute takes no arguments}}
33 return nullptr;
34}
35
36struct __attribute__((os_returns_retained)) NoRetainAttrOnStruct {}; // expected-warning{{'os_returns_retained' attribute only applies to functions, Objective-C methods, and Objective-C properties}}
37
38__attribute__((os_returns_not_retained(10))) S* os_returns_no_retained_no_extra_args( S *arg) { // expected-error{{'os_returns_not_retained' attribute takes no arguments}}
39 return nullptr;
40}
41
42struct __attribute__((os_returns_not_retained)) NoNotRetainedAttrOnStruct {}; // expected-warning{{'os_returns_not_retained' attribute only applies to functions, Objective-C methods, and Objective-C properties}}