48 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: no-threads10 11// <mutex>12 13// GCC doesn't have thread safety attributes14// UNSUPPORTED: gcc15 16// ADDITIONAL_COMPILE_FLAGS: -Wthread-safety -Wno-comment17 18// XFAIL: FROZEN-CXX03-HEADERS-FIXME19 20#include <mutex>21 22#include "test_macros.h"23 24std::mutex m0;25std::mutex m1;26std::mutex m2;27std::mutex m3;28 29void f1() {30 std::lock(m0, m1);31} // expected-warning {{mutex 'm0' is still held at the end of function}} \32 expected-warning {{mutex 'm1' is still held at the end of function}}33 34#if TEST_STD_VER >= 11 && defined(TEST_CLANG_VER) && TEST_CLANG_VER >= 210135void f2() {36 std::lock(m0, m1, m2);37} // expected-warning {{mutex 'm0' is still held at the end of function}} \38 expected-warning {{mutex 'm1' is still held at the end of function}} \39 expected-warning {{mutex 'm2' is still held at the end of function}}40 41void f3() {42 std::lock(m0, m1, m2, m3);43} // expected-warning {{mutex 'm0' is still held at the end of function}} \44 expected-warning {{mutex 'm1' is still held at the end of function}} \45 expected-warning {{mutex 'm2' is still held at the end of function}} \46 expected-warning {{mutex 'm3' is still held at the end of function}}47#endif48