Joel E. Denny | 9010ee6 | 2018-03-02 19:03:27 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -verify -fsyntax-only |
Alp Toker | e11bd86 | 2013-10-20 19:04:19 +0000 | [diff] [blame] | 2 | |
| 3 | void f1(void) __attribute__((ownership_takes("foo"))); // expected-error {{'ownership_takes' attribute requires parameter 1 to be an identifier}} |
Aaron Ballman | 05e420a | 2014-01-02 21:26:14 +0000 | [diff] [blame] | 4 | void *f2(void) __attribute__((ownership_returns(foo, 1, 2))); // expected-error {{'ownership_returns' attribute takes no more than 1 argument}} |
Alp Toker | e11bd86 | 2013-10-20 19:04:19 +0000 | [diff] [blame] | 5 | void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}} |
| 6 | void *f4(void) __attribute__((ownership_returns(foo))); |
Aaron Ballman | 05e420a | 2014-01-02 21:26:14 +0000 | [diff] [blame] | 7 | void f5(void) __attribute__((ownership_holds(foo))); // expected-error {{'ownership_holds' attribute takes at least 2 arguments}} |
Alp Toker | e11bd86 | 2013-10-20 19:04:19 +0000 | [diff] [blame] | 8 | void f6(void) __attribute__((ownership_holds(foo, 1, 2, 3))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}} |
Aaron Ballman | 05e420a | 2014-01-02 21:26:14 +0000 | [diff] [blame] | 9 | void f7(void) __attribute__((ownership_takes(foo))); // expected-error {{'ownership_takes' attribute takes at least 2 arguments}} |
Alp Toker | e11bd86 | 2013-10-20 19:04:19 +0000 | [diff] [blame] | 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}} |
| 11 | |
Dimitry Andric | b1aa87e | 2016-01-03 15:55:40 +0000 | [diff] [blame] | 12 | int f9 __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to non-K&R-style functions}} |
Alp Toker | e11bd86 | 2013-10-20 19:04:19 +0000 | [diff] [blame] | 13 | |
| 14 | void f10(int i) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute only applies to pointer arguments}} |
| 15 | void *f11(float i) __attribute__((ownership_returns(foo, 1))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}} |
| 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}} |
| 17 | |
| 18 | void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_takes(foo, 2))); |
Michael Kruse | dc5ce72 | 2018-08-03 01:21:16 +0000 | [diff] [blame] | 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}} |
Aaron Ballman | ef7aef8 | 2014-07-31 20:44:26 +0000 | [diff] [blame] | 20 | |
| 21 | void f15(int, int) |
Michael Kruse | dc5ce72 | 2018-08-03 01:21:16 +0000 | [diff] [blame] | 22 | __attribute__((ownership_returns(foo, 1))) // expected-error {{'ownership_returns' attribute index does not match; here it is 1}} |
| 23 | __attribute__((ownership_returns(foo, 2))); // expected-note {{declared with index 2 here}} |
Dimitry Andric | b1aa87e | 2016-01-03 15:55:40 +0000 | [diff] [blame] | 24 | void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index |
| 25 | void f17(void*) __attribute__((ownership_takes(__, 1))); |
| 26 | void f18() __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to non-K&R-style functions}} |