re PR libfortran/69799 (FAIL: gfortran.dg/coarray_allocate_3.f08 at -O1 and above)
[official-gcc.git] / libstdc++-v3 / testsuite / 18_support / exception_ptr / requirements.cc
blobec016ca326bfdc3223d16caa7081ca784e4a7cb0
1 // { dg-options "-std=gnu++11" }
2 // { dg-require-atomic-builtins "" }
4 // Copyright (C) 2010-2016 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <exception>
22 #include <testsuite_hooks.h>
24 // test NullablePointer requirements
25 void test01()
27 std::exception_ptr p1; // DefaultConstructible
28 std::exception_ptr p2(p1); // CopyConstructible
29 p1 = p2; // CopyAssignable
30 VERIFY( p1 == p2 ); // EqualityComparable
31 VERIFY( !bool(p1) ); // contextually convertible to bool
32 swap(p1, p2); // Swappable
34 // Table 39 expressions
35 std::exception_ptr p3 = nullptr;
36 std::exception_ptr p4(nullptr);
37 VERIFY( std::exception_ptr() == nullptr );
38 p4 = nullptr;
39 VERIFY( p4 == nullptr );
40 VERIFY( nullptr == p4 );
41 VERIFY( (p4 != nullptr) == !(p4 == nullptr) );
42 VERIFY( (nullptr != p4) == !(p4 == nullptr) );
44 std::exception_ptr p5{}; // value initialized ...
45 VERIFY( p5 == nullptr ); // ... is equivalent to null
48 // additional exception_ptr requirements
49 void test02()
51 std::exception_ptr p1;
52 VERIFY( p1 == nullptr );
55 int main()
57 test01();
58 test02();
59 return 0;