diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2019-05-07 17:31:12 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2019-05-07 17:31:12 +0000 |
commit | eec33732a01453baedb2598c6997bad6a39d9e1e (patch) | |
tree | 15c52c0770d845cf0053e959a8b998cda7ddec25 /libstdc++-v3/testsuite | |
parent | 6ffaf63f736250e03afb9974fe5a32b50c69bdef (diff) | |
parent | a91db438b583050311a6eb845d05775b14e09f1d (diff) |
svn merge -r270931:270974 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branchredhat/gcc-8-branch
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/redhat/gcc-8-branch@270976 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
28 files changed, 505 insertions, 27 deletions
diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc index 4a71021f2a0..08a317b95b6 100644 --- a/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc @@ -30,6 +30,7 @@ namespace std typedef void test_type5; typedef const void test_type6; + template struct common_type<>; template struct common_type<test_type1>; template struct common_type<test_type1, test_type2>; template struct common_type<test_type1, test_type2, test_type3>; diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc index 0907f9df24b..e933d5206b6 100644 --- a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc @@ -159,7 +159,10 @@ namespace std { }; } +static_assert(is_type<std::common_type<int>, int>(), ""); +static_assert(is_type<std::common_type<const int>, int>(), ""); static_assert(is_type<std::common_type<int, int>, int>(), ""); +static_assert(is_type<std::common_type<const int, int>, int>(), ""); static_assert(is_type<std::common_type<ScEn, ScEn>, ScEn>(), ""); static_assert(is_type<std::common_type<UnscEn, UnscEn>, UnscEn>(), ""); static_assert(is_type<std::common_type<UnscEn, int>, int>(), ""); @@ -180,6 +183,8 @@ static_assert(is_type<std::common_type<int*, const volatile int*>, const volatile int*>(), ""); static_assert(is_type<std::common_type<void*, const volatile int*>, const volatile void*>(), ""); +static_assert(is_type<std::common_type<void>, void>(), ""); +static_assert(is_type<std::common_type<const void>, void>(), ""); static_assert(is_type<std::common_type<void, void>, void>(), ""); static_assert(is_type<std::common_type<const void, const void>, void>(), ""); static_assert(is_type<std::common_type<int&, int&&>, int>(), ""); @@ -316,6 +321,14 @@ static_assert(!has_type<std::common_type<UConv1, Abstract&&>>(), ""); static_assert(!has_type<std::common_type<std::initializer_list<int>, std::initializer_list<long>>>(), ""); +// PR libstdc++/89102 +static_assert(!has_type<std::common_type<int() &>>(), ""); +static_assert(!has_type<std::common_type<int() & noexcept>>(), ""); +static_assert(!has_type<std::common_type<int() const>>(), ""); +static_assert(!has_type<std::common_type<int(...) &>>(), ""); +static_assert(!has_type<std::common_type<int(...) & noexcept>>(), ""); +static_assert(!has_type<std::common_type<int(...) const>>(), ""); + void test(int i) { auto local_lmd1 = [=](int, double) { return i + i; }; diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc index 8b0e9fd3f33..7758a7d08e5 100644 --- a/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc @@ -25,7 +25,7 @@ template<typename... Args> constexpr std::array<typename std::common_type<Args...>::type, sizeof...(Args)> -make_array(Args&&... args) // { dg-error "invalid use" } +make_array(Args&&... args) // { dg-error "no type.*common_type<>" } { typedef typename std::common_type<Args...>::type CT; return std::array<CT, sizeof...(Args)>{static_cast<CT> diff --git a/libstdc++-v3/testsuite/20_util/hash/89629.cc b/libstdc++-v3/testsuite/20_util/hash/89629.cc new file mode 100644 index 00000000000..fd8273087fc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/hash/89629.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target { lp64 || llp64 } } } +// { dg-require-effective-target c++11 } +// { dg-require-effective-target run_expensive_tests } + +#include <functional> +#include <string> + +void +test01() +{ + const std::size_t big = std::size_t(1) << 31; + std::string s; + try { + s.resize(big, 'a'); + } catch (const std::bad_alloc&) { + return; // try to avoid a FAIL if memory allocation fails + } + // PR libstdc++/89629 + (void) std::hash<std::string>{}(s); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc b/libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc index 7743221adf7..12b0b9393c6 100644 --- a/libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc +++ b/libstdc++-v3/testsuite/20_util/optional/constexpr/observers/4.cc @@ -25,10 +25,42 @@ struct value_type int i; }; -int main() +void test01() { constexpr std::optional<value_type> o { value_type { 51 } }; constexpr value_type fallback { 3 }; - static_assert( o.value_or(fallback).i == 51, "" ); - static_assert( o.value_or(fallback).i == (*o).i, "" ); + static_assert( o.value_or(fallback).i == 51 ); + static_assert( o.value_or(fallback).i == (*o).i ); +} + +void test02() +{ + constexpr std::optional<value_type> o; + constexpr value_type fallback { 3 }; + static_assert( o.value_or(fallback).i == 3 ); +} + +template<typename T> + constexpr std::optional<value_type> + make_rvalue(T t) + { return std::optional<value_type>{t}; } + +void test03() +{ + constexpr value_type fallback { 3 }; + static_assert( make_rvalue(value_type{51}).value_or(fallback).i == 51 ); +} + +void test04() +{ + constexpr value_type fallback { 3 }; + static_assert( make_rvalue(std::nullopt).value_or(fallback).i == 3 ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); } diff --git a/libstdc++-v3/testsuite/20_util/optional/observers/4.cc b/libstdc++-v3/testsuite/20_util/optional/observers/4.cc index ac8515f4cff..6f528b5c916 100644 --- a/libstdc++-v3/testsuite/20_util/optional/observers/4.cc +++ b/libstdc++-v3/testsuite/20_util/optional/observers/4.cc @@ -26,10 +26,42 @@ struct value_type int i; }; -int main() +void test01() { std::optional<value_type> o { value_type { 51 } }; value_type fallback { 3 }; VERIFY( o.value_or(fallback).i == 51 ); VERIFY( o.value_or(fallback).i == (*o).i ); } + +void test02() +{ + std::optional<value_type> o; + value_type fallback { 3 }; + VERIFY( o.value_or(fallback).i == 3 ); +} + +void test03() +{ + std::optional<value_type> o { value_type { 51 } }; + value_type fallback { 3 }; + VERIFY( std::move(o).value_or(fallback).i == 51 ); + VERIFY( o.has_value() ); + VERIFY( std::move(o).value_or(fallback).i == (*o).i ); +} + +void test04() +{ + std::optional<value_type> o; + value_type fallback { 3 }; + VERIFY( std::move(o).value_or(fallback).i == 3 ); + VERIFY( !o.has_value() ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); +} diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc index 621ff47c7a3..3b2da30a065 100644 --- a/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc +++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc @@ -46,5 +46,5 @@ test01() scoped_alloc sa; auto p = sa.allocate(1); sa.construct(p); // this is required to be ill-formed - // { dg-error "static assertion failed" "" { target *-*-* } 90 } + // { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 } } diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/dr2586.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/dr2586.cc new file mode 100644 index 00000000000..11aab8a420b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/dr2586.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile { target c++11 } } + +#include <memory> +#include <scoped_allocator> + +// DR 2586. Wrong value category used in scoped_allocator_adaptor::construct() + +struct X { + using allocator_type = std::allocator<X>; + X(std::allocator_arg_t, allocator_type&&) { } + X(const allocator_type&) { } +}; + +int main() { + std::scoped_allocator_adaptor<std::allocator<X>> sa; + sa.construct(sa.allocate(1)); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc index eb444f76cbe..85e43c9c16f 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc @@ -181,9 +181,23 @@ void test02() test_type empty = make_tuple(); } +void test03() +{ + struct dr2586 + { + using allocator_type = std::allocator<int>; + dr2586(std::allocator_arg_t, allocator_type&&) { } + dr2586(const allocator_type&) { } + }; + + const dr2586::allocator_type a; + std::tuple<dr2586> t{std::allocator_arg, a}; +} + int main() { test01(); test02(); + test03(); return 0; } diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc index 348ed41a7bc..b1c6eab4c23 100644 --- a/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc @@ -44,5 +44,5 @@ test01() { alloc_type a; std::tuple<X> t(std::allocator_arg, a); // this is required to be ill-formed - // { dg-error "static assertion failed" "" { target *-*-* } 90 } + // { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 } } diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc index 8894e389cec..b0525d1f290 100644 --- a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc @@ -43,4 +43,4 @@ void test01() tuple<Type> t(allocator_arg, a, 1); } -// { dg-error "static assertion failed" "" { target *-*-* } 90 } +// { dg-error "failed: .* uses_allocator is true" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc index 0b8eaf04b0d..811389a8fd7 100644 --- a/libstdc++-v3/testsuite/20_util/variant/compile.cc +++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc @@ -129,10 +129,15 @@ void arbitrary_ctor() static_assert(noexcept(variant<int, DefaultNoexcept>(DefaultNoexcept{})), ""); } +struct none { none() = delete; }; +struct any { template <typename T> any(T&&) {} }; + void in_place_index_ctor() { variant<string, string> a(in_place_index<0>, "a"); variant<string, string> b(in_place_index<1>, {'a'}); + + static_assert(!is_constructible_v<variant<none, any>, std::in_place_index_t<0>>, "PR libstdc++/90165"); } void in_place_type_ctor() @@ -140,6 +145,7 @@ void in_place_type_ctor() variant<int, string, int> a(in_place_type<string>, "a"); variant<int, string, int> b(in_place_type<string>, {'a'}); static_assert(!is_constructible_v<variant<string, string>, in_place_type_t<string>, const char*>, ""); + static_assert(!is_constructible_v<variant<none, any>, std::in_place_type_t<none>>, "PR libstdc++/90165"); } void dtor() diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc b/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc index aea2db96538..d7a50ee85f7 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc @@ -17,15 +17,11 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. - -// NOTE: This makes use of the fact that we know how moveable -// is implemented on list (via swap). If the implementation changed -// this test may begin to fail. - #include <forward_list> #include <testsuite_hooks.h> -int main() +void +test01() { std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; std::forward_list<double> b = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; @@ -43,6 +39,40 @@ int main() VERIFY((b > a) == true); VERIFY((b >= a) == true); VERIFY((b <= a) == false); +} + +void +test02() +{ + // The EqualityComparable requirements only require == + struct X { + bool operator==(const X&) const { return true; } + }; + + std::forward_list<X> a(2); + const auto b = a; + VERIFY( a == b ); +} + +void +test03() +{ + // The LessThanComparable requirements only require < + struct X { + bool operator<(const X&) const { return false; } + }; - return 0; + std::forward_list<X> a(2); + const auto b = a; + VERIFY( !(a < b) ); + VERIFY( !(a > b) ); + VERIFY( a <= b ); + VERIFY( a >= b ); +} + +int main() +{ + test01(); + test02(); + test03(); } diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc new file mode 100644 index 00000000000..3c1478e2e34 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target c++11 } } + +#include <forward_list> +#include <testsuite_hooks.h> + +// PR libstdc++/90105 - std::forward_list::sort() is not "stable" + +struct X +{ + int key; + int val; +}; + +bool operator<(const X& l, const X& r) +{ return l.key < r.key; } + +bool operator==(const X& l, const X& r) +{ return l.key == r.key && l.val == r.val; } + +void +test01() +{ + std::forward_list<X> l{ {1, 1}, {2, 2}, {1, 3}, {0, 4}, {2, 5}, {0, 6} }; + l.sort(); + std::forward_list<X> exp{ {0, 4}, {0, 6}, {1, 1}, {1, 3}, {2, 2}, {2, 5} }; + VERIFY( l == exp ); +} + +void +test02() +{ + std::forward_list<X> l{ {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6} }; + const std::forward_list<X> exp = l; + l.sort(); + VERIFY( l == exp ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc index df913161bf3..9a63a0aa3c7 100644 --- a/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/48101_neg.cc @@ -23,8 +23,10 @@ void test01() { - std::map<int, int, std::less<int*>> c; // { dg-error "here" } - std::map<int, int, std::allocator<int>> c2; // { dg-error "here" } + std::map<int, int, std::less<int*>> c; + std::map<int, int, std::allocator<int>> c2; } +// { dg-error "_Compare = std::less<int.>" "" { target *-*-* } 0 } +// { dg-error "_Compare = std::allocator<int>" "" { target *-*-* } 0 } // { dg-error "comparison object must be invocable" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc index 5b4e335c91d..5b5f75d6d8c 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/48101_neg.cc @@ -23,8 +23,10 @@ void test01() { - std::multimap<int, int, std::less<int*>> c; // { dg-error "here" } - std::multimap<int, int, std::allocator<int>> c2; // { dg-error "here" } + std::multimap<int, int, std::less<int*>> c; + std::multimap<int, int, std::allocator<int>> c2; } +// { dg-error "_Compare = std::less<int.>" "" { target *-*-* } 0 } +// { dg-error "_Compare = std::allocator<int>" "" { target *-*-* } 0 } // { dg-error "comparison object must be invocable" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc index b815f86219b..b8f92b89bc0 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/48101_neg.cc @@ -23,7 +23,7 @@ void test01() { std::multiset<const int> c; // { dg-error "here" } - std::multiset<int, std::less<long*>> c2; // { dg-error "here" } + std::multiset<int, std::less<long*>> c2; } // { dg-error "non-const, non-volatile value_type" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/dr2537.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/dr2537.cc new file mode 100644 index 00000000000..ecb51780ee5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/priority_queue/dr2537.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target c++11 } } + +#include <queue> +#include <testsuite_hooks.h> + +struct Q : std::priority_queue<int> +{ + using priority_queue::priority_queue; + + bool is_heap() const + { return std::is_heap(c.begin(), c.end()); } +}; + +void +test01() +{ + const Q::value_compare cmp; + const Q::container_type c{ 2, 3, 5, 7, 11, 13, 17, 19, 23 }; + const Q::container_type::allocator_type a; + + Q q1(cmp, c, a); + VERIFY( q1.is_heap() ); + + auto c2 = c; + Q q2(cmp, std::move(c2), a); + VERIFY( q2.is_heap() ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/set/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/set/48101_neg.cc index 9cd728d9bc6..c70c1779a76 100644 --- a/libstdc++-v3/testsuite/23_containers/set/48101_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/48101_neg.cc @@ -23,7 +23,7 @@ void test01() { std::set<const int> c; // { dg-error "here" } - std::set<int, std::less<long*>> c2; // { dg-error "here" } + std::set<int, std::less<long*>> c2; } // { dg-error "non-const, non-volatile value_type" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/set/85965.cc b/libstdc++-v3/testsuite/23_containers/set/85965.cc new file mode 100644 index 00000000000..54d501f6c4f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/85965.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile { target c++11 } } + +#include <set> + +struct Base { }; +struct Derived; // derives from Base, but incomplete at this point + +struct Foo +{ + // PR libstdc++/85965 + std::set<Derived*, std::less<Base*>> s; +}; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc index 956835c916a..17a7c88cddf 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/48101_neg.cc @@ -23,7 +23,7 @@ void test01() { using namespace std; - unordered_map<int, int, equal_to<int>, hash<int>> c2; // { dg-error "here" } + unordered_map<int, int, equal_to<int>, hash<int>> c2; } // { dg-error "hash function must be invocable" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc index ca717e313c6..309e43f71d6 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/48101_neg.cc @@ -23,7 +23,7 @@ void test01() { using namespace std; - unordered_multimap<int, int, equal_to<int>, hash<int>> c2; // { dg-error "here" } + unordered_multimap<int, int, equal_to<int>, hash<int>> c2; } // { dg-error "hash function must be invocable" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc index a06c302ad6b..223a8ebbf61 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/48101_neg.cc @@ -24,7 +24,7 @@ test01() { using namespace std; unordered_multiset<const int, hash<int>> c; // { dg-error "here" } - unordered_multiset<int, equal_to<int>, hash<int>> c2; // { dg-error "here" } + unordered_multiset<int, equal_to<int>, hash<int>> c2; } // { dg-error "non-const, non-volatile value_type" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc index 61f79f917e0..1a10286bb2b 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/48101_neg.cc @@ -24,7 +24,7 @@ test01() { using namespace std; unordered_set<const int, hash<int>> c; // { dg-error "here" } - unordered_set<int, equal_to<int>, hash<int>> c2; // { dg-error "here" } + unordered_set<int, equal_to<int>, hash<int>> c2; } // { dg-error "non-const, non-volatile value_type" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/85965.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/85965.cc new file mode 100644 index 00000000000..8b90b369901 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/85965.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile { target c++11 } } + +#include <unordered_set> + +struct Base { }; +struct Derived; // derives from Base, but incomplete at this point + +struct Foo +{ + // PR libstdc++/85965 + std::unordered_set<Derived*, std::equal_to<Base*>, std::hash<Base*>> u; +}; diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/caching.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/caching.cc new file mode 100644 index 00000000000..101b0cd6b49 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/caching.cc @@ -0,0 +1,76 @@ +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++17 -lstdc++fs" } +// { dg-do run { target c++17 } } +// { dg-require-filesystem-ts "" } + +#include <filesystem> +#include <testsuite_fs.h> +#include <testsuite_hooks.h> + +namespace fs = std::filesystem; + +__gnu_test::scoped_file +create_dir(fs::path dir = __gnu_test::nonexistent_path()) +{ + fs::create_directory(dir); + return { dir, __gnu_test::scoped_file::adopt_file }; +} + +void +test01() +{ + auto testdir = create_dir(); + __gnu_test::scoped_file file1(testdir.path/"file1"); + __gnu_test::scoped_file file2(testdir.path/"file2"); + + fs::directory_iterator it(testdir.path); + VERIFY( it->is_regular_file() ); + ++it; + VERIFY( it->is_regular_file() ); + ++it; + VERIFY( it == fs::directory_iterator{} ); +} + +void +test02() +{ + auto testdir = create_dir(); + const auto sub1 = create_dir(testdir.path/"sub1"); + __gnu_test::scoped_file file1(sub1.path / "file"); + const auto sub2 = create_dir(testdir.path/"sub2"); + __gnu_test::scoped_file file2(sub2.path / "file"); + + fs::recursive_directory_iterator it(testdir.path); + VERIFY( it->is_directory() ); + ++it; + VERIFY( it->is_regular_file() ); + ++it; + VERIFY( it->is_directory() ); + ++it; + VERIFY( it->is_regular_file() ); + ++it; + VERIFY( it == fs::recursive_directory_iterator{} ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc index e8391f46e2d..20d2d880f08 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/assign/copy.cc @@ -21,6 +21,7 @@ #include <filesystem> #include <testsuite_fs.h> +#include <testsuite_hooks.h> using std::filesystem::path; using __gnu_test::compare_paths; @@ -48,9 +49,26 @@ test02() } } +void +test03() +{ + // self assignment should have no effect + const path orig = "foo/bar/baz"; + path p = orig; + const auto ptr1 = p.c_str(); + const auto ptr2 = p.begin()->c_str(); + p = std::move(p); + __gnu_test::compare_paths(p, orig); + p = p; + __gnu_test::compare_paths(p, orig); + VERIFY( ptr1 == p.c_str() ); + VERIFY( ptr2 == p.begin()->c_str() ); +} + int main() { test01(); test02(); + test03(); } diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h index 36b53ac23f7..9700f0b7761 100644 --- a/libstdc++-v3/testsuite/util/testsuite_hooks.h +++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h @@ -46,18 +46,25 @@ #include <bits/c++config.h> #include <bits/functexcept.h> #include <ctime> +#include <stdio.h> #ifdef _GLIBCXX_HAVE_SYS_STAT_H #include <sys/stat.h> #endif +#ifdef stderr +# define _VERIFY_PRINT(S, F, L, P, C) __builtin_fprintf(stderr, S, F, L, P, C) +#else +# define _VERIFY_PRINT(S, F, L, P, C) __builtin_printf(S, F, L, P, C) +#endif + #define VERIFY(fn) \ do \ { \ if (! (fn)) \ { \ - __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", \ - __FILE__, __LINE__, __PRETTY_FUNCTION__, #fn); \ + _VERIFY_PRINT("%s:%d: %s: Assertion '%s' failed.\n", \ + __FILE__, __LINE__, __PRETTY_FUNCTION__, #fn); \ __builtin_abort(); \ } \ } while (false) |