1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // On Windows Clang bugs out when both __declspec and __attribute__ are present, 11 // the processing goes awry preventing the definition of the types. 12 // XFAIL: LIBCXX-WINDOWS-FIXME 13 14 // UNSUPPORTED: libcpp-has-no-threads 15 // REQUIRES: thread-safety 16 17 // <mutex> 18 19 // MODULES_DEFINES: _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS 20 #define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS 21 22 #include <mutex> 23 24 std::mutex m; 25 int foo __attribute__((guarded_by(m))); 26 27 int main() { 28 m.lock(); 29 foo++; 30 m.unlock(); 31 } 32