1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 3 struct 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 24 void accept_consumed_arg(__attribute__((os_consumed)) S *arg) {} 25 26 void accept_consumed_arg_by_value(__attribute__((os_consumed)) S arg) {} // expected-warning{{os_consumed attribute only applies to pointer parameters}} 27 28 void accept_consumed_arg_no_extra_arg(__attribute__((os_consumed(10))) S *arg) {} // expected-error{{'os_consumed' attribute takes no arguments}} 29 30 struct __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 36 struct __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 42 struct __attribute__((os_returns_not_retained)) NoNotRetainedAttrOnStruct {}; // expected-warning{{'os_returns_not_retained' attribute only applies to functions, Objective-C methods, and Objective-C properties}} 43