diff options
Diffstat (limited to 'libstdc++-v3/testsuite')
4 files changed, 141 insertions, 3 deletions
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2011/42319.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2011/42319.cc index cd576ca..350a548 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++2011/42319.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++2011/42319.cc @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-std=gnu++11" } +// { dg-add-options no_pch } // Copyright (C) 2009-2025 Free Software Foundation, Inc. // @@ -19,4 +19,4 @@ // <http://www.gnu.org/licenses/>. // libstdc++/42319 -#include <bits/char_traits.h> +#include <ios> diff --git a/libstdc++-v3/testsuite/20_util/tuple/requirements/empty_trivial.cc b/libstdc++-v3/testsuite/20_util/tuple/requirements/empty_trivial.cc new file mode 100644 index 0000000..ee18bb3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/requirements/empty_trivial.cc @@ -0,0 +1,17 @@ +// { dg-do compile { target c++11 } } + +#include <tuple> +#include <type_traits> + +// Check that tuple<> has the expected trivial properties +static_assert(std::is_trivially_copyable<std::tuple<>>::value, + "tuple<> should be trivially copyable"); +static_assert(std::is_trivially_copy_constructible<std::tuple<>>::value, + "tuple<> should be trivially copy constructible"); +static_assert(std::is_trivially_move_constructible<std::tuple<>>::value, + "tuple<> should be trivially move constructible"); +static_assert(std::is_trivially_copy_assignable<std::tuple<>>::value, + "tuple<> should be trivially copy assignable"); +static_assert(std::is_trivially_move_assignable<std::tuple<>>::value, + "tuple<> should be trivially move assignable"); + diff --git a/libstdc++-v3/testsuite/23_containers/tuple/cons/119721.cc b/libstdc++-v3/testsuite/23_containers/tuple/cons/119721.cc new file mode 100644 index 0000000..1d15238 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/tuple/cons/119721.cc @@ -0,0 +1,121 @@ +// { dg-do run { target c++23 } } + +// Test for PR libstdc++/119721: tuple<> construction/assignment with array<T, 0> + +#include <tuple> +#include <array> +#include <memory> +#include <testsuite_hooks.h> + +constexpr void +test01() +{ + std::array<int, 0> a{}; + + // Constructor from array<int, 0> + std::tuple<> t1(a); + std::tuple<> t2(std::move(a)); + + // Assignment from array<int, 0> + std::tuple<> t3; + t3 = a; + t3 = std::move(a); + + VERIFY( t1 == a ); + VERIFY( t2 == a ); + VERIFY( t3 == a ); +} + +constexpr void +test02() +{ + // Test with non-comparable element type + struct NonComparable + { + void operator==(const NonComparable&) const = delete; + void operator<=>(const NonComparable&) const = delete; + }; + + std::array<NonComparable, 0> a{}; + + std::tuple<> t1(a); + std::tuple<> t2(std::move(a)); + + std::tuple<> t3; + t3 = a; + t3 = std::move(a); + + VERIFY( t1 == a ); +} + +constexpr void +test03() +{ + // Test assignment return type (non-const assignment) + std::tuple<> t, u; + std::tuple<>& r1 = (t = u); + VERIFY( &r1 == &t ); + + std::tuple<>& r2 = (t = {}); + VERIFY( &r2 == &t ); + + std::array<int, 0> a{}; + std::tuple<>& r3 = (t = a); + VERIFY( &r3 == &t ); +} + +constexpr void +test04() +{ + std::array<int, 0> a{}; + const std::tuple<> t1; + + // Const assignment from array + std::tuple<> t2; + const std::tuple<>& r1 = (t1 = t2); + VERIFY( &r1 == &t1 ); + const std::tuple<>& r2 = (t1 = std::move(t2)); + VERIFY( &r2 == &t1 ); + + const std::tuple<>& r3 = (t1 = {}); + VERIFY( &r3 == &t1 ); + + // Const assignment from array + const std::tuple<>& r4 = (t1 = a); + VERIFY( &r4 == &t1 ); + const std::tuple<>& r5 = (t1 = std::move(a)); + VERIFY( &r5 == &t1 ); +} + +void +test05() +{ + std::array<int, 0> a{}; + std::allocator<int> alloc; + + // Allocator constructor from array + std::tuple<> t1(std::allocator_arg, alloc, a); + std::tuple<> t2(std::allocator_arg, alloc, std::move(a)); + + VERIFY( t1 == a ); + VERIFY( t2 == a ); +} + +int main() +{ + auto test_all = [] { + test01(); + test02(); + test03(); + test04(); + return true; + }; + + test_all(); + static_assert( test_all() ); + + // allocator test is not constexpr + test05(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/30_threads/thread/swap/1.cc b/libstdc++-v3/testsuite/30_threads/thread/swap/1.cc index 9616b15..b1fde09 100644 --- a/libstdc++-v3/testsuite/30_threads/thread/swap/1.cc +++ b/libstdc++-v3/testsuite/30_threads/thread/swap/1.cc @@ -23,7 +23,7 @@ #include <thread> #include <system_error> -#include <bits/move.h> // std::move +#include <utility> // std::move #include <testsuite_hooks.h> void f() { } |
