diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-10-05 22:38:19 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-10-05 22:38:19 +0000 |
commit | ef2388b10c41a9696d5d81f42ca79ff005fef7fc (patch) | |
tree | f17cf273f4a7b43b86a43dc0a8d0a2108a254e72 /test/SemaCXX/warn-thread-safety-analysis.cpp | |
parent | efdfc1d38bdfa6c9c2ac47f883dd602f12e29807 (diff) |
Thread-safety analysis: allow attributes on constructors to refer to 'this'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/warn-thread-safety-analysis.cpp')
-rw-r--r-- | test/SemaCXX/warn-thread-safety-analysis.cpp | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp index a82d265a7e..92d88c0970 100644 --- a/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/test/SemaCXX/warn-thread-safety-analysis.cpp @@ -1543,22 +1543,6 @@ namespace constructor_destructor_tests { } -namespace invalid_lock_expression_test { - -class LOCKABLE MyLockable { -public: - MyLockable() __attribute__((exclusive_lock_function)) { } - ~MyLockable() { } -}; - -// create an empty lock expression -void foo() { - MyLockable lock; // \ - // expected-warning {{cannot resolve lock expression}} -} - -} // end namespace invalid_lock_expression_test - namespace template_member_test { struct S { int n; }; @@ -3603,3 +3587,37 @@ void testFooT() { } // end namespace TemplateFunctionParamRemapTest + +namespace SelfConstructorTest { + +class SelfLock { +public: + SelfLock() EXCLUSIVE_LOCK_FUNCTION(mu_); + ~SelfLock() UNLOCK_FUNCTION(mu_); + + void foo() EXCLUSIVE_LOCKS_REQUIRED(mu_); + + Mutex mu_; +}; + +class LOCKABLE SelfLock2 { +public: + SelfLock2() EXCLUSIVE_LOCK_FUNCTION(); + ~SelfLock2() UNLOCK_FUNCTION(); + + void foo() EXCLUSIVE_LOCKS_REQUIRED(this); +}; + + +void test() { + SelfLock s; + s.foo(); +} + +void test2() { + SelfLock2 s2; + s2.foo(); +} + +} // end namespace SelfConstructorTest + |