| Aaron Ballman | efe348e | 2014-02-18 17:36:50 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wthread-safety -verify %s
|
| 2 |
|
| 3 | struct __attribute__((capability("thread role"))) ThreadRole {};
|
| 4 | struct __attribute__((shared_capability("mutex"))) Mutex {};
|
| 5 | struct NotACapability {};
|
| 6 |
|
| 7 | int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs}}
|
| 8 | int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs}}
|
| 9 |
|
| 10 | struct __attribute__((capability(12))) Test3 {}; // expected-error {{'capability' attribute requires a string}}
|
| 11 | struct __attribute__((shared_capability(Test2))) Test4 {}; // expected-error {{'shared_capability' attribute requires a string}}
|
| 12 |
|
| 13 | struct __attribute__((capability)) Test5 {}; // expected-error {{'capability' attribute takes one argument}}
|
| 14 | struct __attribute__((shared_capability("test1", 12))) Test6 {}; // expected-error {{'shared_capability' attribute takes one argument}}
|
| 15 |
|
| 16 | struct NotACapability BadCapability;
|
| 17 | struct ThreadRole GUI, Worker;
|
| 18 | void Func1(void) __attribute__((requires_capability(GUI))) {}
|
| 19 | void Func2(void) __attribute__((requires_shared_capability(Worker))) {}
|
| 20 |
|
| 21 | void Func3(void) __attribute__((requires_capability)) {} // expected-error {{'requires_capability' attribute takes at least 1 argument}}
|
| 22 | void Func4(void) __attribute__((requires_shared_capability)) {} // expected-error {{'requires_shared_capability' attribute takes at least 1 argument}}
|
| 23 |
|
| 24 | void Func5(void) __attribute__((requires_capability(1))) {} // expected-warning {{'requires_capability' attribute requires arguments that are class type or point to class type}}
|
| 25 | void Func6(void) __attribute__((requires_shared_capability(BadCapability))) {} // expected-warning {{'requires_shared_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'struct NotACapability'}}
|