Daily bump.
[official-gcc.git] / libstdc++-v3 / testsuite / 17_intro / tag_type_explicit_ctor.cc
blobacb34974d56ca9e7a5ad11f9ff739b7e669d95b6
1 // { dg-do compile { target c++11 } }
3 // Copyright (C) 2015-2024 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 #include <new>
21 #include <utility>
22 #include <memory>
24 #if __STDC_HOSTED__
25 # include <mutex>
26 #endif
28 void f1(std::nothrow_t);
29 void f2(std::piecewise_construct_t);
30 void f3(std::allocator_arg_t);
31 #if __STDC_HOSTED__
32 void f4(std::defer_lock_t);
33 void f5(std::try_to_lock_t);
34 void f6(std::adopt_lock_t);
35 #endif
37 #pragma GCC diagnostic ignored "-Wunused-variable"
39 int main()
41 std::nothrow_t v1;
42 std::piecewise_construct_t v2;
43 std::allocator_arg_t v3;
44 #if __STDC_HOSTED__
45 std::defer_lock_t v4;
46 std::try_to_lock_t v5;
47 std::try_to_lock_t v6;
48 #endif
49 std::nothrow_t v7 = {}; // { dg-error "explicit" }
50 std::piecewise_construct_t v8 = {}; // { dg-error "explicit" }
51 std::allocator_arg_t v9 = {}; // { dg-error "explicit" }
52 #if __STDC_HOSTED__
53 std::defer_lock_t v10 = {}; // { dg-error "explicit" "" { target hosted } }
54 std::try_to_lock_t v11 = {}; // { dg-error "explicit" "" { target hosted } }
55 std::try_to_lock_t v12 = {}; // { dg-error "explicit" "" { target hosted } }
56 #endif
57 f1(std::nothrow_t{});
58 f2(std::piecewise_construct_t{});
59 f3(std::allocator_arg_t{});
60 f1({}); // { dg-error "explicit" }
61 f2({}); // { dg-error "explicit" }
62 f3({}); // { dg-error "explicit" }
63 #if __STDC_HOSTED__
64 f4(std::defer_lock_t{});
65 f5(std::try_to_lock_t{});
66 f6(std::adopt_lock_t{});
67 f4({}); // { dg-error "explicit" "" { target hosted } }
68 f5({}); // { dg-error "explicit" "" { target hosted } }
69 f6({}); // { dg-error "explicit" "" { target hosted } }
70 #endif