| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
// Decl annotations. |
| 4 |
void f(int *a __attribute__((acquire_handle("Fuchsia")))); |
| 5 |
void (*fp)(int handle [[clang::use_handle("Fuchsia")]]); |
| 6 |
auto lambda = [](int handle [[clang::use_handle("Fuchsia")]]){}; |
| 7 |
void g(int a __attribute__((acquire_handle("Fuchsia")))); // expected-error {{attribute only applies to output parameters}} |
| 8 |
void h(int *a __attribute__((acquire_handle))); // expected-error {{'acquire_handle' attribute takes one argument}} |
| 9 |
void h(int *a __attribute__((acquire_handle(1)))); // expected-error {{expected string literal as argument of 'acquire_handle' attribute}} |
| 10 |
void h(int *a __attribute__((acquire_handle("RandomString", "AndAnother")))); // expected-error {{'acquire_handle' attribute takes one argument}} |
| 11 |
__attribute__((release_handle("Fuchsia"))) int i(); // expected-warning {{'release_handle' attribute only applies to parameters}} |
| 12 |
__attribute__((use_handle("Fuchsia"))) int j(); // expected-warning {{'use_handle' attribute only applies to parameters}} |
| 13 |
int a __attribute__((acquire_handle("Fuchsia"))); // expected-warning {{'acquire_handle' attribute only applies to functions, typedefs, and parameters}} |
| 14 |
int (* __attribute__((acquire_handle("Fuchsia"))) fpt)(char *); // expected-warning {{'acquire_handle' attribute only applies to functions, typedefs, and parameters}} |
| 15 |
|
| 16 |
// Type annotations. |
| 17 |
auto lambdat = [](int handle __attribute__((use_handle("Fuchsia")))) |
| 18 |
__attribute__((acquire_handle("Fuchsia"))) -> int { return 0; }; |
| 19 |
int __attribute((acquire_handle("Fuchsia"))) ta; // expected-warning {{'acquire_handle' attribute only applies to functions, typedefs, and parameters}} |
| 20 |
int open(const char *path, int flags, ...) [[clang::acquire_handle]]; // expected-error {{'clang::acquire_handle' attribute takes one argument}} |
| 21 |
|
| 22 |
// Typedefs. |
| 23 |
typedef int callback(char *) __attribute__((acquire_handle("Fuchsia"))); |