aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/attr-capabilities.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:11:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:11:37 +0000
commit461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch)
tree6942083d7d56bba40ec790a453ca58ad3baf6832 /test/Sema/attr-capabilities.cpp
parent75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff)
Notes
Diffstat (limited to 'test/Sema/attr-capabilities.cpp')
-rw-r--r--test/Sema/attr-capabilities.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/Sema/attr-capabilities.cpp b/test/Sema/attr-capabilities.cpp
new file mode 100644
index 0000000000000..5bae94edaa41f
--- /dev/null
+++ b/test/Sema/attr-capabilities.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -Wthread-safety -verify %s
+
+class __attribute__((shared_capability("mutex"))) Mutex {
+ public:
+ void func1() __attribute__((assert_capability(this)));
+ void func2() __attribute__((assert_capability(!this)));
+
+ const Mutex& operator!() const { return *this; }
+};
+
+class NotACapability {
+ public:
+ void func1() __attribute__((assert_capability(this))); // expected-warning {{'assert_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'NotACapability *'}}
+ void func2() __attribute__((assert_capability(!this))); // expected-warning {{'assert_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'bool'}}
+
+ const NotACapability& operator!() const { return *this; }
+};