annotate clang/test/Sema/attr-ownership.c @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -verify -fsyntax-only
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 void f1(void) __attribute__((ownership_takes("foo"))); // expected-error {{'ownership_takes' attribute requires parameter 1 to be an identifier}}
anatofuz
parents:
diff changeset
4 void *f2(void) __attribute__((ownership_returns(foo, 1, 2))); // expected-error {{'ownership_returns' attribute takes no more than 1 argument}}
anatofuz
parents:
diff changeset
5 void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
anatofuz
parents:
diff changeset
6 void *f4(void) __attribute__((ownership_returns(foo)));
anatofuz
parents:
diff changeset
7 void f5(void) __attribute__((ownership_holds(foo))); // expected-error {{'ownership_holds' attribute takes at least 2 arguments}}
anatofuz
parents:
diff changeset
8 void f6(void) __attribute__((ownership_holds(foo, 1, 2, 3))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
anatofuz
parents:
diff changeset
9 void f7(void) __attribute__((ownership_takes(foo))); // expected-error {{'ownership_takes' attribute takes at least 2 arguments}}
anatofuz
parents:
diff changeset
10 void f8(int *i, int *j, int k) __attribute__((ownership_holds(foo, 1, 2, 4))); // expected-error {{'ownership_holds' attribute parameter 3 is out of bounds}}
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 int f9 __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to non-K&R-style functions}}
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 void f10(int i) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute only applies to pointer arguments}}
anatofuz
parents:
diff changeset
15 void *f11(float i) __attribute__((ownership_returns(foo, 1))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
anatofuz
parents:
diff changeset
16 void *f12(float i, int k, int f, int *j) __attribute__((ownership_returns(foo, 4))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_takes(foo, 2)));
anatofuz
parents:
diff changeset
19 void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) __attribute__((ownership_takes(foo, 3))); // expected-error {{'ownership_takes' and 'ownership_holds' attributes are not compatible}}
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 void f15(int, int)
anatofuz
parents:
diff changeset
22 __attribute__((ownership_returns(foo, 1))) // expected-error {{'ownership_returns' attribute index does not match; here it is 1}}
anatofuz
parents:
diff changeset
23 __attribute__((ownership_returns(foo, 2))); // expected-note {{declared with index 2 here}}
anatofuz
parents:
diff changeset
24 void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
anatofuz
parents:
diff changeset
25 void f17(void*) __attribute__((ownership_takes(__, 1)));
anatofuz
parents:
diff changeset
26 void f18() __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to non-K&R-style functions}}