brintos

brintos / llvm-project-archived public Read only

0
0
Text · 863 B · 9633982 Raw
41 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-safety17 18// XFAIL: FROZEN-CXX03-HEADERS-FIXME19 20#include <mutex>21 22#include "test_macros.h"23 24std::mutex m;25int foo __attribute__((guarded_by(m)));26 27static void scoped() {28#if TEST_STD_VER >= 1729  std::scoped_lock<std::mutex> lock(m);30  foo++;31#endif32}33 34int main(int, char**) {35  scoped();36  std::lock_guard<std::mutex> lock(m);37  foo++;38 39  return 0;40}41