• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: no-threads
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // REQUIRES: libcpp-hardening-mode={{extensive|debug}}
11 
12 // XFAIL: availability-verbose_abort-missing
13 
14 // REQUIRES: has-unix-headers
15 
16 // <barrier>
17 
18 // class barrier;
19 
20 // void arrive(ptrdiff_t __update = 1);
21 
22 // Make sure that calling arrive with a negative value or with a value greater than 'expected' triggers an assertion
23 
24 #include <barrier>
25 
26 #include "check_assertion.h"
27 
main(int,char **)28 int main(int, char**) {
29   {
30     std::barrier<> b(5);
31     TEST_LIBCPP_ASSERT_FAILURE(b.arrive(0), "barrier:arrive must be called with a value greater than 0");
32   }
33 
34   {
35     std::barrier<> b(5);
36     TEST_LIBCPP_ASSERT_FAILURE(b.arrive(10), "update is greater than the expected count for the current barrier phase");
37   }
38 
39   return 0;
40 }
41