From 6012fe9abb1f01b1b5b4ca908464804c21ff8602 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 19 Jan 2019 10:05:35 +0000 Subject: Vendor import of libc++ trunk r351319 (just before the release_80 branch point): https://llvm.org/svn/llvm-project/libcxx/trunk@351319 --- .../random_shuffle.cxx1z.pass.cpp | 4 +- .../random_shuffle.depr_in_cxx14.fail.cpp | 50 ++++ test/libcxx/algorithms/debug_less.pass.cpp | 51 ++++ test/libcxx/algorithms/half_positive.pass.cpp | 56 +++++ .../associative/non_const_comparator.fail.cpp | 3 +- .../sequences/deque/pop_back_empty.pass.cpp | 26 +++ .../containers/sequences/vector/db_back.pass.cpp | 3 +- .../containers/sequences/vector/db_cback.pass.cpp | 3 +- .../containers/sequences/vector/db_cfront.pass.cpp | 3 +- .../containers/sequences/vector/db_cindex.pass.cpp | 3 +- .../containers/sequences/vector/db_front.pass.cpp | 3 +- .../containers/sequences/vector/db_index.pass.cpp | 3 +- .../sequences/vector/db_iterators_2.pass.cpp | 3 +- .../sequences/vector/db_iterators_3.pass.cpp | 3 +- .../sequences/vector/db_iterators_4.pass.cpp | 3 +- .../sequences/vector/db_iterators_5.pass.cpp | 3 +- .../sequences/vector/db_iterators_6.pass.cpp | 3 +- .../sequences/vector/db_iterators_7.pass.cpp | 3 +- .../sequences/vector/db_iterators_8.pass.cpp | 3 +- .../sequences/vector/pop_back_empty.pass.cpp | 26 +++ .../vector.cons/construct_iter_iter.pass.cpp | 54 +++++ .../vector.cons/construct_iter_iter_alloc.pass.cpp | 57 +++++ .../containers/unord/non_const_comparator.fail.cpp | 8 +- .../unord/unord.map/db_iterators_7.pass.cpp | 3 +- .../unord/unord.map/db_iterators_8.pass.cpp | 3 +- .../unord/unord.map/db_local_iterators_7.pass.cpp | 3 +- .../unord/unord.map/db_local_iterators_8.pass.cpp | 3 +- .../auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp | 39 ++++ .../adaptors.depr_in_cxx11.fail.cpp | 59 +++++ .../depr.adaptors.cxx1z.pass.cpp | 22 +- test/libcxx/diagnostics/enable_nodiscard.fail.cpp | 33 +++ .../enable_nodiscard_disable_after_cxx17.fail.cpp | 33 +++ ...enable_nodiscard_disable_nodiscard_ext.fail.cpp | 31 +++ test/libcxx/diagnostics/nodiscard.fail.cpp | 24 -- test/libcxx/diagnostics/nodiscard.pass.cpp | 15 +- .../diagnostics/nodiscard_aftercxx17.fail.cpp | 23 ++ .../diagnostics/nodiscard_aftercxx17.pass.cpp | 23 ++ .../diagnostics/nodiscard_extensions.fail.cpp | 35 +++ .../diagnostics/nodiscard_extensions.pass.cpp | 29 +++ test/libcxx/double_include.sh.cpp | 2 +- .../dynarray/dynarray.cons/alloc.pass.cpp | 83 ------- .../dynarray/dynarray.cons/default.pass.cpp | 102 -------- .../default_throws_bad_alloc.pass.cpp | 35 --- .../dynarray/dynarray.data/default.pass.cpp | 69 ------ .../dynarray/dynarray.mutate/default.pass.cpp | 47 ---- .../dynarray/dynarray.overview/at.pass.cpp | 94 -------- .../dynarray/dynarray.overview/begin_end.pass.cpp | 110 --------- .../dynarray/dynarray.overview/capacity.pass.cpp | 56 ----- .../dynarray/dynarray.overview/front_back.pass.cpp | 74 ------ .../dynarray/dynarray.overview/indexing.pass.cpp | 76 ------ .../dynarray/dynarray.traits/default.pass.cpp | 28 --- .../dynarray/dynarray.zero/default.pass.cpp | 48 ---- .../containers/sequences/dynarray/lit.local.cfg | 3 - .../sequences/dynarray/nothing_to_do.pass.cpp | 12 - .../diagnostics/syserr/use_header_warning.fail.cpp | 18 ++ .../diagnostics/syserr/version.pass.cpp | 21 ++ .../construct_piecewise_pair.pass.cpp | 7 - .../db_deallocate.pass.cpp | 2 +- .../numeric.ops/use_header_warning.fail.cpp | 18 ++ .../numerics/numeric.ops/version.pass.cpp | 21 ++ .../string.view/use_header_warning.fail.cpp | 18 ++ .../strings/string.view/version.pass.cpp | 21 ++ .../utilities/any/use_header_warning.fail.cpp | 18 ++ .../experimental/utilities/any/version.pass.cpp | 21 ++ .../utilities/optional/use_header_warning.fail.cpp | 18 ++ .../utilities/optional/version.pass.cpp | 21 ++ .../utilities/ratio/use_header_warning.fail.cpp | 18 ++ .../experimental/utilities/ratio/version.pass.cpp | 21 ++ .../utilities/time/use_header_warning.fail.cpp | 18 ++ .../experimental/utilities/time/version.pass.cpp | 21 ++ .../utilities/tuple/use_header_warning.fail.cpp | 18 ++ .../experimental/utilities/tuple/version.pass.cpp | 21 ++ .../file.streams/fstreams/fstream.close.pass.cpp | 35 +++ .../language.support/cxa_deleted_virtual.pass.cpp | 1 + .../language.support/has_c11_features.pass.cpp | 3 + .../new.badlength/bad_array_length.pass.cpp | 37 --- .../support.dynamic/libcpp_deallocate.sh.cpp | 260 +++++++++++++++++++++ .../support.dynamic/new_faligned_allocation.sh.cpp | 8 +- test/libcxx/libcpp_alignof.pass.cpp | 37 +++ .../memory/aligned_allocation_macro.pass.cpp | 31 +++ test/libcxx/min_max_macros.sh.cpp | 4 +- .../string.modifiers/erase_iter_db1.pass.cpp | 3 +- .../string.modifiers/erase_iter_db2.pass.cpp | 3 +- .../string.modifiers/erase_iter_iter_db1.pass.cpp | 3 +- .../string.modifiers/erase_iter_iter_db2.pass.cpp | 3 +- .../string.modifiers/erase_iter_iter_db3.pass.cpp | 3 +- .../string.modifiers/erase_iter_iter_db4.pass.cpp | 3 +- .../resize_default_initialized.pass.cpp | 63 +++++ .../thread.mutex/thread_safety_lock_guard.pass.cpp | 10 + .../thread.thread.this/sleep_for.pass.cpp | 1 - test/libcxx/type_traits/is_floating_point.pass.cpp | 24 -- .../optional.object/triviality.abi.pass.cpp | 98 ++++++++ .../utility/pairs/pairs.pair/U_V.pass.cpp | 54 +++++ .../pairs.pair/const_first_const_second.pass.cpp | 62 +++++ .../pairs/pairs.pair/const_pair_U_V.pass.cpp | 64 +++++ .../utility/pairs/pairs.pair/default.pass.cpp | 36 +++ .../pairs.pair/non_trivial_copy_move_ABI.pass.cpp | 15 +- .../pairs/pairs.pair/pair.tuple_element.fail.cpp | 2 +- .../utility/pairs/pairs.pair/piecewise.pass.cpp | 38 +++ .../utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp | 63 +++++ .../pairs.pair/trivial_copy_move_ABI.pass.cpp | 15 +- .../variant.helper/variant_alternative.fail.cpp | 2 +- .../variant/variant.variant/variant_size.pass.cpp | 3 +- 103 files changed, 1914 insertions(+), 982 deletions(-) create mode 100644 test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.fail.cpp create mode 100644 test/libcxx/algorithms/half_positive.pass.cpp create mode 100644 test/libcxx/containers/sequences/deque/pop_back_empty.pass.cpp create mode 100644 test/libcxx/containers/sequences/vector/pop_back_empty.pass.cpp create mode 100644 test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp create mode 100644 test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp create mode 100644 test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp create mode 100644 test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.fail.cpp create mode 100644 test/libcxx/diagnostics/enable_nodiscard.fail.cpp create mode 100644 test/libcxx/diagnostics/enable_nodiscard_disable_after_cxx17.fail.cpp create mode 100644 test/libcxx/diagnostics/enable_nodiscard_disable_nodiscard_ext.fail.cpp delete mode 100644 test/libcxx/diagnostics/nodiscard.fail.cpp create mode 100644 test/libcxx/diagnostics/nodiscard_aftercxx17.fail.cpp create mode 100644 test/libcxx/diagnostics/nodiscard_aftercxx17.pass.cpp create mode 100644 test/libcxx/diagnostics/nodiscard_extensions.fail.cpp create mode 100644 test/libcxx/diagnostics/nodiscard_extensions.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/lit.local.cfg delete mode 100644 test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp create mode 100644 test/libcxx/experimental/diagnostics/syserr/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/diagnostics/syserr/version.pass.cpp create mode 100644 test/libcxx/experimental/numerics/numeric.ops/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/numerics/numeric.ops/version.pass.cpp create mode 100644 test/libcxx/experimental/strings/string.view/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/strings/string.view/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/any/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/any/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/optional/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/optional/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/ratio/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/ratio/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/time/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/time/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/tuple/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/tuple/version.pass.cpp create mode 100644 test/libcxx/input.output/file.streams/fstreams/fstream.close.pass.cpp delete mode 100644 test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp create mode 100644 test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp create mode 100644 test/libcxx/libcpp_alignof.pass.cpp create mode 100644 test/libcxx/memory/aligned_allocation_macro.pass.cpp create mode 100644 test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp delete mode 100644 test/libcxx/type_traits/is_floating_point.pass.cpp create mode 100644 test/libcxx/utilities/optional/optional.object/triviality.abi.pass.cpp create mode 100644 test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp create mode 100644 test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp create mode 100644 test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp create mode 100644 test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp create mode 100644 test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp create mode 100644 test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp (limited to 'test/libcxx') diff --git a/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp b/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp index 28a9281b49c2a..58ce689981cac 100644 --- a/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp +++ b/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// +// // template // void @@ -23,6 +23,8 @@ // However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE // is defined before including , then random_shuffle will be restored. +// REQUIRES: verify-support + // MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE diff --git a/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.fail.cpp b/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.fail.cpp new file mode 100644 index 0000000000000..608f4f86c31f9 --- /dev/null +++ b/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.fail.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last); +// +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last, +// RandomNumberGenerator& rand); + +// UNSUPPORTED: clang-4.0 +// UNSUPPORTED: c++98, c++03, c++11 +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE + +#include +#include + +#include "test_macros.h" + +struct gen +{ + std::ptrdiff_t operator()(std::ptrdiff_t n) + { + return n-1; + } +}; + + +int main() +{ + int v[1] = {1}; + std::random_shuffle(&v[0], &v[1]); // expected-error{{'random_shuffle' is deprecated}} + gen r; + std::random_shuffle(&v[0], &v[1], r); // expected-error{{'random_shuffle' is deprecated}} +} diff --git a/test/libcxx/algorithms/debug_less.pass.cpp b/test/libcxx/algorithms/debug_less.pass.cpp index e030f64e5dd9d..302c5a8376c8d 100644 --- a/test/libcxx/algorithms/debug_less.pass.cpp +++ b/test/libcxx/algorithms/debug_less.pass.cpp @@ -161,7 +161,58 @@ void test_failing() { } } +template +struct Tag { + explicit Tag(int v) : value(v) {} + int value; +}; + +template +struct FooImp { + explicit FooImp(int x) : x_(x) {} + int x_; +}; + +template +inline bool operator<(FooImp const& x, Tag<0> y) { + return x.x_ < y.value; +} + +template +inline bool operator<(Tag<0>, FooImp const&) { + static_assert(sizeof(FooImp) != sizeof(FooImp), "should not be instantiated"); +} + +template +inline bool operator<(Tag<1> x, FooImp const& y) { + return x.value < y.x_; +} + +template +inline bool operator<(FooImp const&, Tag<1>) { + static_assert(sizeof(FooImp) != sizeof(FooImp), "should not be instantiated"); +} + +typedef FooImp<> Foo; + +// Test that we don't attempt to call the comparator with the arguments reversed +// for upper_bound and lower_bound since the comparator or type is not required +// to support it, nor does it require the range to have a strict weak ordering. +// See llvm.org/PR39458 +void test_upper_and_lower_bound() { + Foo table[] = {Foo(1), Foo(2), Foo(3), Foo(4), Foo(5)}; + { + Foo* iter = std::lower_bound(std::begin(table), std::end(table), Tag<0>(3)); + assert(iter == (table + 2)); + } + { + Foo* iter = std::upper_bound(std::begin(table), std::end(table), Tag<1>(3)); + assert(iter == (table + 3)); + } +} + int main() { test_passing(); test_failing(); + test_upper_and_lower_bound(); } diff --git a/test/libcxx/algorithms/half_positive.pass.cpp b/test/libcxx/algorithms/half_positive.pass.cpp new file mode 100644 index 0000000000000..7dcfc2c92c946 --- /dev/null +++ b/test/libcxx/algorithms/half_positive.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// __half_positive divides an integer number by 2 as unsigned number for known types. +// It can be an important optimization for lower bound, for example. + +#include +#include +#include +#include + +#include "test_macros.h" +#include "user_defined_integral.hpp" + +namespace { + +template +TEST_CONSTEXPR bool test(IntType max_v = IntType(std::numeric_limits::max())) { + return std::__half_positive(max_v) == max_v / 2; +} + +} // namespace + +int main() +{ + { + assert(test()); + assert(test()); + assert(test()); + assert((test, int>())); + assert(test()); +#if !defined(_LIBCPP_HAS_NO_INT128) + assert(test<__int128_t>()); +#endif // !defined(_LIBCPP_HAS_NO_INT128) + } + +#if TEST_STD_VER >= 11 + { + static_assert(test(), ""); + static_assert(test(), ""); + static_assert(test(), ""); + static_assert(test(), ""); +#if !defined(_LIBCPP_HAS_NO_INT128) + static_assert(test<__int128_t>(), ""); +#endif // !defined(_LIBCPP_HAS_NO_INT128) + } +#endif // TEST_STD_VER >= 11 +} diff --git a/test/libcxx/containers/associative/non_const_comparator.fail.cpp b/test/libcxx/containers/associative/non_const_comparator.fail.cpp index ea0d9ac09328e..ddd7960893997 100644 --- a/test/libcxx/containers/associative/non_const_comparator.fail.cpp +++ b/test/libcxx/containers/associative/non_const_comparator.fail.cpp @@ -27,7 +27,8 @@ int main() { static_assert(!std::__invokable::value, ""); static_assert(std::__invokable::value, ""); - // expected-warning@__tree:* 4 {{the specified comparator type does not provide a const call operator}} + // expected-warning@set:* 2 {{the specified comparator type does not provide a const call operator}} + // expected-warning@map:* 2 {{the specified comparator type does not provide a const call operator}} { using C = std::set; C s; diff --git a/test/libcxx/containers/sequences/deque/pop_back_empty.pass.cpp b/test/libcxx/containers/sequences/deque/pop_back_empty.pass.cpp new file mode 100644 index 0000000000000..e4f5d0b01197b --- /dev/null +++ b/test/libcxx/containers/sequences/deque/pop_back_empty.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// pop_back() more than the number of elements in a deque + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include + + +int main() { + std::deque q; + q.push_back(0); + q.pop_back(); + q.pop_back(); + std::exit(1); +} diff --git a/test/libcxx/containers/sequences/vector/db_back.pass.cpp b/test/libcxx/containers/sequences/vector/db_back.pass.cpp index 05f3d07712eb5..d66ffeb67af04 100644 --- a/test/libcxx/containers/sequences/vector/db_back.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_back.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -34,7 +35,7 @@ int main() assert(c.back() == 0); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_cback.pass.cpp b/test/libcxx/containers/sequences/vector/db_cback.pass.cpp index 5eb1a353e8b04..9ad0fb92969f2 100644 --- a/test/libcxx/containers/sequences/vector/db_cback.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_cback.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -32,7 +33,7 @@ int main() assert(c.back() == 0); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp b/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp index 5e54da1d444e9..58f57a500dd9a 100644 --- a/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -32,7 +33,7 @@ int main() assert(c.front() == 0); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp b/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp index 133aa56528245..9a54b6cb98420 100644 --- a/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -33,7 +34,7 @@ int main() assert(c[1] == 0); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_front.pass.cpp b/test/libcxx/containers/sequences/vector/db_front.pass.cpp index 388058fb31593..0acb7df0c4d9e 100644 --- a/test/libcxx/containers/sequences/vector/db_front.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_front.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -34,7 +35,7 @@ int main() assert(c.front() == 0); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_index.pass.cpp b/test/libcxx/containers/sequences/vector/db_index.pass.cpp index 1daf076da67c1..75ae095f2b1c1 100644 --- a/test/libcxx/containers/sequences/vector/db_index.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_index.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -34,7 +35,7 @@ int main() assert(c[0] == 0); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp index 2d43843067b75..d5e8c86109b7c 100644 --- a/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -33,7 +34,7 @@ int main() bool b = c1.begin() < c2.begin(); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp index 051d66c33394d..96a75204a7bd6 100644 --- a/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -33,7 +34,7 @@ int main() int i = c1.begin() - c2.begin(); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp index 4c2aa628de143..311a517cfc015 100644 --- a/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -34,7 +35,7 @@ int main() assert(i[1] == 0); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp index 1b1090499c276..6df3fd459c187 100644 --- a/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -36,7 +37,7 @@ int main() i += 2; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp index 424bc939b1366..0785dd96444ca 100644 --- a/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -35,7 +36,7 @@ int main() --i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp index 72cdb10cbc855..11ba9f864b0c9 100644 --- a/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -35,7 +36,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp index 7b898533197c6..0434ad5f15098 100644 --- a/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp +++ b/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -33,7 +34,7 @@ int main() T j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; diff --git a/test/libcxx/containers/sequences/vector/pop_back_empty.pass.cpp b/test/libcxx/containers/sequences/vector/pop_back_empty.pass.cpp new file mode 100644 index 0000000000000..388dfa4e1a833 --- /dev/null +++ b/test/libcxx/containers/sequences/vector/pop_back_empty.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// pop_back() more than the number of elements in a vector + +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) + +#include +#include + + +int main() { + std::vector v; + v.push_back(0); + v.pop_back(); + v.pop_back(); + std::exit(1); +} diff --git a/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp new file mode 100644 index 0000000000000..998d0b74eddff --- /dev/null +++ b/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template vector(InputIter first, InputIter last); + +#include +#include + +#include "min_allocator.h" + +void test_ctor_under_alloc() { + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + typedef std::vector > C; + typedef C::allocator_type Alloc; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3); + assert(Alloc::construct_called); + } + } + { + typedef std::vector > C; + typedef C::allocator_type Alloc; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3); + assert(Alloc::construct_called); + } + } +} + +int main() { + test_ctor_under_alloc(); +} diff --git a/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp new file mode 100644 index 0000000000000..c4950fbe637d6 --- /dev/null +++ b/test/libcxx/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template vector(InputIter first, InputIter last, +// const allocator_type& a); + +#include +#include + +#include "min_allocator.h" + +void test_ctor_under_alloc() { + int arr1[] = {42}; + int arr2[] = {1, 101, 42}; + { + typedef std::vector > C; + typedef C::allocator_type Alloc; + Alloc a; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1, a); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3, a); + assert(Alloc::construct_called); + } + } + { + typedef std::vector > C; + typedef C::allocator_type Alloc; + Alloc a; + { + Alloc::construct_called = false; + C v(arr1, arr1 + 1, a); + assert(Alloc::construct_called); + } + { + Alloc::construct_called = false; + C v(arr2, arr2 + 3, a); + assert(Alloc::construct_called); + } + } +} + +int main() { + test_ctor_under_alloc(); +} diff --git a/test/libcxx/containers/unord/non_const_comparator.fail.cpp b/test/libcxx/containers/unord/non_const_comparator.fail.cpp index 8adc67589ef88..f428ab9aca6db 100644 --- a/test/libcxx/containers/unord/non_const_comparator.fail.cpp +++ b/test/libcxx/containers/unord/non_const_comparator.fail.cpp @@ -11,7 +11,7 @@ // REQUIRES: diagnose-if-support, verify-support // Test that libc++ generates a warning diagnostic when the container is -// provided a non-const callable comparator. +// provided a non-const callable comparator or a non-const hasher. #include #include @@ -34,8 +34,10 @@ int main() { static_assert(!std::__invokable::value, ""); static_assert(std::__invokable::value, ""); - // expected-warning@__hash_table:* 4 {{the specified comparator type does not provide a const call operator}} - // expected-warning@__hash_table:* 4 {{the specified hash functor does not provide a const call operator}} + // expected-warning@unordered_set:* 2 {{the specified comparator type does not provide a const call operator}} + // expected-warning@unordered_map:* 2 {{the specified comparator type does not provide a const call operator}} + // expected-warning@unordered_set:* 2 {{the specified hash functor does not provide a const call operator}} + // expected-warning@unordered_map:* 2 {{the specified hash functor does not provide a const call operator}} { using C = std::unordered_set; diff --git a/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp b/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp index b8db0a35ffc3e..664cb7e86b959 100644 --- a/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp +++ b/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp @@ -22,6 +22,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -36,7 +37,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; diff --git a/test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp b/test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp index c923dd77862e6..621d7f343e085 100644 --- a/test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp +++ b/test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp @@ -22,6 +22,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -34,7 +35,7 @@ int main() C::value_type j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; diff --git a/test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp b/test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp index fa1886bfff189..19794e04769d9 100644 --- a/test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp +++ b/test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp @@ -22,6 +22,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -34,7 +35,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; diff --git a/test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp b/test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp index 4b071cad7b473..1567caf9be9ef 100644 --- a/test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp +++ b/test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp @@ -22,6 +22,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -33,7 +34,7 @@ int main() C::value_type j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; diff --git a/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp b/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp new file mode 100644 index 0000000000000..3ad9ae8d6f683 --- /dev/null +++ b/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// +// template +// class auto_ptr; +// +// class auto_ptr; +// +// template +// class auto_ptr_ref; +// +// Deprecated in C++11 + +// UNSUPPORTED: clang-4.0 +// UNSUPPORTED: c++98, c++03 +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR + +#include +#include "test_macros.h" + +int main() +{ + typedef std::auto_ptr AP; // expected-error{{'auto_ptr' is deprecated}} + typedef std::auto_ptr APV; // expected-error{{'auto_ptr' is deprecated}} + typedef std::auto_ptr_ref APR; // expected-error{{'auto_ptr_ref' is deprecated}} +} diff --git a/test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.fail.cpp b/test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.fail.cpp new file mode 100644 index 0000000000000..88c1e21d6bb61 --- /dev/null +++ b/test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.fail.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// UNSUPPORTED: clang-4.0 +// UNSUPPORTED: c++98, c++03 +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS + +#include +#include +#include "test_macros.h" + +int identity(int v) { return v; } +int sum(int a, int b) { return a + b; } + +struct Foo { + int const_zero() const { return 0; } + int const_identity(int v) const { return v; } + int zero() { return 0; } + int identity(int v) { return v; } +}; + +int main() +{ + typedef std::pointer_to_unary_function PUF; // expected-error{{'pointer_to_unary_function' is deprecated}} + typedef std::pointer_to_binary_function PBF; // expected-error{{'pointer_to_binary_function' is deprecated}} + std::ptr_fun(identity); // expected-error{{'ptr_fun' is deprecated}} + std::ptr_fun(sum); // expected-error{{'ptr_fun' is deprecated}} + + typedef std::mem_fun_t MFT0; // expected-error{{'mem_fun_t' is deprecated}} + typedef std::mem_fun1_t MFT1; // expected-error{{'mem_fun1_t' is deprecated}} + typedef std::const_mem_fun_t CMFT0; // expected-error{{'const_mem_fun_t' is deprecated}} + typedef std::const_mem_fun1_t CMFT1; // expected-error{{'const_mem_fun1_t' is deprecated}} + std::mem_fun(&Foo::zero); // expected-error{{'mem_fun' is deprecated}} + std::mem_fun(&Foo::identity); // expected-error{{'mem_fun' is deprecated}} + std::mem_fun(&Foo::const_zero); // expected-error{{'mem_fun' is deprecated}} + std::mem_fun(&Foo::const_identity); // expected-error{{'mem_fun' is deprecated}} + + typedef std::mem_fun_ref_t MFR0; // expected-error{{'mem_fun_ref_t' is deprecated}} + typedef std::mem_fun1_ref_t MFR1; // expected-error{{'mem_fun1_ref_t' is deprecated}} + typedef std::const_mem_fun_ref_t CMFR0; // expected-error{{'const_mem_fun_ref_t' is deprecated}} + typedef std::const_mem_fun1_ref_t CMFR1; // expected-error{{'const_mem_fun1_ref_t' is deprecated}} + std::mem_fun_ref(&Foo::zero); // expected-error{{'mem_fun_ref' is deprecated}} + std::mem_fun_ref(&Foo::identity); // expected-error{{'mem_fun_ref' is deprecated}} + std::mem_fun_ref(&Foo::const_zero); // expected-error{{'mem_fun_ref' is deprecated}} + std::mem_fun_ref(&Foo::const_identity); // expected-error{{'mem_fun_ref' is deprecated}} +} diff --git a/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp b/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp index 1847dac2ed00d..beb5608006122 100644 --- a/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp +++ b/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp @@ -24,15 +24,25 @@ int identity(int v) { return v; } int sum(int a, int b) { return a + b; } struct Foo { - int zero() const { return 0; } - int identity(int v) const { return v; } - int sum(int a, int b) const { return a + b; } + int zero() { return 0; } + int zero_const() const { return 1; } + + int identity(int v) const { return v; } + int sum(int a, int b) const { return a + b; } }; int main() { typedef std::pointer_to_unary_function PUF; typedef std::pointer_to_binary_function PBF; + + static_assert( + (std::is_same(identity)))>::value), + ""); + static_assert( + (std::is_same(sum)))>::value), + ""); + assert((std::ptr_fun(identity)(4) == 4)); assert((std::ptr_fun(sum)(4, 5) == 9)); @@ -43,6 +53,12 @@ int main() typedef std::mem_fun_ref_t MFR; typedef std::const_mem_fun_ref_t CMFR; + static_assert( + (std::is_same::value), ""); + static_assert((std::is_same::value), + ""); + assert((std::mem_fun_ref(&Foo::zero)(f) == 0)); assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5)); } diff --git a/test/libcxx/diagnostics/enable_nodiscard.fail.cpp b/test/libcxx/diagnostics/enable_nodiscard.fail.cpp new file mode 100644 index 0000000000000..e1ef17672ccb9 --- /dev/null +++ b/test/libcxx/diagnostics/enable_nodiscard.fail.cpp @@ -0,0 +1,33 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test that _LIBCPP_NODISCARD_EXT and _LIBCPP_NODISCARD_AFTER_CXX17 are defined +// to the appropriate warning-generating attribute when _LIBCPP_ENABLE_NODISCARD +// is explicitly provided. + +// UNSUPPORTED: c++98, c++03 + +// GCC 7 is the first version to introduce [[nodiscard]] +// UNSUPPORTED: gcc-4.9, gcc-5, gcc-6 + +// MODULES_DEFINES: _LIBCPP_ENABLE_NODISCARD +#define _LIBCPP_ENABLE_NODISCARD + +#include <__config> + +_LIBCPP_NODISCARD_EXT int foo() { return 42; } +_LIBCPP_NODISCARD_AFTER_CXX17 int bar() { return 42; } + +int main() { + foo(); // expected-error-re {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} + bar(); // expected-error-re {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} + (void)foo(); // OK. void casts disable the diagnostic. + (void)bar(); +} diff --git a/test/libcxx/diagnostics/enable_nodiscard_disable_after_cxx17.fail.cpp b/test/libcxx/diagnostics/enable_nodiscard_disable_after_cxx17.fail.cpp new file mode 100644 index 0000000000000..2c7d899ff5a04 --- /dev/null +++ b/test/libcxx/diagnostics/enable_nodiscard_disable_after_cxx17.fail.cpp @@ -0,0 +1,33 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// GCC 7 is the first version to introduce [[nodiscard]] +// UNSUPPORTED: gcc-4.9, gcc-5, gcc-6 + +// Test that _LIBCPP_DISABLE_NODISCARD_EXT only disables _LIBCPP_NODISCARD_EXT +// and not _LIBCPP_NODISCARD_AFTER_CXX17. + +// MODULES_DEFINES: _LIBCPP_ENABLE_NODISCARD +// MODULES_DEFINES: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17 +#define _LIBCPP_ENABLE_NODISCARD +#define _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17 +#include <__config> + + +_LIBCPP_NODISCARD_EXT int foo() { return 42; } +_LIBCPP_NODISCARD_AFTER_CXX17 int bar() { return 42; } + +int main() { + foo(); // expected-error-re {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} + bar(); // OK. + (void)foo(); // OK. +} diff --git a/test/libcxx/diagnostics/enable_nodiscard_disable_nodiscard_ext.fail.cpp b/test/libcxx/diagnostics/enable_nodiscard_disable_nodiscard_ext.fail.cpp new file mode 100644 index 0000000000000..c7d080d8425ce --- /dev/null +++ b/test/libcxx/diagnostics/enable_nodiscard_disable_nodiscard_ext.fail.cpp @@ -0,0 +1,31 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// GCC 7 is the first version to introduce [[nodiscard]] +// UNSUPPORTED: gcc-4.9, gcc-5, gcc-6 + + +// MODULES_DEFINES: _LIBCPP_ENABLE_NODISCARD +// MODULES_DEFINES: _LIBCPP_DISABLE_NODISCARD_EXT +#define _LIBCPP_ENABLE_NODISCARD +#define _LIBCPP_DISABLE_NODISCARD_EXT +#include <__config> + + +_LIBCPP_NODISCARD_EXT int foo() { return 42; } +_LIBCPP_NODISCARD_AFTER_CXX17 int bar() { return 42; } + +int main() { + bar(); // expected-error-re {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} + foo(); // OK. + (void)bar(); // OK. +} diff --git a/test/libcxx/diagnostics/nodiscard.fail.cpp b/test/libcxx/diagnostics/nodiscard.fail.cpp deleted file mode 100644 index 903a24a72805a..0000000000000 --- a/test/libcxx/diagnostics/nodiscard.fail.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works -// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]] - -// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 -// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8 - -#include <__config> - -_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; } - -int main () -{ - foo(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}} -} diff --git a/test/libcxx/diagnostics/nodiscard.pass.cpp b/test/libcxx/diagnostics/nodiscard.pass.cpp index d308248cff228..de920d459ed66 100644 --- a/test/libcxx/diagnostics/nodiscard.pass.cpp +++ b/test/libcxx/diagnostics/nodiscard.pass.cpp @@ -8,18 +8,13 @@ // //===----------------------------------------------------------------------===// -// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works -// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]] +// Test that _LIBCPP_NODISCARD_EXT is not defined to [[nodiscard]] unless +// explicitly enabled by _LIBCPP_ENABLE_NODISCARD -// UNSUPPORTED: c++98, c++03, c++11, c++14 - -// MODULES_DEFINES: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17 -#define _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17 #include <__config> -_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; } +_LIBCPP_NODISCARD_EXT int foo() { return 42; } -int main () -{ - foo(); // no error here! +int main() { + foo(); // OK. } diff --git a/test/libcxx/diagnostics/nodiscard_aftercxx17.fail.cpp b/test/libcxx/diagnostics/nodiscard_aftercxx17.fail.cpp new file mode 100644 index 0000000000000..47e560feb962f --- /dev/null +++ b/test/libcxx/diagnostics/nodiscard_aftercxx17.fail.cpp @@ -0,0 +1,23 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works +// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]] + +// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 + +#include <__config> + +_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; } + +int main () +{ + foo(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}} +} diff --git a/test/libcxx/diagnostics/nodiscard_aftercxx17.pass.cpp b/test/libcxx/diagnostics/nodiscard_aftercxx17.pass.cpp new file mode 100644 index 0000000000000..4db8181723e14 --- /dev/null +++ b/test/libcxx/diagnostics/nodiscard_aftercxx17.pass.cpp @@ -0,0 +1,23 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test that _LIBCPP_NODISCARD_AFTER_CXX17 is disabled whenever +// _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17 is defined by the user. + +// MODULES_DEFINES: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17 +#define _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17 +#include <__config> + +_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; } + +int main () +{ + foo(); // no error here! +} diff --git a/test/libcxx/diagnostics/nodiscard_extensions.fail.cpp b/test/libcxx/diagnostics/nodiscard_extensions.fail.cpp new file mode 100644 index 0000000000000..d1e0a8af5c8a6 --- /dev/null +++ b/test/libcxx/diagnostics/nodiscard_extensions.fail.cpp @@ -0,0 +1,35 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// GCC versions prior to 7.0 don't provide the required [[nodiscard]] attribute. +// UNSUPPORTED: gcc-4, gcc-5, gcc-6 + +// Test that entities declared [[nodiscard]] as at extension by libc++, are +// only actually declared such when _LIBCPP_ENABLE_NODISCARD is specified. + +// All entities to which libc++ applies [[nodiscard]] as an extension should +// be tested here and in nodiscard_extensions.pass.cpp. They should also +// be listed in `UsingLibcxx.rst` in the documentation for the extension. + +// MODULES_DEFINES: _LIBCPP_ENABLE_NODISCARD +#define _LIBCPP_ENABLE_NODISCARD + +#include + +#include "test_macros.h" + +int main() { + { + // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} + std::get_temporary_buffer(1); + } +} diff --git a/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp b/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp new file mode 100644 index 0000000000000..9a09a43bae1cd --- /dev/null +++ b/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp @@ -0,0 +1,29 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test that entities declared [[nodiscard]] as at extension by libc++, are +// only actually declared such when _LIBCPP_ENABLE_NODISCARD is specified. + +// This test intentionally leaks memory, so it is unsupported under ASAN. +// UNSUPPORTED: asan + +// All entities to which libc++ applies [[nodiscard]] as an extension should +// be tested here and in nodiscard_extensions.fail.cpp. They should also +// be listed in `UsingLibcxx.rst` in the documentation for the extension. + +#include + +#include "test_macros.h" + +int main() { + { + std::get_temporary_buffer(1); // intentional memory leak. + } +} diff --git a/test/libcxx/double_include.sh.cpp b/test/libcxx/double_include.sh.cpp index 8d08db4fd1055..5a0f2ba72dc00 100644 --- a/test/libcxx/double_include.sh.cpp +++ b/test/libcxx/double_include.sh.cpp @@ -27,6 +27,7 @@ #ifndef _LIBCPP_HAS_NO_THREADS #include #endif +#include #include #include #include @@ -144,7 +145,6 @@ #include #endif #include -#include #include #include #include diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp deleted file mode 100644 index c6a83cc61bdcb..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp +++ /dev/null @@ -1,83 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// dynarray.cons - -// template -// dynarray(size_type c, const Alloc& alloc); -// template -// dynarray(size_type c, const T& v, const Alloc& alloc); -// template -// dynarray(const dynarray& d, const Alloc& alloc); -// template -// dynarray(initializer_list, const Alloc& alloc); - -// ~dynarray(); - - -#include <__config> - -#include -#include - -#include -#include -#include -#include "test_allocator.h" - -using std::experimental::dynarray; - -template -void check_allocator ( const dynarray &dyn, const Allocator &alloc ) { - for ( int i = 0; i < dyn.size (); ++i ) - assert ( dyn[i].get_allocator() == alloc ); -} - -template -void test ( const std::initializer_list &vals, const Allocator &alloc ) { - typedef dynarray dynA; - - dynA d1 ( vals, alloc ); - assert ( d1.size () == vals.size() ); - assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ())); - check_allocator ( d1, alloc ); - } - - -template -void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) { - typedef dynarray dynA; - - dynA d1 ( 4, alloc1 ); - assert ( d1.size () == 4 ); - assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } )); - check_allocator ( d1, alloc1 ); - - dynA d2 ( 7, val, alloc1 ); - assert ( d2.size () == 7 ); - assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } )); - check_allocator ( d2, alloc1 ); - - dynA d3 ( d2, alloc2 ); - assert ( d3.size () == 7 ); - assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } )); - check_allocator ( d3, alloc2 ); - } - -int main() -{ -// This test is waiting on the resolution of LWG issue #2235 -// typedef test_allocator Alloc; -// typedef std::basic_string, Alloc> nstr; -// -// test ( nstr("fourteen"), Alloc(3), Alloc(4) ); -// test ( { nstr("1"), nstr("1"), nstr("2"), nstr("3"), nstr("5"), nstr("8")}, Alloc(6)); -} - diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp deleted file mode 100644 index db7484d468dad..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: availability=macosx10.12 -// XFAIL: availability=macosx10.11 -// XFAIL: availability=macosx10.10 -// XFAIL: availability=macosx10.9 -// XFAIL: availability=macosx10.8 -// XFAIL: availability=macosx10.7 - -// dynarray.cons - -// explicit dynarray(size_type c); -// dynarray(size_type c, const T& v); -// dynarray(initializer_list); -// dynarray(const dynarray& d); - -// ~dynarray(); - - -#include -#include - -#include -#include -#include -#include -#include - -#include "test_macros.h" - - -using std::experimental::dynarray; - -template -void testInitList( const std::initializer_list &vals ) { - typedef dynarray dynA; - - dynA d1 ( vals ); - assert ( d1.size () == vals.size() ); - assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ())); - } - - -template -void test ( const T &val, bool DefaultValueIsIndeterminate = false) { - typedef dynarray dynA; - - dynA d1 ( 4 ); - assert ( d1.size () == 4 ); - if (!DefaultValueIsIndeterminate) { - assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } )); - } - - dynA d2 ( 7, val ); - assert ( d2.size () == 7 ); - assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } )); - - dynA d3 ( d2 ); - assert ( d3.size () == 7 ); - assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } )); - } - -#ifndef TEST_HAS_NO_EXCEPTIONS -void test_bad_length () { - try { dynarray ( std::numeric_limits::max() / sizeof ( int ) + 1 ); } - catch ( std::bad_array_length & ) { return ; } - catch (...) { assert(false); } - assert ( false ); -} -#endif - - -int main() -{ - test ( 14, /* DefaultValueIsIndeterminate */ true ); // ints don't get default initialized - test ( 0, true); - test ( 14.0, true ); - test> ( std::complex ( 14, 0 )); - test ( "fourteen" ); - - testInitList( { 1, 1, 2, 3, 5, 8 } ); - testInitList( { 1., 1., 2., 3., 5., 8. } ); - testInitList( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), - std::string("5"), std::string("8")} ); - -// Make sure we don't pick up the Allocator version here - dynarray d1 ( 20, 3 ); - assert ( d1.size() == 20 ); - assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } )); - -#ifndef TEST_HAS_NO_EXCEPTIONS - test_bad_length (); -#endif -} diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp deleted file mode 100644 index 4009841355f9f..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: libcpp-no-exceptions -// XFAIL: availability -// dynarray.cons - -// explicit dynarray(size_type c); - -// UNSUPPORTED: c++98, c++03, c++11 - -// The sanitizers replace new/delete with versions that do not throw bad_alloc. -// UNSUPPORTED: sanitizer-new-delete - - -#include -#include -#include -#include - - -using std::experimental::dynarray; - -int main() { - try { dynarray((std::numeric_limits::max() / sizeof(int)) - 1); } - catch (std::bad_alloc &) { return 0; } - catch (...) { assert(false); } - assert(false); -} diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp deleted file mode 100644 index 5c745e0d1eaf1..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp +++ /dev/null @@ -1,69 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: availability - -// dynarray.data - -// T* data() noexcept; -// const T* data() const noexcept; - - -#include -#include - -#include -#include -#include - -using std::experimental::dynarray; - -template -void dyn_test_const(const dynarray &dyn, bool CheckEquals = true) { - const T *data = dyn.data (); - assert ( data != NULL ); - if (CheckEquals) { - assert ( std::equal ( dyn.begin(), dyn.end(), data )); - } -} - -template -void dyn_test( dynarray &dyn, bool CheckEquals = true) { - T *data = dyn.data (); - assert ( data != NULL ); - if (CheckEquals) { - assert ( std::equal ( dyn.begin(), dyn.end(), data )); - } -} - - - -template -void test(const T &val, bool DefaultValueIsIndeterminate = false) { - typedef dynarray dynA; - - const bool CheckDefaultValues = !DefaultValueIsIndeterminate; - - dynA d1(4); - dyn_test(d1, CheckDefaultValues); - dyn_test_const(d1, CheckDefaultValues); - - dynA d2 (7, val); - dyn_test ( d2 ); - dyn_test_const ( d2 ); -} - -int main() -{ - test(14, /* DefaultValueIsIndeterminate */ true); - test(14.0, true); - test> ( std::complex ( 14, 0 )); - test ( "fourteen" ); -} diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp deleted file mode 100644 index 1ed51538f6faa..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: availability - -// dynarray.data - -// void fill(const T& v); -// const T* data() const noexcept; - - -#include <__config> - -#include -#include - -#include -#include -#include - -using std::experimental::dynarray; - -template -void test ( const T &val ) { - typedef dynarray dynA; - - dynA d1 ( 4 ); - d1.fill ( val ); - assert ( std::all_of ( d1.begin (), d1.end (), - [&val]( const T &item ){ return item == val; } )); - } - -int main() -{ - test ( 14 ); - test ( 14.0 ); - test> ( std::complex ( 14, 0 )); - test ( "fourteen" ); -} - diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp deleted file mode 100644 index 473313f39fc47..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp +++ /dev/null @@ -1,94 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// UNSUPPORTED: libcpp-no-exceptions -// XFAIL: availability - -// dynarray.overview - -// const_reference at(size_type n) const; -// reference at(size_type n); - -#include <__config> - -#include -#include - -#include -#include -#include - -using std::experimental::dynarray; - -template -void dyn_at_fail ( dynarray &dyn, size_t sz ) { - try { dyn.at (sz); } - catch (const std::out_of_range &) { return; } - assert ( false ); - } - -template -void dyn_at_fail_const ( const dynarray &dyn, size_t sz ) { - try { dyn.at (sz); } - catch (const std::out_of_range &) { return; } - assert ( false ); - } - - -template -void dyn_test_const ( const dynarray &dyn, const std::initializer_list &vals ) { - const T *data = dyn.data (); - auto it = vals.begin (); - for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { - assert ( data + i == &dyn.at(i)); - assert ( *it == dyn.at(i)); - } - - dyn_at_fail_const ( dyn, dyn.size ()); - dyn_at_fail_const ( dyn, 2*dyn.size ()); - dyn_at_fail_const ( dyn, size_t (-1)); - } - -template -void dyn_test ( dynarray &dyn, const std::initializer_list &vals ) { - T *data = dyn.data (); - auto it = vals.begin (); - for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { - assert ( data + i == &dyn.at(i)); - assert ( *it == dyn.at(i)); - } - - dyn_at_fail ( dyn, dyn.size ()); - dyn_at_fail ( dyn, 2*dyn.size ()); - dyn_at_fail ( dyn, size_t (-1)); - } - - -template -void test ( std::initializer_list vals ) { - typedef dynarray dynA; - - dynA d1 ( vals ); - dyn_test ( d1, vals ); - dyn_test_const ( d1, vals ); - } - -int main() -{ - test ( { 1, 1, 2, 3, 5, 8 } ); - test ( { 1., 1., 2., 3., 5., 8. } ); - test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), - std::string("5"), std::string("8")} ); - - test ( {} ); - test> ( {} ); - test ( {} ); -} - diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp deleted file mode 100644 index f0aa1e3ff6911..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp +++ /dev/null @@ -1,110 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: availability - -// dynarray.overview - - -// iterator begin() noexcept; -// const_iterator begin() const noexcept; -// const_iterator cbegin() const noexcept; -// iterator end() noexcept; -// const_iterator end() const noexcept; -// const_iterator cend() const noexcept; -// -// reverse_iterator rbegin() noexcept; -// const_reverse_iterator rbegin() const noexcept; -// const_reverse_iterator crbegin() const noexcept; -// reverse_iterator rend() noexcept; -// const_reverse_iterator rend() const noexcept; -// const_reverse_iterator crend() const noexcept; - - -#include <__config> - -#include -#include -#include - -#include -#include -#include - -using std::experimental::dynarray; - -template -void dyn_test_const ( const dynarray &dyn ) { - const T *data = dyn.data (); - assert ( data == &*dyn.begin ()); - assert ( data == &*dyn.cbegin ()); - - assert ( data + dyn.size() - 1 == &*dyn.rbegin ()); - assert ( data + dyn.size() - 1 == &*dyn.crbegin ()); - - std::ptrdiff_t ds = static_cast(dyn.size()); - assert (ds == std::distance ( dyn.begin(), dyn.end())); - assert (ds == std::distance ( dyn.cbegin(), dyn.cend())); - assert (ds == std::distance ( dyn.rbegin(), dyn.rend())); - assert (ds == std::distance ( dyn.crbegin(), dyn.crend())); - - assert ( dyn.begin () == dyn.cbegin ()); - assert ( &*dyn.begin () == &*dyn.cbegin ()); - assert ( dyn.rbegin () == dyn.crbegin ()); - assert ( &*dyn.rbegin () == &*dyn.crbegin ()); - assert ( dyn.end () == dyn.cend ()); - assert ( dyn.rend () == dyn.crend ()); - } - -template -void dyn_test ( dynarray &dyn ) { - T *data = dyn.data (); - assert ( data == &*dyn.begin ()); - assert ( data == &*dyn.cbegin ()); - - assert ( data + dyn.size() - 1 == &*dyn.rbegin ()); - assert ( data + dyn.size() - 1 == &*dyn.crbegin ()); - - std::ptrdiff_t ds = static_cast(dyn.size()); - assert (ds == std::distance ( dyn.begin(), dyn.end())); - assert (ds == std::distance ( dyn.cbegin(), dyn.cend())); - assert (ds == std::distance ( dyn.rbegin(), dyn.rend())); - assert (ds == std::distance ( dyn.crbegin(), dyn.crend())); - - assert ( dyn.begin () == dyn.cbegin ()); - assert ( &*dyn.begin () == &*dyn.cbegin ()); - assert ( dyn.rbegin () == dyn.crbegin ()); - assert ( &*dyn.rbegin () == &*dyn.crbegin ()); - assert ( dyn.end () == dyn.cend ()); - assert ( dyn.rend () == dyn.crend ()); - } - - -template -void test ( const T &val ) { - typedef dynarray dynA; - - dynA d1 ( 4 ); - dyn_test ( d1 ); - dyn_test_const ( d1 ); - - dynA d2 ( 7, val ); - dyn_test ( d2 ); - dyn_test_const ( d2 ); - } - -int main() -{ - test ( 14 ); - test ( 14.0 ); - test> ( std::complex ( 14, 0 )); - test ( "fourteen" ); -} - diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp deleted file mode 100644 index a5484296fa21b..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: availability - -// dynarray.overview - -// size_type size() const noexcept; -// size_type max_size() const noexcept; -// bool empty() const noexcept; - -#include <__config> - -#include -#include - -#include -#include -#include - -using std::experimental::dynarray; - -template -void dyn_test ( const dynarray &dyn, size_t sz ) { - assert ( dyn.size () == sz ); - assert ( dyn.max_size () == sz ); - assert ( dyn.empty () == ( sz == 0 )); - } - -template -void test ( std::initializer_list vals ) { - typedef dynarray dynA; - - dynA d1 ( vals ); - dyn_test ( d1, vals.size ()); - } - -int main() -{ - test ( { 1, 1, 2, 3, 5, 8 } ); - test ( { 1., 1., 2., 3., 5., 8. } ); - test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), - std::string("5"), std::string("8")} ); - - test ( {} ); - test> ( {} ); - test ( {} ); -} - diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp deleted file mode 100644 index 0ba27cf925f77..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp +++ /dev/null @@ -1,74 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: availability - -// dynarray.overview - -// reference front(); -// const_reference front() const; -// reference back(); -// const_reference back() const; - - -#include -#include - -#include -#include -#include - -using std::experimental::dynarray; - -template -void dyn_test_const ( const dynarray &dyn, bool CheckValues = true ) { - const T *data = dyn.data (); - assert(data == &dyn.front()); - assert((data + dyn.size() - 1) == &dyn.back()); - if (CheckValues) { - assert ( *data == dyn.front ()); - assert ( *(data + dyn.size() - 1 ) == dyn.back ()); - } -} - -template -void dyn_test ( dynarray &dyn, bool CheckValues = true ) { - T *data = dyn.data (); - assert(data == &dyn.front()); - assert((data + dyn.size() - 1) == &dyn.back()); - if (CheckValues) { - assert ( *data == dyn.front ()); - assert ( *(data + dyn.size() - 1 ) == dyn.back ()); - } -} - - -template -void test ( const T &val, bool DefaultValueIsIndeterminate = false) { - typedef dynarray dynA; - - const bool CheckDefaultValues = ! DefaultValueIsIndeterminate; - - dynA d1 ( 4 ); - dyn_test ( d1, CheckDefaultValues ); - dyn_test_const ( d1, CheckDefaultValues ); - - dynA d2 ( 7, val ); - dyn_test ( d2 ); - dyn_test_const ( d2 ); -} - -int main() -{ - test ( 14, /* DefaultValueIsIndeterminate */ true); - test ( 14.0, true ); - test> ( std::complex ( 14, 0 )); - test ( "fourteen" ); -} diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp deleted file mode 100644 index 4306d1e9c1b67..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp +++ /dev/null @@ -1,76 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 - -// XFAIL: availability=macosx10.12 -// XFAIL: availability=macosx10.11 -// XFAIL: availability=macosx10.10 -// XFAIL: availability=macosx10.9 -// XFAIL: availability=macosx10.8 -// XFAIL: availability=macosx10.7 - -// dynarray.overview - -// const_reference at(size_type n) const; -// reference at(size_type n); - -#include <__config> - -#include -#include - -#include -#include -#include - -using std::experimental::dynarray; - -template -void dyn_test_const ( const dynarray &dyn, const std::initializer_list &vals ) { - const T *data = dyn.data (); - auto it = vals.begin (); - for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { - assert ( data + i == &dyn[i]); - assert ( *it == dyn[i]); - } - } - -template -void dyn_test ( dynarray &dyn, const std::initializer_list &vals ) { - T *data = dyn.data (); - auto it = vals.begin (); - for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { - assert ( data + i == &dyn[i]); - assert ( *it == dyn[i]); - } - } - - -template -void test ( std::initializer_list vals ) { - typedef dynarray dynA; - - dynA d1 ( vals ); - dyn_test ( d1, vals ); - dyn_test_const ( d1, vals ); - } - -int main() -{ - test ( { 1, 1, 2, 3, 5, 8 } ); - test ( { 1., 1., 2., 3., 5., 8. } ); - test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), - std::string("5"), std::string("8")} ); - - test ( {} ); - test> ( {} ); - test ( {} ); -} - diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp deleted file mode 100644 index 48da6d885773f..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// dynarray.data - -// template -// struct uses_allocator, Alloc> : true_type { }; - - -#include <__config> - -#include -#include "test_allocator.h" - -using std::experimental::dynarray; - -int main() -{ - static_assert ( std::uses_allocator, test_allocator>::value, "" ); -} - diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp deleted file mode 100644 index ab49600350600..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: availability -// dynarray.zero - -// dynarray shall provide support for the special case of construction with a size of zero. -// In the case that the size is zero, begin() == end() == unique value. -// The return value of data() is unspecified. -// The effect of calling front() or back() for a zero-sized dynarray is undefined. - - - -#include <__config> - -#include -#include - -#include -#include -#include - -using std::experimental::dynarray; - -template -void test ( ) { - typedef dynarray dynA; - - dynA d1 ( 0 ); - assert ( d1.size() == 0 ); - assert ( d1.begin() == d1.end ()); - } - -int main() -{ - test (); - test (); - test> (); - test (); -} - diff --git a/test/libcxx/experimental/containers/sequences/dynarray/lit.local.cfg b/test/libcxx/experimental/containers/sequences/dynarray/lit.local.cfg deleted file mode 100644 index 93553b5130e39..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/lit.local.cfg +++ /dev/null @@ -1,3 +0,0 @@ -if ('availability' in config.available_features - and not 'libcpp-no-exceptions' in config.available_features): - config.unsupported = True diff --git a/test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b643a..0000000000000 --- a/test/libcxx/experimental/containers/sequences/dynarray/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/test/libcxx/experimental/diagnostics/syserr/use_header_warning.fail.cpp b/test/libcxx/experimental/diagnostics/syserr/use_header_warning.fail.cpp new file mode 100644 index 0000000000000..074a9c58c6140 --- /dev/null +++ b/test/libcxx/experimental/diagnostics/syserr/use_header_warning.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support + +// + +#include + +// expected-error@experimental/system_error:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/diagnostics/syserr/version.pass.cpp b/test/libcxx/experimental/diagnostics/syserr/version.pass.cpp new file mode 100644 index 0000000000000..c4fb9593a9ee2 --- /dev/null +++ b/test/libcxx/experimental/diagnostics/syserr/version.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp index 40bacbcbad590..b2150fcd2716b 100644 --- a/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp +++ b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp @@ -106,14 +106,10 @@ struct CountCopiesAllocV2 { int main() { - using PMR = ex::memory_resource*; - using PMA = ex::polymorphic_allocator; - { using T = CountCopies; using U = CountCopiesAllocV1; using P = std::pair; - using TH = TestHarness

