diff options
Diffstat (limited to 'test/Sema/attr-capabilities.c')
-rw-r--r-- | test/Sema/attr-capabilities.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/Sema/attr-capabilities.c b/test/Sema/attr-capabilities.c index 5bfbdacf508f..89967704865f 100644 --- a/test/Sema/attr-capabilities.c +++ b/test/Sema/attr-capabilities.c @@ -4,11 +4,15 @@ typedef int __attribute__((capability("role"))) ThreadRole; struct __attribute__((shared_capability("mutex"))) Mutex {}; struct NotACapability {}; +// Put capability attributes on unions +union __attribute__((capability("mutex"))) MutexUnion { int a; char* b; }; +typedef union { int a; char* b; } __attribute__((capability("mutex"))) MutexUnion2; + // Test an invalid capability name struct __attribute__((capability("wrong"))) IncorrectName {}; // expected-warning {{invalid capability name 'wrong'; capability name must be 'mutex' or 'role'}} -int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs and typedefs}} -int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs and typedefs}} +int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs, unions, and typedefs}} +int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs, unions, and typedefs}} int Test3 __attribute__((acquire_capability("test3"))); // expected-warning {{'acquire_capability' attribute only applies to functions}} int Test4 __attribute__((try_acquire_capability("test4"))); // expected-error {{'try_acquire_capability' attribute only applies to functions}} int Test5 __attribute__((release_capability("test5"))); // expected-warning {{'release_capability' attribute only applies to functions}} |