1118824Sharti// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
2118824Sharti// { dg-options " -std=gnu++14 -pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
3118824Sharti// { dg-options " -std=gnu++14 -pthreads" { target *-*-solaris* } }
4118824Sharti// { dg-options " -std=gnu++14 " { target *-*-cygwin *-*-darwin* } }
5118824Sharti// { dg-require-cstdint "" }
6118824Sharti
7118824Sharti// Copyright (C) 2013-2015 Free Software Foundation, Inc.
8118824Sharti//
9118824Sharti// This file is part of the GNU ISO C++ Library.  This library is free
10118824Sharti// software; you can redistribute it and/or modify it under the
11118824Sharti// terms of the GNU General Public License as published by the
12132494Sharti// Free Software Foundation; either version 3, or (at your option)
13118824Sharti// any later version.
14118824Sharti
15132494Sharti// This library is distributed in the hope that it will be useful,
16118824Sharti// but WITHOUT ANY WARRANTY; without even the implied warranty of
17118824Sharti// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18118824Sharti// GNU General Public License for more details.
19118824Sharti
20118824Sharti// You should have received a copy of the GNU General Public License along
21118824Sharti// with this library; see the file COPYING3.  If not see
22118824Sharti// <http://www.gnu.org/licenses/>.
23118824Sharti
24118824Sharti
25118824Sharti#include <chrono>
26118824Sharti#include <shared_mutex>
27118824Sharti#include <system_error>
28132494Sharti#include <testsuite_hooks.h>
29118824Sharti
30118824Shartiint main()
31118824Sharti{
32118824Sharti  bool test __attribute__((unused)) = true;
33118824Sharti  typedef std::shared_timed_mutex mutex_type;
34118824Sharti  typedef std::shared_lock<mutex_type> lock_type;
35118824Sharti
36118824Sharti  try
37118824Sharti    {
38132494Sharti      mutex_type m;
39118824Sharti      lock_type l(m, std::defer_lock);
40118824Sharti
41132494Sharti      try
42118824Sharti	{
43118824Sharti	  l.try_lock_for(std::chrono::milliseconds(100));
44132494Sharti	}
45118824Sharti      catch(const std::system_error&)
46118824Sharti	{
47118824Sharti	  VERIFY( false );
48118824Sharti	}
49118824Sharti      catch (...)
50118824Sharti	{
51118824Sharti	  VERIFY( false );
52118824Sharti	}
53118824Sharti
54118824Sharti      VERIFY( l.owns_lock() );
55118824Sharti    }
56118824Sharti  catch (const std::system_error&)
57118824Sharti    {
58118824Sharti      VERIFY( false );
59118824Sharti    }
60118824Sharti  catch (...)
61118824Sharti    {
62118824Sharti      VERIFY( false );
63118824Sharti    }
64118824Sharti
65118824Sharti  return 0;
66118824Sharti}
67118824Sharti