; std::tuple t1; std::tuple t2; @@ -129,7 +125,6 @@ int main() using T = CountCopiesAllocV1; using U = CountCopiesAllocV2; using P = std::pair; - using TH = TestHarness

; std::tuple t1; std::tuple t2; @@ -146,7 +141,6 @@ int main() using T = CountCopiesAllocV2; using U = CountCopiesAllocV1; using P = std::pair; - using TH = TestHarness

; std::tuple t1; std::tuple t2; @@ -163,7 +157,6 @@ int main() using T = CountCopiesAllocV2; using U = CountCopies; using P = std::pair; - using TH = TestHarness

; std::tuple t1; std::tuple t2; diff --git a/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp b/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp index ccb9b710e5dcd..ffcedf0bf5319 100644 --- a/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp +++ b/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp @@ -30,7 +30,7 @@ namespace ex = std::experimental::pmr; int main() { using Alloc = NullAllocator; - using R = ex::resource_adaptor; + AllocController P; ex::resource_adaptor r(Alloc{P}); ex::memory_resource & m1 = r; diff --git a/test/libcxx/experimental/numerics/numeric.ops/use_header_warning.fail.cpp b/test/libcxx/experimental/numerics/numeric.ops/use_header_warning.fail.cpp new file mode 100644 index 0000000000000..32fd0527d482b --- /dev/null +++ b/test/libcxx/experimental/numerics/numeric.ops/use_header_warning.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support + +// + +#include + +// expected-error@experimental/numeric:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/numerics/numeric.ops/version.pass.cpp b/test/libcxx/experimental/numerics/numeric.ops/version.pass.cpp new file mode 100644 index 0000000000000..37ac584a7cd4d --- /dev/null +++ b/test/libcxx/experimental/numerics/numeric.ops/version.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/strings/string.view/use_header_warning.fail.cpp b/test/libcxx/experimental/strings/string.view/use_header_warning.fail.cpp new file mode 100644 index 0000000000000..64f73742099bb --- /dev/null +++ b/test/libcxx/experimental/strings/string.view/use_header_warning.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support + +// + +#include + +// expected-error@experimental/string_view:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/strings/string.view/version.pass.cpp b/test/libcxx/experimental/strings/string.view/version.pass.cpp new file mode 100644 index 0000000000000..417982e36696f --- /dev/null +++ b/test/libcxx/experimental/strings/string.view/version.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/any/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/any/use_header_warning.fail.cpp new file mode 100644 index 0000000000000..0bcda7056b4d0 --- /dev/null +++ b/test/libcxx/experimental/utilities/any/use_header_warning.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support + +// + +#include + +// expected-error@experimental/any:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/any/version.pass.cpp b/test/libcxx/experimental/utilities/any/version.pass.cpp new file mode 100644 index 0000000000000..bc37d8b4dbfa5 --- /dev/null +++ b/test/libcxx/experimental/utilities/any/version.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/optional/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/optional/use_header_warning.fail.cpp new file mode 100644 index 0000000000000..1711d2f03742a --- /dev/null +++ b/test/libcxx/experimental/utilities/optional/use_header_warning.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support + +// + +#include + +// expected-error@experimental/optional:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/optional/version.pass.cpp b/test/libcxx/experimental/utilities/optional/version.pass.cpp new file mode 100644 index 0000000000000..ef011bbe4506e --- /dev/null +++ b/test/libcxx/experimental/utilities/optional/version.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/ratio/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/ratio/use_header_warning.fail.cpp new file mode 100644 index 0000000000000..d9a01337a9367 --- /dev/null +++ b/test/libcxx/experimental/utilities/ratio/use_header_warning.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support + +// + +#include + +// expected-error@experimental/ratio:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/ratio/version.pass.cpp b/test/libcxx/experimental/utilities/ratio/version.pass.cpp new file mode 100644 index 0000000000000..8ebb347a44ba2 --- /dev/null +++ b/test/libcxx/experimental/utilities/ratio/version.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/time/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/time/use_header_warning.fail.cpp new file mode 100644 index 0000000000000..9f3d679fc2ab5 --- /dev/null +++ b/test/libcxx/experimental/utilities/time/use_header_warning.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support + +// + +#include + +// expected-error@experimental/chrono:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/time/version.pass.cpp b/test/libcxx/experimental/utilities/time/version.pass.cpp new file mode 100644 index 0000000000000..5544a3f0e14b5 --- /dev/null +++ b/test/libcxx/experimental/utilities/time/version.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/tuple/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/tuple/use_header_warning.fail.cpp new file mode 100644 index 0000000000000..520e9fbb42f09 --- /dev/null +++ b/test/libcxx/experimental/utilities/tuple/use_header_warning.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: verify-support + +// + +#include + +// expected-error@experimental/tuple:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/tuple/version.pass.cpp b/test/libcxx/experimental/utilities/tuple/version.pass.cpp new file mode 100644 index 0000000000000..c7c9e572856d1 --- /dev/null +++ b/test/libcxx/experimental/utilities/tuple/version.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/input.output/file.streams/fstreams/fstream.close.pass.cpp b/test/libcxx/input.output/file.streams/fstreams/fstream.close.pass.cpp new file mode 100644 index 0000000000000..0f8defcbd97d8 --- /dev/null +++ b/test/libcxx/input.output/file.streams/fstreams/fstream.close.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// + +// template > +// class basic_fstream + +// close(); + +// Inspired by PR#38052 - std::fstream still good after closing and updating content + +#include +#include +#include "platform_support.h" + +int main() +{ + std::string temp = get_temp_file_name(); + + std::fstream ofs(temp, std::ios::out | std::ios::trunc); + ofs << "Hello, World!\n"; + assert( ofs.good()); + ofs.close(); + assert( ofs.good()); + ofs << "Hello, World!\n"; + assert(!ofs.good()); + + std::remove(temp.c_str()); +} diff --git a/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp b/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp index ddef5d00e5da4..7e3130cf9fa98 100644 --- a/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp +++ b/test/libcxx/language.support/cxa_deleted_virtual.pass.cpp @@ -12,6 +12,7 @@ // Test exporting the symbol: "__cxa_deleted_virtual" in macosx // But don't expect the symbol to be exported in previous versions. // +// XFAIL: with_system_cxx_lib=macosx10.14 // XFAIL: with_system_cxx_lib=macosx10.13 // XFAIL: with_system_cxx_lib=macosx10.12 // XFAIL: with_system_cxx_lib=macosx10.11 diff --git a/test/libcxx/language.support/has_c11_features.pass.cpp b/test/libcxx/language.support/has_c11_features.pass.cpp index cdccc00e21b4f..4edec534eb98b 100644 --- a/test/libcxx/language.support/has_c11_features.pass.cpp +++ b/test/libcxx/language.support/has_c11_features.pass.cpp @@ -14,6 +14,9 @@ // _LIBCPP_HAS_C11_FEATURES - which is defined in <__config> // They should always be the same +#include <__config> +#include "test_macros.h" + #ifdef TEST_HAS_C11_FEATURES # ifndef _LIBCPP_HAS_C11_FEATURES # error "TEST_HAS_C11_FEATURES is defined, but _LIBCPP_HAS_C11_FEATURES is not" diff --git a/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp b/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp deleted file mode 100644 index c37d234331484..0000000000000 --- a/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: availability - -// XFAIL: availability=macosx10.12 -// XFAIL: availability=macosx10.11 -// XFAIL: availability=macosx10.10 -// XFAIL: availability=macosx10.9 -// XFAIL: availability=macosx10.7 -// XFAIL: availability=macosx10.8 - -// test bad_array_length - -#include -#include -#include - -int main() -{ - static_assert((std::is_base_of::value), - "std::is_base_of::value"); - static_assert(std::is_polymorphic::value, - "std::is_polymorphic::value"); - std::bad_array_length b; - std::bad_array_length b2 = b; - b2 = b; - const char* w = b2.what(); - assert(w); -} diff --git a/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp b/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp new file mode 100644 index 0000000000000..f62e82d8e594a --- /dev/null +++ b/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp @@ -0,0 +1,260 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test libc++'s implementation of align_val_t, and the relevant new/delete +// overloads in all dialects when -faligned-allocation is present. + +// Libc++ defers to the underlying MSVC library to provide the new/delete +// definitions, which does not yet provide aligned allocation +// XFAIL: LIBCXX-WINDOWS-FIXME + +// The dylibs shipped before macosx10.14 do not contain the aligned allocation +// functions, so trying to force using those with -faligned-allocation results +// in a link error. +// XFAIL: with_system_cxx_lib=macosx10.13 +// XFAIL: with_system_cxx_lib=macosx10.12 +// XFAIL: with_system_cxx_lib=macosx10.11 +// XFAIL: with_system_cxx_lib=macosx10.10 +// XFAIL: with_system_cxx_lib=macosx10.9 +// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: with_system_cxx_lib=macosx10.7 + +// The test will fail on deployment targets that do not support sized deallocation. +// XFAIL: availability=macosx10.11 +// XFAIL: availability=macosx10.10 +// XFAIL: availability=macosx10.9 +// XFAIL: availability=macosx10.8 +// XFAIL: availability=macosx10.7 + +// XFAIL: sanitizer-new-delete, ubsan + +// GCC doesn't support the aligned-allocation flags. +// XFAIL: gcc + +// RUN: %build -faligned-allocation -fsized-deallocation +// RUN: %run +// RUN: %build -faligned-allocation -fno-sized-deallocation -DNO_SIZE +// RUN: %run +// RUN: %build -fno-aligned-allocation -fsized-deallocation -DNO_ALIGN +// RUN: %run +// RUN: %build -fno-aligned-allocation -fno-sized-deallocation -DNO_ALIGN -DNO_SIZE +// RUN: %run + +#include +#include +#include +#include + +#include "test_macros.h" + +struct alloc_stats { + alloc_stats() { reset(); } + + int aligned_sized_called; + int aligned_called; + int sized_called; + int plain_called; + int last_size; + int last_align; + + void reset() { + aligned_sized_called = aligned_called = sized_called = plain_called = 0; + last_align = last_size = -1; + } + + bool expect_plain() const { + assert(aligned_sized_called == 0); + assert(aligned_called == 0); + assert(sized_called == 0); + assert(last_size == -1); + assert(last_align == -1); + return plain_called == 1; + } + + bool expect_size(int n) const { + assert(plain_called == 0); + assert(aligned_sized_called == 0); + assert(aligned_called == 0); + assert(last_size == n); + assert(last_align == -1); + return sized_called == 1; + } + + bool expect_align(int a) const { + assert(plain_called == 0); + assert(aligned_sized_called == 0); + assert(sized_called == 0); + assert(last_size == -1); + assert(last_align == a); + return aligned_called == 1; + } + + bool expect_size_align(int n, int a) const { + assert(plain_called == 0); + assert(sized_called == 0); + assert(aligned_called == 0); + assert(last_size == n); + assert(last_align == a); + return aligned_sized_called == 1; + } +}; +alloc_stats stats; + +void operator delete(void* p)TEST_NOEXCEPT { + ::free(p); + stats.plain_called++; + stats.last_size = stats.last_align = -1; +} + +#ifndef NO_SIZE +void operator delete(void* p, size_t n)TEST_NOEXCEPT { + ::free(p); + stats.sized_called++; + stats.last_size = n; + stats.last_align = -1; +} +#endif + +#ifndef NO_ALIGN +void operator delete(void* p, std::align_val_t a)TEST_NOEXCEPT { + ::free(p); + stats.aligned_called++; + stats.last_align = static_cast(a); + stats.last_size = -1; +} + +void operator delete(void* p, size_t n, std::align_val_t a)TEST_NOEXCEPT { + ::free(p); + stats.aligned_sized_called++; + stats.last_align = static_cast(a); + stats.last_size = n; +} +#endif + +void test_libcpp_dealloc() { + void* p = nullptr; + size_t over_align_val = TEST_ALIGNOF(std::max_align_t) * 2; + size_t under_align_val = TEST_ALIGNOF(int); + size_t with_size_val = 2; + + { + std::__libcpp_deallocate_unsized(p, under_align_val); + assert(stats.expect_plain()); + } + stats.reset(); + +#if defined(NO_SIZE) && defined(NO_ALIGN) + { + std::__libcpp_deallocate(p, with_size_val, over_align_val); + assert(stats.expect_plain()); + } + stats.reset(); +#elif defined(NO_SIZE) + { + std::__libcpp_deallocate(p, with_size_val, over_align_val); + assert(stats.expect_align(over_align_val)); + } + stats.reset(); +#elif defined(NO_ALIGN) + { + std::__libcpp_deallocate(p, with_size_val, over_align_val); + assert(stats.expect_size(with_size_val)); + } + stats.reset(); +#else + { + std::__libcpp_deallocate(p, with_size_val, over_align_val); + assert(stats.expect_size_align(with_size_val, over_align_val)); + } + stats.reset(); + { + std::__libcpp_deallocate_unsized(p, over_align_val); + assert(stats.expect_align(over_align_val)); + } + stats.reset(); + { + std::__libcpp_deallocate(p, with_size_val, under_align_val); + assert(stats.expect_size(with_size_val)); + } + stats.reset(); +#endif +} + +struct TEST_ALIGNAS(128) AlignedType { + AlignedType() : elem(0) {} + TEST_ALIGNAS(128) char elem; +}; + +void test_allocator_and_new_match() { + stats.reset(); +#if defined(NO_SIZE) && defined(NO_ALIGN) + { + int* x = new int(42); + delete x; + assert(stats.expect_plain()); + } + stats.reset(); + { + AlignedType* a = new AlignedType(); + delete a; + assert(stats.expect_plain()); + } + stats.reset(); +#elif defined(NO_SIZE) + stats.reset(); +#if TEST_STD_VER >= 11 + { + int* x = new int(42); + delete x; + assert(stats.expect_plain()); + } +#endif + stats.reset(); + { + AlignedType* a = new AlignedType(); + delete a; + assert(stats.expect_align(TEST_ALIGNOF(AlignedType))); + } + stats.reset(); +#elif defined(NO_ALIGN) + stats.reset(); + { + int* x = new int(42); + delete x; + assert(stats.expect_size(sizeof(int))); + } + stats.reset(); + { + AlignedType* a = new AlignedType(); + delete a; + assert(stats.expect_size(sizeof(AlignedType))); + } + stats.reset(); +#else + stats.reset(); + { + int* x = new int(42); + delete x; + assert(stats.expect_size(sizeof(int))); + } + stats.reset(); + { + AlignedType* a = new AlignedType(); + delete a; + assert(stats.expect_size_align(sizeof(AlignedType), + TEST_ALIGNOF(AlignedType))); + } + stats.reset(); +#endif +} + +int main() { + test_libcpp_dealloc(); + test_allocator_and_new_match(); +} diff --git a/test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp b/test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp index 388fbebbd7b04..d7b4cca63aa1d 100644 --- a/test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp +++ b/test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// test libc++'s implementation of align_val_t, and the relevent new/delete +// test libc++'s implementation of align_val_t, and the relevant new/delete // overloads in all dialects when -faligned-allocation is present. // Libc++ defers to the underlying MSVC library to provide the new/delete @@ -16,12 +16,16 @@ // REQUIRES: -faligned-allocation +// The dylibs shipped before macosx10.14 do not contain the aligned allocation +// functions, so trying to force using those with -faligned-allocation results +// in a link error. +// XFAIL: with_system_cxx_lib=macosx10.13 // XFAIL: with_system_cxx_lib=macosx10.12 // XFAIL: with_system_cxx_lib=macosx10.11 // XFAIL: with_system_cxx_lib=macosx10.10 // XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 // XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: with_system_cxx_lib=macosx10.7 // RUN: %build -faligned-allocation // RUN: %run diff --git a/test/libcxx/libcpp_alignof.pass.cpp b/test/libcxx/libcpp_alignof.pass.cpp new file mode 100644 index 0000000000000..ba0df807e82dd --- /dev/null +++ b/test/libcxx/libcpp_alignof.pass.cpp @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test that _LIBCPP_ALIGNOF acts the same as the C++11 keyword `alignof`, and +// not as the GNU extension `__alignof`. The former returns the minimal required +// alignment for a type, whereas the latter returns the preferred alignment. +// +// See llvm.org/PR39713 + +#include +#include "test_macros.h" + +template +void test() { + static_assert(_LIBCPP_ALIGNOF(T) == std::alignment_of::value, ""); + static_assert(_LIBCPP_ALIGNOF(T) == TEST_ALIGNOF(T), ""); +#if TEST_STD_VER >= 11 + static_assert(_LIBCPP_ALIGNOF(T) == alignof(T), ""); +#endif +#ifdef TEST_COMPILER_CLANG + static_assert(_LIBCPP_ALIGNOF(T) == _Alignof(T), ""); +#endif +} + +int main() { + test(); + test(); + test(); + test(); +} diff --git a/test/libcxx/memory/aligned_allocation_macro.pass.cpp b/test/libcxx/memory/aligned_allocation_macro.pass.cpp new file mode 100644 index 0000000000000..368076dee3ad8 --- /dev/null +++ b/test/libcxx/memory/aligned_allocation_macro.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// AppleClang <= 10 enables aligned allocation regardless of the deployment +// target, so this test would fail. +// UNSUPPORTED: apple-clang-9, apple-clang-10 + +// XFAIL: availability=macosx10.13 +// XFAIL: availability=macosx10.12 +// XFAIL: availability=macosx10.11 +// XFAIL: availability=macosx10.10 +// XFAIL: availability=macosx10.9 +// XFAIL: availability=macosx10.8 +// XFAIL: availability=macosx10.7 + +#include + + +#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +# error "libc++ should have aligned allocation in C++17 and up when targeting a platform that supports it" +#endif + +int main() { } diff --git a/test/libcxx/min_max_macros.sh.cpp b/test/libcxx/min_max_macros.sh.cpp index 087aa3645a50e..7b9202d952fb7 100644 --- a/test/libcxx/min_max_macros.sh.cpp +++ b/test/libcxx/min_max_macros.sh.cpp @@ -46,6 +46,8 @@ TEST_MACROS(); TEST_MACROS(); #include TEST_MACROS(); +#include +TEST_MACROS(); #include TEST_MACROS(); #include @@ -239,8 +241,6 @@ TEST_MACROS(); TEST_MACROS(); #include TEST_MACROS(); -#include -TEST_MACROS(); #include TEST_MACROS(); #include diff --git a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.cpp index 6c2929d7f1d3a..09a6aa8a6343b 100644 --- a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.cpp +++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -30,7 +31,7 @@ int main() l1.erase(i); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S l1("123"); diff --git a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp index d20fcd4623b7d..1ff02932bd98a 100644 --- a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp +++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -31,7 +32,7 @@ int main() l1.erase(i); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S l1("123"); diff --git a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.cpp index 5015241ad63ea..46fa5bf434dd2 100644 --- a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.cpp +++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -30,7 +31,7 @@ int main() std::string::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S l1("123"); diff --git a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.cpp index 6a23bf88ca5c0..3ccbfad70a6b4 100644 --- a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.cpp +++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -30,7 +31,7 @@ int main() std::string::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S l1("123"); diff --git a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.cpp index a8443818aea5b..e493dfea9e059 100644 --- a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.cpp +++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -30,7 +31,7 @@ int main() std::string::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S l1("123"); diff --git a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp index 0549e816b44c8..918cffe733fd0 100644 --- a/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp +++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -29,7 +30,7 @@ int main() std::string::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin()); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S l1("123"); diff --git a/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp new file mode 100644 index 0000000000000..a3fa585e44ff5 --- /dev/null +++ b/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// __resize_default_init(size_type) + +#include +#include + +#include "test_macros.h" + +void write_c_str(char *buf, int size) { + for (int i=0; i < size; ++i) { + buf[i] = 'a'; + } + buf[size] = '\0'; +} + +void test_buffer_usage() +{ + { + unsigned buff_size = 125; + unsigned used_size = buff_size - 16; + std::string s; + s.__resize_default_init(buff_size); + write_c_str(&s[0], used_size); + assert(s.size() == buff_size); + assert(strlen(s.data()) == used_size); + s.__resize_default_init(used_size); + assert(s.size() == used_size); + assert(s.data()[used_size] == '\0'); + for (unsigned i=0; i < used_size; ++i) { + assert(s[i] == 'a'); + } + } +} + +void test_basic() { + { + std::string s; + s.__resize_default_init(3); + assert(s.size() == 3); + assert(s.data()[3] == '\0'); + for (int i=0; i < 3; ++i) + s[i] = 'a' + i; + s.__resize_default_init(1); + assert(s[0] == 'a'); + assert(s.data()[1] == '\0'); + assert(s.size() == 1); + } +} + +int main() { + test_basic(); + test_buffer_usage(); +} diff --git a/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp b/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp index 6024d9978433a..74a4657196e47 100644 --- a/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp +++ b/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp @@ -21,10 +21,20 @@ #include +#include "test_macros.h" + std::mutex m; int foo __attribute__((guarded_by(m))); +static void scoped() { +#if TEST_STD_VER >= 17 + std::scoped_lock lock(m); + foo++; +#endif +} + int main() { + scoped(); std::lock_guard lock(m); foo++; } diff --git a/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp b/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp index b46c2cdec6cb8..3c0571bf9c223 100644 --- a/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp +++ b/test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp @@ -57,7 +57,6 @@ int main() typedef std::chrono::system_clock Clock; typedef Clock::time_point time_point; - typedef Clock::duration duration; std::chrono::milliseconds ms(500); time_point t0 = Clock::now(); std::this_thread::sleep_for(ms); diff --git a/test/libcxx/type_traits/is_floating_point.pass.cpp b/test/libcxx/type_traits/is_floating_point.pass.cpp deleted file mode 100644 index 98452fad384ba..0000000000000 --- a/test/libcxx/type_traits/is_floating_point.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// -// -// Test that is_floating_point::value is true when T=__fp16 or T=_Float16. - -#include - -int main() { -#ifdef __clang__ - static_assert(std::is_floating_point<__fp16>::value, ""); -#endif -#ifdef __FLT16_MANT_DIG__ - static_assert(std::is_floating_point<_Float16>::value, ""); -#endif - return 0; -} diff --git a/test/libcxx/utilities/optional/optional.object/triviality.abi.pass.cpp b/test/libcxx/utilities/optional/optional.object/triviality.abi.pass.cpp new file mode 100644 index 0000000000000..cdfb027364bed --- /dev/null +++ b/test/libcxx/utilities/optional/optional.object/triviality.abi.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// + +// This test asserts the triviality of special member functions of optional +// whenever T has these special member functions trivial. The goal of this test +// is to make sure that we do not change the triviality of those, since that +// constitues an ABI break (small enough optionals would be passed by registers). +// +// constexpr optional(const optional& rhs); +// constexpr optional(optional&& rhs) noexcept(see below); +// constexpr optional& operator=(const optional& rhs); +// constexpr optional& operator=(optional&& rhs) noexcept(see below); + +#include +#include +#include + +#include "archetypes.hpp" + +template +struct SpecialMemberTest { + using O = std::optional; + + static_assert(std::is_trivially_destructible_v == + std::is_trivially_destructible_v, + "optional is trivially destructible if and only if T is."); + + static_assert(std::is_trivially_copy_constructible_v == + std::is_trivially_copy_constructible_v, + "optional is trivially copy constructible if and only if T is."); + + static_assert(std::is_trivially_move_constructible_v == + std::is_trivially_move_constructible_v || + (!std::is_move_constructible_v && std::is_trivially_copy_constructible_v), + "optional is trivially move constructible if T is trivially move constructible, " + "or if T is trivially copy constructible and is not move constructible."); + + static_assert(std::is_trivially_copy_assignable_v == + (std::is_trivially_destructible_v && + std::is_trivially_copy_constructible_v && + std::is_trivially_copy_assignable_v), + "optional is trivially copy assignable if and only if T is trivially destructible, " + "trivially copy constructible, and trivially copy assignable."); + + static_assert(std::is_trivially_move_assignable_v == + (std::is_trivially_destructible_v && + ((std::is_trivially_move_constructible_v && std::is_trivially_move_assignable_v) || + ((!std::is_move_constructible_v || !std::is_move_assignable_v) && + std::is_trivially_copy_constructible_v && std::is_trivially_copy_assignable_v))), + "optional is trivially move assignable if T is trivially destructible, and either " + "(1) trivially move constructible and trivially move assignable, or " + "(2) not move constructible or not move assignable, and " + "trivially copy constructible and trivially copy assignable."); +}; + +template static void sink(Args&&...) {} + +template +struct DoTestsMetafunction { + DoTestsMetafunction() { sink(SpecialMemberTest{}...); } +}; + +struct TrivialMoveNonTrivialCopy { + TrivialMoveNonTrivialCopy() = default; + TrivialMoveNonTrivialCopy(const TrivialMoveNonTrivialCopy&) {} + TrivialMoveNonTrivialCopy(TrivialMoveNonTrivialCopy&&) = default; + TrivialMoveNonTrivialCopy& operator=(const TrivialMoveNonTrivialCopy&) { return *this; } + TrivialMoveNonTrivialCopy& operator=(TrivialMoveNonTrivialCopy&&) = default; +}; + +struct TrivialCopyNonTrivialMove { + TrivialCopyNonTrivialMove() = default; + TrivialCopyNonTrivialMove(const TrivialCopyNonTrivialMove&) = default; + TrivialCopyNonTrivialMove(TrivialCopyNonTrivialMove&&) {} + TrivialCopyNonTrivialMove& operator=(const TrivialCopyNonTrivialMove&) = default; + TrivialCopyNonTrivialMove& operator=(TrivialCopyNonTrivialMove&&) { return *this; } +}; + +int main() +{ + sink( + ImplicitTypes::ApplyTypes{}, + ExplicitTypes::ApplyTypes{}, + NonLiteralTypes::ApplyTypes{}, + NonTrivialTypes::ApplyTypes{}, + DoTestsMetafunction{} + ); +} diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp new file mode 100644 index 0000000000000..6a3e613e9dcba --- /dev/null +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// template struct pair + +// template pair(U&& x, V&& y); + +#include + + +struct ExplicitT { + constexpr explicit ExplicitT(int x) : value(x) {} + int value; +}; + +struct ImplicitT { + constexpr ImplicitT(int x) : value(x) {} + int value; +}; + +struct ExplicitNothrowT { + explicit ExplicitNothrowT(int x) noexcept : value(x) {} + int value; +}; + +struct ImplicitNothrowT { + ImplicitNothrowT(int x) noexcept : value(x) {} + int value; +}; + +int main() { + { // explicit noexcept test + static_assert(!std::is_nothrow_constructible, int, int>::value, ""); + static_assert(!std::is_nothrow_constructible, int, int>::value, ""); + static_assert(!std::is_nothrow_constructible, int, int>::value, ""); + static_assert( std::is_nothrow_constructible, int, int>::value, ""); + } + { // implicit noexcept test + static_assert(!std::is_nothrow_constructible, int, int>::value, ""); + static_assert(!std::is_nothrow_constructible, int, int>::value, ""); + static_assert(!std::is_nothrow_constructible, int, int>::value, ""); + static_assert( std::is_nothrow_constructible, int, int>::value, ""); + } +} diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp new file mode 100644 index 0000000000000..6a2401223755b --- /dev/null +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// template struct pair + +// pair(const T1& x, const T2& y); + +#include + + +struct ExplicitT { + constexpr explicit ExplicitT(int x) : value(x) {} + constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {} + int value; +}; + +struct ImplicitT { + constexpr ImplicitT(int x) : value(x) {} + constexpr ImplicitT(ImplicitT const& o) : value(o.value) {} + int value; +}; + +struct ExplicitNothrowT { + explicit ExplicitNothrowT(ExplicitNothrowT const&) noexcept {} +}; + +struct ImplicitNothrowT { + ImplicitNothrowT(ImplicitNothrowT const&) noexcept {} +}; + +int main() { + { // explicit noexcept test + static_assert(!std::is_nothrow_constructible, + ExplicitT const&, ExplicitT const&>::value, ""); + static_assert(!std::is_nothrow_constructible, + ExplicitNothrowT const&, ExplicitT const&>::value, ""); + static_assert(!std::is_nothrow_constructible, + ExplicitT const&, ExplicitNothrowT const&>::value, ""); + static_assert( std::is_nothrow_constructible, + ExplicitNothrowT const&, ExplicitNothrowT const&>::value, ""); + } + { // implicit noexcept test + static_assert(!std::is_nothrow_constructible, + ImplicitT const&, ImplicitT const&>::value, ""); + static_assert(!std::is_nothrow_constructible, + ImplicitNothrowT const&, ImplicitT const&>::value, ""); + static_assert(!std::is_nothrow_constructible, + ImplicitT const&, ImplicitNothrowT const&>::value, ""); + static_assert( std::is_nothrow_constructible, + ImplicitNothrowT const&, ImplicitNothrowT const&>::value, ""); + } +} diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp new file mode 100644 index 0000000000000..edb3bbf64afb0 --- /dev/null +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// template struct pair + +// template EXPLICIT constexpr pair(const pair& p); + +#include + + +struct ExplicitT { + constexpr explicit ExplicitT(int x) : value(x) {} + constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {} + int value; +}; + +struct ImplicitT { + constexpr ImplicitT(int x) : value(x) {} + constexpr ImplicitT(ImplicitT const& o) : value(o.value) {} + int value; +}; + +struct ExplicitNothrowT { + explicit ExplicitNothrowT(int x) noexcept : value(x) {} + int value; +}; + +struct ImplicitNothrowT { + ImplicitNothrowT(int x) noexcept : value(x) {} + int value; +}; + +int main() { + { // explicit noexcept test + static_assert(!std::is_nothrow_constructible, + std::pair const&>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::pair const&>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::pair const&>::value, ""); + static_assert( std::is_nothrow_constructible, + std::pair const&>::value, ""); + } + { // implicit noexcept test + static_assert(!std::is_nothrow_constructible, + std::pair const&>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::pair const&>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::pair const&>::value, ""); + static_assert( std::is_nothrow_constructible, + std::pair const&>::value, ""); + } +} diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp new file mode 100644 index 0000000000000..2dbf5511dd160 --- /dev/null +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// template struct pair + +// constexpr pair(); + +#include +#include + + +struct ThrowingDefault { + ThrowingDefault() { } +}; + +struct NonThrowingDefault { + NonThrowingDefault() noexcept { } +}; + +int main() { + + static_assert(!std::is_nothrow_default_constructible>::value, ""); + static_assert(!std::is_nothrow_default_constructible>::value, ""); + static_assert(!std::is_nothrow_default_constructible>::value, ""); + static_assert( std::is_nothrow_default_constructible>::value, ""); +} diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp index 8b5969d5198c0..58ea6ecde9923 100644 --- a/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "test_macros.h" @@ -86,7 +87,7 @@ static_assert(!HasNonTrivialABI::value, ""); #endif -int main() +void test_trivial() { { typedef std::pair P; @@ -150,3 +151,15 @@ int main() } #endif } + +void test_layout() { + typedef std::pair, char> PairT; + static_assert(sizeof(PairT) == 3, ""); + static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), ""); + static_assert(offsetof(PairT, first) == 0, ""); +} + +int main() { + test_trivial(); + test_layout(); +} diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/pair.tuple_element.fail.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/pair.tuple_element.fail.cpp index 2a92240a63d22..8bfeeea5d2a6c 100644 --- a/test/libcxx/utilities/utility/pairs/pairs.pair/pair.tuple_element.fail.cpp +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/pair.tuple_element.fail.cpp @@ -20,6 +20,6 @@ int main() { typedef std::pair P; std::tuple_element<2, P>::type foo; // expected-note {{requested here}} - // expected-error@utility:* {{static_assert failed "Index out of bounds in std::tuple_element>"}} + // expected-error-re@utility:* {{static_assert failed{{( due to requirement '2U[L]{0,2} < 2')?}} "Index out of bounds in std::tuple_element>"}} } } diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp new file mode 100644 index 0000000000000..81dad3bc2ffa1 --- /dev/null +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// template struct pair + +// template +// pair(piecewise_construct_t, tuple first_args, +// tuple second_args); + +#include +#include +#include + +#include "archetypes.hpp" + + +int main() { + using NonThrowingConvert = NonThrowingTypes::ConvertingType; + using ThrowingConvert = NonTrivialTypes::ConvertingType; + static_assert(!std::is_nothrow_constructible, + std::piecewise_construct_t, std::tuple, std::tuple>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::piecewise_construct_t, std::tuple, std::tuple>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::piecewise_construct_t, std::tuple, std::tuple>::value, ""); + static_assert( std::is_nothrow_constructible, + std::piecewise_construct_t, std::tuple, std::tuple>::value, ""); +} diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp new file mode 100644 index 0000000000000..5d8d36262f17c --- /dev/null +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// template struct pair + +// template pair(pair&& p); + +#include +#include + + +struct ExplicitT { + constexpr explicit ExplicitT(int x) : value(x) {} + int value; +}; + +struct ImplicitT { + constexpr ImplicitT(int x) : value(x) {} + int value; +}; + +struct ExplicitNothrowT { + explicit ExplicitNothrowT(int x) noexcept : value(x) {} + int value; +}; + +struct ImplicitNothrowT { + ImplicitNothrowT(int x) noexcept : value(x) {} + int value; +}; + +int main() { + { // explicit noexcept test + static_assert(!std::is_nothrow_constructible, + std::pair&&>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::pair&&>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::pair&&>::value, ""); + static_assert( std::is_nothrow_constructible, + std::pair&&>::value, ""); + } + { // implicit noexcept test + static_assert(!std::is_nothrow_constructible, + std::pair&&>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::pair&&>::value, ""); + static_assert(!std::is_nothrow_constructible, + std::pair&&>::value, ""); + static_assert( std::is_nothrow_constructible, + std::pair&&>::value, ""); + } +} diff --git a/test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp b/test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp index ec9cc7ec3e020..7346233887798 100644 --- a/test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp +++ b/test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "test_macros.h" @@ -81,7 +82,7 @@ static_assert(HasTrivialABI::value, ""); #endif -int main() +void test_trivial() { { typedef std::pair P; @@ -145,3 +146,15 @@ int main() } #endif } + +void test_layout() { + typedef std::pair, char> PairT; + static_assert(sizeof(PairT) == 3, ""); + static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), ""); + static_assert(offsetof(PairT, first) == 0, ""); +} + +int main() { + test_trivial(); + test_layout(); +} diff --git a/test/libcxx/utilities/variant/variant.variant/variant.helper/variant_alternative.fail.cpp b/test/libcxx/utilities/variant/variant.variant/variant.helper/variant_alternative.fail.cpp index f39a445b98afd..c4522682c4b88 100644 --- a/test/libcxx/utilities/variant/variant.variant/variant.helper/variant_alternative.fail.cpp +++ b/test/libcxx/utilities/variant/variant.variant/variant.helper/variant_alternative.fail.cpp @@ -31,6 +31,6 @@ int main() { typedef std::variant T; std::variant_alternative<2, T>::type foo; // expected-note {{requested here}} - // expected-error@variant:* {{static_assert failed "Index out of bounds in std::variant_alternative<>"}} + // expected-error-re@variant:* {{static_assert failed{{( due to requirement '2U[L]{0,2} < sizeof...\(_Types\)')?}} "Index out of bounds in std::variant_alternative<>"}} } } diff --git a/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp b/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp index a836ef5169ef1..c309aaaaea180 100644 --- a/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp +++ b/test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp @@ -24,7 +24,8 @@ struct make_variant_imp; template struct make_variant_imp> { - using type = std::variant; + template using AlwaysChar = char; + using type = std::variant...>; }; template -- cgit v1.3