annotate clang/test/Sema/attr-osobject.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 struct S {
anatofuz
parents:
diff changeset
4 __attribute__((os_returns_retained)) S* method_returns_retained() {
anatofuz
parents:
diff changeset
5 return nullptr;
anatofuz
parents:
diff changeset
6 }
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 __attribute__((os_consumes_this)) void method_consumes_this();
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 __attribute__((os_consumes_this)) static void rejected_on_static(); // expected-warning{{'os_consumes_this' attribute only applies to non-static member functions}}
anatofuz
parents:
diff changeset
11 };
anatofuz
parents:
diff changeset
12 __attribute__((os_returns_retained)) S *ret_retained() {
anatofuz
parents:
diff changeset
13 return nullptr;
anatofuz
parents:
diff changeset
14 }
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 __attribute__((os_returns_retained)) S ret_retained_value() { // expected-warning{{'os_returns_retained' attribute only applies to functions that return a pointer}}
anatofuz
parents:
diff changeset
17 return {};
anatofuz
parents:
diff changeset
18 }
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 __attribute__((os_returns_not_retained)) S *ret_not_retained() {
anatofuz
parents:
diff changeset
21 return nullptr;
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 __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}}
anatofuz
parents:
diff changeset
25 return {};
anatofuz
parents:
diff changeset
26 }
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 void accept_consumed_arg(__attribute__((os_consumed)) S *arg) {}
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 void accept_consumed_arg_by_value(__attribute__((os_consumed)) S arg) {} // expected-warning{{os_consumed attribute only applies to pointer parameters}}
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 void accept_consumed_arg_no_extra_arg(__attribute__((os_consumed(10))) S *arg) {} // expected-error{{'os_consumed' attribute takes no arguments}}
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 struct __attribute__((os_consumed)) NoAttrOnStruct {}; // expected-warning{{'os_consumed' attribute only applies to parameters}}
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 __attribute__((os_returns_retained(10))) S* returns_retained_no_extra_arg() { // expected-error{{'os_returns_retained' attribute takes no arguments}}
anatofuz
parents:
diff changeset
37 return nullptr;
anatofuz
parents:
diff changeset
38 }
anatofuz
parents:
diff changeset
39
anatofuz
parents:
diff changeset
40 struct __attribute__((os_returns_retained)) NoRetainAttrOnStruct {}; // expected-warning{{'os_returns_retained' attribute only applies to functions, Objective-C methods, Objective-C properties, and parameters}}
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 __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}}
anatofuz
parents:
diff changeset
43 return nullptr;
anatofuz
parents:
diff changeset
44 }
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 struct __attribute__((os_returns_not_retained)) NoNotRetainedAttrOnStruct {}; // expected-warning{{'os_returns_not_retained' attribute only applies to functions, Objective-C methods, Objective-C properties, and parameters}}
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 __attribute__((os_consumes_this)) void no_consumes_this_on_function() {} // expected-warning{{'os_consumes_this' attribute only applies to non-static member functions}}
anatofuz
parents:
diff changeset
49
anatofuz
parents:
diff changeset
50 void write_into_out_parameter(__attribute__((os_returns_retained)) S** out) {}
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 bool write_into_out_parameter_on_nonzero(__attribute__((os_returns_retained_on_non_zero)) S** out) {}
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 bool write_into_out_parameter_on_nonzero_invalid(__attribute__((os_returns_retained_on_non_zero)) S* out) {} // expected-warning{{'os_returns_retained_on_non_zero' attribute only applies to pointer/reference-to-OSObject-pointer parameters}}
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 bool write_into_out_parameter_on_zero(__attribute__((os_returns_retained_on_zero)) S** out) {}
anatofuz
parents:
diff changeset
57
anatofuz
parents:
diff changeset
58 bool write_into_out_parameter_on_zero_invalid(__attribute__((os_returns_retained_on_zero)) S* out) {} // expected-warning{{'os_returns_retained_on_zero' attribute only applies to pointer/reference-to-OSObject-pointer parameters}}
anatofuz
parents:
diff changeset
59
anatofuz
parents:
diff changeset
60 void write_into_out_parameter_ref(__attribute__((os_returns_retained)) S*& out) {}
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 typedef S* SPtr;
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 void write_into_out_parameter_typedef(__attribute__((os_returns_retained)) SPtr* out) {}
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 void write_into_out_parameter_invalid(__attribute__((os_returns_retained)) S* out) {} // expected-warning{{'os_returns_retained' attribute only applies to pointer/reference-to-OSObject-pointer parameters}}
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 void write_into_out_parameter_not_retained(__attribute__((os_returns_not_retained)) S **out) {}
anatofuz
parents:
diff changeset
69
anatofuz
parents:
diff changeset
70 void write_into_out_parameter_not_retained(__attribute__((os_returns_not_retained)) S volatile * const * const out) {}
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 void write_into_not_retainedout_parameter_invalid(__attribute__((os_returns_not_retained)) S* out) {} // expected-warning{{'os_returns_not_retained' attribute only applies to pointer/reference-to-OSObject-pointer parameters}}
anatofuz
parents:
diff changeset
73
anatofuz
parents:
diff changeset
74 void write_into_not_retainedout_parameter_too_many_pointers(__attribute__((os_returns_not_retained)) S*** out) {} // expected-warning{{'os_returns_not_retained' attribute only applies to pointer/reference-to-OSObject-pointer parameters}}