summaryrefslogtreecommitdiff
path: root/test/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'test/libcxx')
-rw-r--r--test/libcxx/algorithms/version.pass.cpp20
-rw-r--r--test/libcxx/atomics/atomics.flag/init_bool.pass.cpp31
-rw-r--r--test/libcxx/atomics/version.pass.cpp22
-rw-r--r--test/libcxx/compiler.py26
-rw-r--r--test/libcxx/containers/associative/map/version.pass.cpp20
-rw-r--r--test/libcxx/containers/associative/set/version.pass.cpp20
-rw-r--r--test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp1619
-rw-r--r--test/libcxx/containers/associative/tree_key_value_traits.pass.cpp59
-rw-r--r--test/libcxx/containers/associative/tree_left_rotate.pass.cpp101
-rw-r--r--test/libcxx/containers/associative/tree_remove.pass.cpp1651
-rw-r--r--test/libcxx/containers/associative/tree_right_rotate.pass.cpp101
-rw-r--r--test/libcxx/containers/container.adaptors/queue/version.pass.cpp20
-rw-r--r--test/libcxx/containers/container.adaptors/stack/version.pass.cpp20
-rw-r--r--test/libcxx/containers/gnu_cxx/hash_map.pass.cpp26
-rw-r--r--test/libcxx/containers/gnu_cxx/hash_set.pass.cpp26
-rw-r--r--test/libcxx/containers/sequences/array/version.pass.cpp20
-rw-r--r--test/libcxx/containers/sequences/deque/version.pass.cpp20
-rw-r--r--test/libcxx/containers/sequences/forwardlist/version.pass.cpp20
-rw-r--r--test/libcxx/containers/sequences/list/db_back.pass.cpp32
-rw-r--r--test/libcxx/containers/sequences/list/db_cback.pass.cpp30
-rw-r--r--test/libcxx/containers/sequences/list/db_cfront.pass.cpp30
-rw-r--r--test/libcxx/containers/sequences/list/db_front.pass.cpp32
-rw-r--r--test/libcxx/containers/sequences/list/db_iterators_6.pass.cpp33
-rw-r--r--test/libcxx/containers/sequences/list/db_iterators_7.pass.cpp33
-rw-r--r--test/libcxx/containers/sequences/list/db_iterators_8.pass.cpp31
-rw-r--r--test/libcxx/containers/sequences/list/db_iterators_9.pass.cpp59
-rw-r--r--test/libcxx/containers/sequences/list/list.cons/db_copy.pass.cpp29
-rw-r--r--test/libcxx/containers/sequences/list/list.cons/db_move.pass.cpp32
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/emplace_db1.pass.cpp44
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp28
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp29
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp29
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp28
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp28
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp27
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp36
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp27
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp27
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp29
-rw-r--r--test/libcxx/containers/sequences/list/list.modifiers/pop_back_db1.pass.cpp33
-rw-r--r--test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list.pass.cpp29
-rw-r--r--test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter.pass.cpp29
-rw-r--r--test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter_iter.pass.cpp29
-rw-r--r--test/libcxx/containers/sequences/list/list.special/db_swap_1.pass.cpp36
-rw-r--r--test/libcxx/containers/sequences/list/list.special/db_swap_2.pass.cpp36
-rw-r--r--test/libcxx/containers/sequences/list/version.pass.cpp20
-rw-r--r--test/libcxx/containers/sequences/vector/const_value_type.pass.cpp22
-rw-r--r--test/libcxx/containers/sequences/vector/db_back.pass.cpp56
-rw-r--r--test/libcxx/containers/sequences/vector/db_cback.pass.cpp52
-rw-r--r--test/libcxx/containers/sequences/vector/db_cfront.pass.cpp52
-rw-r--r--test/libcxx/containers/sequences/vector/db_cindex.pass.cpp54
-rw-r--r--test/libcxx/containers/sequences/vector/db_front.pass.cpp56
-rw-r--r--test/libcxx/containers/sequences/vector/db_index.pass.cpp56
-rw-r--r--test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp54
-rw-r--r--test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp54
-rw-r--r--test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp56
-rw-r--r--test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp60
-rw-r--r--test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp58
-rw-r--r--test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp58
-rw-r--r--test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp54
-rw-r--r--test/libcxx/containers/sequences/vector/version.pass.cpp20
-rw-r--r--test/libcxx/containers/unord/key_value_traits.pass.cpp59
-rw-r--r--test/libcxx/containers/unord/next_prime.pass.cpp51
-rw-r--r--test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp60
-rw-r--r--test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp56
-rw-r--r--test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp57
-rw-r--r--test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp54
-rw-r--r--test/libcxx/containers/unord/unord.map/version.pass.cpp20
-rw-r--r--test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp48
-rw-r--r--test/libcxx/containers/unord/unord.set/version.pass.cpp20
-rw-r--r--test/libcxx/depr/depr.c.headers/extern_c.pass.cpp43
-rw-r--r--test/libcxx/depr/depr.str.strstreams/version.pass.cpp20
-rw-r--r--test/libcxx/diagnostics/assertions/version_cassert.pass.cpp20
-rw-r--r--test/libcxx/diagnostics/errno/version_cerrno.pass.cpp19
-rw-r--r--test/libcxx/diagnostics/std.exceptions/version.pass.cpp20
-rw-r--r--test/libcxx/diagnostics/syserr/version.pass.cpp20
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp19
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp10
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp4
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp15
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp13
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp15
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp13
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp2
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp13
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp9
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp15
-rw-r--r--test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp101
-rw-r--r--test/libcxx/experimental/filesystem/lit.local.cfg3
-rw-r--r--test/libcxx/experimental/filesystem/version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp178
-rw-r--r--test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp42
-rw-r--r--test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp65
-rw-r--r--test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp45
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_deque_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_forward_list_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_list_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_map_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_regex_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_set_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_string_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_map_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_set_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.aliases/header_vector_libcpp_version.pass.cpp22
-rw-r--r--test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp61
-rw-r--r--test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp53
-rw-r--r--test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp22
-rw-r--r--test/libcxx/experimental/optional/version.pass.cpp20
-rw-r--r--test/libcxx/experimental/utilities/meta/version.pass.cpp20
-rw-r--r--test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp7
-rw-r--r--test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp7
-rw-r--r--test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp7
-rw-r--r--test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp9
-rw-r--r--test/libcxx/experimental/utilities/utility/version.pass.cpp20
-rw-r--r--test/libcxx/extensions/hash/specializations.fail.cpp17
-rw-r--r--test/libcxx/extensions/hash/specializations.pass.cpp31
-rw-r--r--test/libcxx/extensions/hash_map/const_iterator.fail.cpp18
-rw-r--r--test/libcxx/extensions/nothing_to_do.pass.cpp12
-rw-r--r--test/libcxx/input.output/file.streams/c.files/version_ccstdio.pass.cpp20
-rw-r--r--test/libcxx/input.output/file.streams/c.files/version_cinttypes.pass.cpp20
-rw-r--r--test/libcxx/input.output/file.streams/fstreams/version.pass.cpp20
-rw-r--r--test/libcxx/input.output/iostream.format/input.streams/version.pass.cpp20
-rw-r--r--test/libcxx/input.output/iostream.format/output.streams/version.pass.cpp20
-rw-r--r--test/libcxx/input.output/iostream.format/std.manip/version.pass.cpp20
-rw-r--r--test/libcxx/input.output/iostream.forward/version.pass.cpp20
-rw-r--r--test/libcxx/input.output/iostream.objects/version.pass.cpp20
-rw-r--r--test/libcxx/input.output/iostreams.base/version.pass.cpp20
-rw-r--r--test/libcxx/input.output/stream.buffers/version.pass.cpp20
-rw-r--r--test/libcxx/input.output/string.streams/version.pass.cpp20
-rw-r--r--test/libcxx/iterators/trivial_iterators.pass.cpp24
-rw-r--r--test/libcxx/iterators/version.pass.cpp20
-rw-r--r--test/libcxx/language.support/cstdint/version.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp28
-rw-r--r--test/libcxx/language.support/support.dynamic/version.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.exception/version.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.initlist/version.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.limits/c.limits/version_cfloat.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.limits/c.limits/version_climits.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.limits/limits/version.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.rtti/version.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.runtime/version_csetjmp.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.runtime/version_csignal.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.runtime/version_cstdarg.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.runtime/version_cstdbool.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.runtime/version_cstdlib.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.runtime/version_ctime.pass.cpp20
-rw-r--r--test/libcxx/language.support/support.types/version.pass.cpp20
-rw-r--r--test/libcxx/localization/c.locales/version.pass.cpp20
-rw-r--r--test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp118
-rw-r--r--test/libcxx/localization/locale.stdcvt/version.pass.cpp20
-rw-r--r--test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp35
-rw-r--r--test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp53
-rw-r--r--test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp50
-rw-r--r--test/libcxx/localization/version.pass.cpp20
-rw-r--r--test/libcxx/numerics/cfenv/version.pass.cpp22
-rw-r--r--test/libcxx/numerics/complex.number/version.pass.cpp20
-rw-r--r--test/libcxx/numerics/numarray/version.pass.cpp20
-rw-r--r--test/libcxx/numerics/numeric.ops/version.pass.cpp20
-rw-r--r--test/libcxx/numerics/rand/rand.synopsis/version.pass.cpp20
-rw-r--r--test/libcxx/selftest/test_macros.pass.cpp54
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.cpp50
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp52
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.cpp50
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.cpp50
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.cpp50
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp48
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/erase_pop_back_db1.pass.cpp32
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp34
-rw-r--r--test/libcxx/strings/basic.string/string.modifiers/insert_iter_size_char_db1.pass.cpp31
-rw-r--r--test/libcxx/strings/c.strings/version_cctype.pass.cpp20
-rw-r--r--test/libcxx/strings/c.strings/version_cstring.pass.cpp20
-rw-r--r--test/libcxx/strings/c.strings/version_cuchar.pass.cpp22
-rw-r--r--test/libcxx/strings/c.strings/version_cwchar.pass.cpp20
-rw-r--r--test/libcxx/strings/c.strings/version_cwctype.pass.cpp20
-rw-r--r--test/libcxx/strings/iterators.exceptions.pass.cpp17
-rw-r--r--test/libcxx/strings/iterators.noexcept.pass.cpp12
-rw-r--r--test/libcxx/strings/version.pass.cpp20
-rw-r--r--test/libcxx/test/config.py117
-rw-r--r--test/libcxx/test/format.py11
-rw-r--r--test/libcxx/test/target_info.py22
-rw-r--r--test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp53
-rw-r--r--test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp53
-rw-r--r--test/libcxx/thread/futures/futures.task/types.pass.cpp31
-rw-r--r--test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp29
-rw-r--r--test/libcxx/thread/thread.condition/version.pass.cpp22
-rw-r--r--test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.pass.cpp35
-rw-r--r--test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp27
-rw-r--r--test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp27
-rw-r--r--test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp26
-rw-r--r--test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp25
-rw-r--r--test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp26
-rw-r--r--test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp23
-rw-r--r--test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp30
-rw-r--r--test/libcxx/thread/thread.mutex/version.pass.cpp20
-rw-r--r--test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp54
-rw-r--r--test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp27
-rw-r--r--test/libcxx/thread/thread.threads/version.pass.cpp22
-rw-r--r--test/libcxx/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp370
-rw-r--r--test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp216
-rw-r--r--test/libcxx/utilities/function.objects/func.require/bullet_7.pass.cpp327
-rw-r--r--test/libcxx/utilities/function.objects/func.require/invoke.pass.cpp45
-rw-r--r--test/libcxx/utilities/function.objects/func.require/invoke_helpers.h456
-rw-r--r--test/libcxx/utilities/function.objects/version.pass.cpp20
-rw-r--r--test/libcxx/utilities/memory/version.pass.cpp20
-rw-r--r--test/libcxx/utilities/meta/is_referenceable.pass.cpp193
-rw-r--r--test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp71
-rw-r--r--test/libcxx/utilities/meta/version.pass.cpp20
-rw-r--r--test/libcxx/utilities/ratio/version.pass.cpp20
-rw-r--r--test/libcxx/utilities/template.bitset/version.pass.cpp20
-rw-r--r--test/libcxx/utilities/time/version.pass.cpp20
-rw-r--r--test/libcxx/utilities/tuple/version.pass.cpp20
-rw-r--r--test/libcxx/utilities/type.index/version.pass.cpp20
-rw-r--r--test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp55
-rw-r--r--test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp147
-rw-r--r--test/libcxx/utilities/utility/version.pass.cpp20
215 files changed, 11264 insertions, 232 deletions
diff --git a/test/libcxx/algorithms/version.pass.cpp b/test/libcxx/algorithms/version.pass.cpp
new file mode 100644
index 0000000000000..20f0637e641b0
--- /dev/null
+++ b/test/libcxx/algorithms/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+#include <algorithm>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp b/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
new file mode 100644
index 0000000000000..d7b172cd1212d
--- /dev/null
+++ b/test/libcxx/atomics/atomics.flag/init_bool.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: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// TESTING EXTENSION atomic_flag(bool)
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+ {
+ std::atomic_flag f(false);
+ assert(f.test_and_set() == 0);
+ }
+ {
+ std::atomic_flag f(true);
+ assert(f.test_and_set() == 1);
+ }
+}
diff --git a/test/libcxx/atomics/version.pass.cpp b/test/libcxx/atomics/version.pass.cpp
new file mode 100644
index 0000000000000..fae2736d229f2
--- /dev/null
+++ b/test/libcxx/atomics/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+
+// <atomic>
+
+#include <atomic>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/compiler.py b/test/libcxx/compiler.py
index 7dfb13abbd41e..17e6cf441ec1d 100644
--- a/test/libcxx/compiler.py
+++ b/test/libcxx/compiler.py
@@ -47,9 +47,10 @@ class CXXCompiler(object):
self.type = compiler_type
self.version = (major_ver, minor_ver, patchlevel)
- def _basicCmd(self, source_files, out, is_link=False, input_is_cxx=False):
+ def _basicCmd(self, source_files, out, is_link=False, input_is_cxx=False,
+ disable_ccache=False):
cmd = []
- if self.use_ccache and not is_link:
+ if self.use_ccache and not disable_ccache and not is_link:
cmd += ['ccache']
cmd += [self.path]
if out is not None:
@@ -65,12 +66,15 @@ class CXXCompiler(object):
return cmd
def preprocessCmd(self, source_files, out=None, flags=[]):
- cmd = self._basicCmd(source_files, out, input_is_cxx=True) + ['-E']
+ cmd = self._basicCmd(source_files, out, input_is_cxx=True,
+ disable_ccache=True) + ['-E']
cmd += self.flags + self.compile_flags + flags
return cmd
- def compileCmd(self, source_files, out=None, flags=[]):
- cmd = self._basicCmd(source_files, out, input_is_cxx=True) + ['-c']
+ def compileCmd(self, source_files, out=None, flags=[],
+ disable_ccache=False):
+ cmd = self._basicCmd(source_files, out, input_is_cxx=True,
+ disable_ccache=disable_ccache) + ['-c']
cmd += self.flags + self.compile_flags + flags
return cmd
@@ -89,8 +93,10 @@ class CXXCompiler(object):
out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
return cmd, out, err, rc
- def compile(self, source_files, out=None, flags=[], env=None, cwd=None):
- cmd = self.compileCmd(source_files, out, flags)
+ def compile(self, source_files, out=None, flags=[], env=None, cwd=None,
+ disable_ccache=False):
+ cmd = self.compileCmd(source_files, out, flags,
+ disable_ccache=disable_ccache)
out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
return cmd, out, err, rc
@@ -106,7 +112,8 @@ class CXXCompiler(object):
return cmd, out, err, rc
def compileLinkTwoSteps(self, source_file, out=None, object_file=None,
- flags=[], env=None, cwd=None):
+ flags=[], env=None, cwd=None,
+ disable_ccache=False):
if not isinstance(source_file, str):
raise TypeError('This function only accepts a single input file')
if object_file is None:
@@ -117,7 +124,8 @@ class CXXCompiler(object):
with_fn = lambda: libcxx.util.nullContext(object_file)
with with_fn() as object_file:
cc_cmd, cc_stdout, cc_stderr, rc = self.compile(
- source_file, object_file, flags=flags, env=env, cwd=cwd)
+ source_file, object_file, flags=flags, env=env, cwd=cwd,
+ disable_ccache=disable_ccache)
if rc != 0:
return cc_cmd, cc_stdout, cc_stderr, rc
diff --git a/test/libcxx/containers/associative/map/version.pass.cpp b/test/libcxx/containers/associative/map/version.pass.cpp
new file mode 100644
index 0000000000000..b2e3fa43e7879
--- /dev/null
+++ b/test/libcxx/containers/associative/map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+#include <map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/associative/set/version.pass.cpp b/test/libcxx/containers/associative/set/version.pass.cpp
new file mode 100644
index 0000000000000..c3c4d926e5c33
--- /dev/null
+++ b/test/libcxx/containers/associative/set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+#include <set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp b/test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp
new file mode 100644
index 0000000000000..300c1e9a49157
--- /dev/null
+++ b/test/libcxx/containers/associative/tree_balance_after_insert.pass.cpp
@@ -0,0 +1,1619 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __root->__is_black_ == true
+// template <class _NodePtr>
+// void
+// __tree_balance_after_insert(_NodePtr __root, _NodePtr __x)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+ bool __is_black_;
+
+ Node* __parent_unsafe() const { return __parent_; }
+ void __set_parent(Node* x) { __parent_ = x;}
+
+ Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = &a;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &a);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &a;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &a);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = &a;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = &g;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &h;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &d;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &g);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &h);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &a;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &h;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &d;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &a);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &h);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &h;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &a;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &b;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &h);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &a);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &h;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &i;
+ d.__right_ = &a;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &b;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &h);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &i);
+ assert(d.__right_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+}
+
+void
+test2()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &a;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ a.__parent_ = &c;
+ a.__left_ = 0;
+ a.__right_ = &b;
+ a.__is_black_ = false;
+
+ b.__parent_ = &a;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = 0;
+ a.__right_ = &c;
+ a.__is_black_ = true;
+
+ c.__parent_ = &a;
+ c.__left_ = &b;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &a;
+ c.__right_ = &g;
+ c.__is_black_ = true;
+
+ a.__parent_ = &c;
+ a.__left_ = &d;
+ a.__right_ = &b;
+ a.__is_black_ = false;
+
+ b.__parent_ = &a;
+ b.__left_ = &e;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = &d;
+ a.__right_ = &c;
+ a.__is_black_ = true;
+
+ c.__parent_ = &a;
+ c.__left_ = &b;
+ c.__right_ = &g;
+ c.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = &e;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+}
+
+void
+test3()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = 0;
+ a.__right_ = &b;
+ a.__is_black_ = true;
+
+ b.__parent_ = &a;
+ b.__left_ = 0;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &g;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &d;
+ a.__right_ = &e;
+ a.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = &d;
+ a.__right_ = &b;
+ a.__is_black_ = true;
+
+ b.__parent_ = &a;
+ b.__left_ = &e;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = &f;
+ c.__right_ = &g;
+ c.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+}
+
+void
+test4()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &a;
+ a.__parent_ = &root;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ a.__right_ = &b;
+ b.__parent_ = &a;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == &b);
+ assert(a.__is_black_ == true);
+
+ assert(b.__parent_ == &a);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == false);
+
+ b.__right_ = &c;
+ c.__parent_ = &b;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ c.__right_ = &d;
+ d.__parent_ = &c;
+
+ std::__tree_balance_after_insert(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ d.__right_ = &e;
+ e.__parent_ = &d;
+
+ std::__tree_balance_after_insert(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ e.__right_ = &f;
+ f.__parent_ = &e;
+
+ std::__tree_balance_after_insert(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == false);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ f.__right_ = &g;
+ g.__parent_ = &f;
+
+ std::__tree_balance_after_insert(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == false);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == false);
+
+ g.__right_ = &h;
+ h.__parent_ = &g;
+
+ std::__tree_balance_after_insert(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+}
+
+void
+test5()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &h;
+ h.__parent_ = &root;
+
+ std::__tree_balance_after_insert(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ h.__left_ = &g;
+ g.__parent_ = &h;
+
+ std::__tree_balance_after_insert(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == &g);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ assert(g.__parent_ == &h);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == false);
+
+ g.__left_ = &f;
+ f.__parent_ = &g;
+
+ std::__tree_balance_after_insert(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ f.__left_ = &e;
+ e.__parent_ = &f;
+
+ std::__tree_balance_after_insert(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ e.__left_ = &d;
+ d.__parent_ = &e;
+
+ std::__tree_balance_after_insert(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ d.__left_ = &c;
+ c.__parent_ = &d;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == false);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ c.__left_ = &b;
+ b.__parent_ = &c;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == false);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ b.__left_ = &a;
+ a.__parent_ = &b;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &g);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(g.__parent_ == &e);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == false);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+}
diff --git a/test/libcxx/containers/associative/tree_key_value_traits.pass.cpp b/test/libcxx/containers/associative/tree_key_value_traits.pass.cpp
new file mode 100644
index 0000000000000..0befd749a50c0
--- /dev/null
+++ b/test/libcxx/containers/associative/tree_key_value_traits.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <__tree>
+#include <map>
+#include <set>
+#include <type_traits>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+void testKeyValueTrait() {
+ {
+ typedef int Tp;
+ typedef std::__tree_key_value_types<Tp> Traits;
+ static_assert((std::is_same<Traits::key_type, int>::value), "");
+ static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
+ static_assert(Traits::__is_map == false, "");
+ }
+ {
+ typedef std::pair<int, int> Tp;
+ typedef std::__tree_key_value_types<Tp> Traits;
+ static_assert((std::is_same<Traits::key_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
+ static_assert(Traits::__is_map == false, "");
+ }
+ {
+ typedef std::pair<const int, int> Tp;
+ typedef std::__tree_key_value_types<Tp> Traits;
+ static_assert((std::is_same<Traits::key_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
+ static_assert(Traits::__is_map == false, "");
+ }
+ {
+ typedef std::__value_type<int, int> Tp;
+ typedef std::__tree_key_value_types<Tp> Traits;
+ static_assert((std::is_same<Traits::key_type, int>::value), "");
+ static_assert((std::is_same<Traits::mapped_type, int>::value), "");
+ static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__container_value_type,
+ std::pair<const int, int> >::value), "");
+ static_assert((std::is_same<Traits::__map_value_type,
+ std::pair<const int, int> >::value), "");
+ static_assert(Traits::__is_map == true, "");
+ }
+}
+
+int main() {
+ testKeyValueTrait();
+}
diff --git a/test/libcxx/containers/associative/tree_left_rotate.pass.cpp b/test/libcxx/containers/associative/tree_left_rotate.pass.cpp
new file mode 100644
index 0000000000000..2720b448bdd4e
--- /dev/null
+++ b/test/libcxx/containers/associative/tree_left_rotate.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __x->__right_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_left_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+
+ Node* __parent_unsafe() const { return __parent_; }
+ void __set_parent(Node* x) { __parent_ = x;}
+
+ Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+ Node root;
+ Node x;
+ Node y;
+ root.__left_ = &x;
+ x.__left_ = 0;
+ x.__right_ = &y;
+ x.__parent_ = &root;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__parent_ = &x;
+ std::__tree_left_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &x);
+ assert(y.__right_ == 0);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == 0);
+ assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+ Node root;
+ Node x;
+ Node y;
+ Node a;
+ Node b;
+ Node c;
+ root.__left_ = &x;
+ x.__left_ = &a;
+ x.__right_ = &y;
+ x.__parent_ = &root;
+ y.__left_ = &b;
+ y.__right_ = &c;
+ y.__parent_ = &x;
+ a.__parent_ = &x;
+ b.__parent_ = &y;
+ c.__parent_ = &y;
+ std::__tree_left_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &x);
+ assert(y.__right_ == &c);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == &a);
+ assert(x.__right_ == &b);
+ assert(a.__parent_ == &x);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(b.__parent_ == &x);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(c.__parent_ == &y);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/libcxx/containers/associative/tree_remove.pass.cpp b/test/libcxx/containers/associative/tree_remove.pass.cpp
new file mode 100644
index 0000000000000..fa0b7d4a13117
--- /dev/null
+++ b/test/libcxx/containers/associative/tree_remove.pass.cpp
@@ -0,0 +1,1651 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Returns __tree_next(__z)
+// template <class _NodePtr>
+// void
+// __tree_remove(_NodePtr __root, _NodePtr __z)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+ bool __is_black_;
+
+ Node* __parent_unsafe() const { return __parent_; }
+ void __set_parent(Node* x) { __parent_ = x;}
+
+ Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+ {
+ // Left
+ // Case 1 -> Case 2 -> x is red turned to black
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &y;
+ b.__right_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__left_ = &c;
+ d.__right_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Right
+ // Case 1 -> Case 2 -> x is red turned to black
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__right_ = &y;
+ b.__left_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__right_ = 0;
+ y.__left_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__right_ = &c;
+ d.__left_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__right_ = 0;
+ c.__left_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__right_ = 0;
+ e.__left_ = 0;
+ e.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__right_ == &b);
+ assert(d.__left_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__right_ == 0);
+ assert(b.__left_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__right_ == 0);
+ assert(c.__left_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__left_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Left
+ // Case 1 -> Case 3 -> Case 4
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &y;
+ b.__right_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__left_ = &c;
+ d.__right_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__left_ = &f;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__left_ = 0;
+ f.__right_ = 0;
+ f.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &f);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &b);
+ assert(f.__right_ == &c);
+ assert(f.__is_black_ == false);
+
+ assert(b.__parent_ == &f);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &f);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Right
+ // Case 1 -> Case 3 -> Case 4
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__right_ = &y;
+ b.__left_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__right_ = 0;
+ y.__left_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__right_ = &c;
+ d.__left_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__right_ = &f;
+ c.__left_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__right_ = 0;
+ e.__left_ = 0;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__right_ = 0;
+ f.__left_ = 0;
+ f.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__right_ == &f);
+ assert(d.__left_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__right_ == &b);
+ assert(f.__left_ == &c);
+ assert(f.__is_black_ == false);
+
+ assert(b.__parent_ == &f);
+ assert(b.__right_ == 0);
+ assert(b.__left_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &f);
+ assert(c.__right_ == 0);
+ assert(c.__left_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__left_ == 0);
+ assert(e.__is_black_ == true);
+ }
+}
+
+void
+test2()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+}
+
+void
+test3()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &e;
+
+ e.__parent_ = &root;
+ e.__left_ = &c;
+ e.__right_ = &g;
+ e.__is_black_ = true;
+
+ c.__parent_ = &e;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = false;
+
+ g.__parent_ = &e;
+ g.__left_ = &f;
+ g.__right_ = &h;
+ g.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = true;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = true;
+
+ f.__parent_ = &g;
+ f.__left_ = 0;
+ f.__right_ = 0;
+ f.__is_black_ = true;
+
+ h.__parent_ = &g;
+ h.__left_ = 0;
+ h.__right_ = 0;
+ h.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ assert(std::__tree_invariant(root.__left_));
+
+ std::__tree_remove(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &g);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(g.__parent_ == &e);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &e);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(e.__parent_ == &c);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+}
+
+void
+test4()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &d;
+
+ d.__parent_ = &root;
+ d.__left_ = &b;
+ d.__right_ = &f;
+ d.__is_black_ = true;
+
+ b.__parent_ = &d;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ f.__parent_ = &d;
+ f.__left_ = &e;
+ f.__right_ = &g;
+ f.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &f;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ g.__parent_ = &f;
+ g.__left_ = 0;
+ g.__right_ = &h;
+ g.__is_black_ = true;
+
+ h.__parent_ = &g;
+ h.__left_ = 0;
+ h.__right_ = 0;
+ h.__is_black_ = false;
+
+ assert(std::__tree_invariant(root.__left_));
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &f);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(f.__parent_ == &root);
+ assert(f.__left_ == &d);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(d.__parent_ == &f);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &f);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(f.__parent_ == &root);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+}
diff --git a/test/libcxx/containers/associative/tree_right_rotate.pass.cpp b/test/libcxx/containers/associative/tree_right_rotate.pass.cpp
new file mode 100644
index 0000000000000..9355a46b4e2b7
--- /dev/null
+++ b/test/libcxx/containers/associative/tree_right_rotate.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __x->__left_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_right_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+
+ Node* __parent_unsafe() const { return __parent_; }
+ void __set_parent(Node* x) { __parent_ = x;}
+
+ Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+ Node root;
+ Node x;
+ Node y;
+ root.__left_ = &x;
+ x.__left_ = &y;
+ x.__right_ = 0;
+ x.__parent_ = &root;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__parent_ = &x;
+ std::__tree_right_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == 0);
+ assert(y.__right_ == &x);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == 0);
+ assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+ Node root;
+ Node x;
+ Node y;
+ Node a;
+ Node b;
+ Node c;
+ root.__left_ = &x;
+ x.__left_ = &y;
+ x.__right_ = &c;
+ x.__parent_ = &root;
+ y.__left_ = &a;
+ y.__right_ = &b;
+ y.__parent_ = &x;
+ a.__parent_ = &y;
+ b.__parent_ = &y;
+ c.__parent_ = &x;
+ std::__tree_right_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &a);
+ assert(y.__right_ == &x);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == &b);
+ assert(x.__right_ == &c);
+ assert(a.__parent_ == &y);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(b.__parent_ == &x);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(c.__parent_ == &x);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/test/libcxx/containers/container.adaptors/queue/version.pass.cpp b/test/libcxx/containers/container.adaptors/queue/version.pass.cpp
new file mode 100644
index 0000000000000..35b94b33c517d
--- /dev/null
+++ b/test/libcxx/containers/container.adaptors/queue/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+#include <queue>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/container.adaptors/stack/version.pass.cpp b/test/libcxx/containers/container.adaptors/stack/version.pass.cpp
new file mode 100644
index 0000000000000..339d0f4dda8f7
--- /dev/null
+++ b/test/libcxx/containers/container.adaptors/stack/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+#include <stack>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp b/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp
new file mode 100644
index 0000000000000..0d9115d0f6938
--- /dev/null
+++ b/test/libcxx/containers/gnu_cxx/hash_map.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.
+//
+//===----------------------------------------------------------------------===//
+
+// Prevent emission of the deprecated warning.
+#ifdef __clang__
+#pragma clang diagnostic ignored "-W#warnings"
+#endif
+
+#include <ext/hash_map>
+
+namespace __gnu_cxx {
+template class hash_map<int, int>;
+}
+
+int main() {
+ typedef __gnu_cxx::hash_map<int, int> Map;
+ Map m;
+ Map m2(m);
+ ((void)m2);
+}
diff --git a/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp b/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp
new file mode 100644
index 0000000000000..5fd4bde66e0ac
--- /dev/null
+++ b/test/libcxx/containers/gnu_cxx/hash_set.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.
+//
+//===----------------------------------------------------------------------===//
+
+// Prevent emission of the deprecated warning.
+#ifdef __clang__
+#pragma clang diagnostic ignored "-W#warnings"
+#endif
+
+#include <ext/hash_set>
+
+namespace __gnu_cxx {
+template class hash_set<int>;
+}
+
+int main() {
+ typedef __gnu_cxx::hash_set<int> Set;
+ Set s;
+ Set s2(s);
+ ((void)s2);
+}
diff --git a/test/libcxx/containers/sequences/array/version.pass.cpp b/test/libcxx/containers/sequences/array/version.pass.cpp
new file mode 100644
index 0000000000000..b89a8dd8cca3b
--- /dev/null
+++ b/test/libcxx/containers/sequences/array/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+#include <array>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/sequences/deque/version.pass.cpp b/test/libcxx/containers/sequences/deque/version.pass.cpp
new file mode 100644
index 0000000000000..22e663d9bc227
--- /dev/null
+++ b/test/libcxx/containers/sequences/deque/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+#include <deque>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/sequences/forwardlist/version.pass.cpp b/test/libcxx/containers/sequences/forwardlist/version.pass.cpp
new file mode 100644
index 0000000000000..918c8dd5d73cd
--- /dev/null
+++ b/test/libcxx/containers/sequences/forwardlist/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+#include <forward_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/sequences/list/db_back.pass.cpp b/test/libcxx/containers/sequences/list/db_back.pass.cpp
new file mode 100644
index 0000000000000..96dfd2d8d2ecd
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/db_back.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call back() on empty container.
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/db_cback.pass.cpp b/test/libcxx/containers/sequences/list/db_cback.pass.cpp
new file mode 100644
index 0000000000000..1e25307c4602b
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/db_cback.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call back() on empty const container.
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ typedef int T;
+ typedef std::list<T> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/db_cfront.pass.cpp b/test/libcxx/containers/sequences/list/db_cfront.pass.cpp
new file mode 100644
index 0000000000000..9501ce1931382
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/db_cfront.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call front() on empty const container.
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ typedef int T;
+ typedef std::list<T> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/db_front.pass.cpp b/test/libcxx/containers/sequences/list/db_front.pass.cpp
new file mode 100644
index 0000000000000..fc02895a8912c
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/db_front.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call front() on empty container.
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/db_iterators_6.pass.cpp b/test/libcxx/containers/sequences/list/db_iterators_6.pass.cpp
new file mode 100644
index 0000000000000..3f0fd015e9a4d
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/db_iterators_6.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Decrement iterator prior to begin.
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/db_iterators_7.pass.cpp b/test/libcxx/containers/sequences/list/db_iterators_7.pass.cpp
new file mode 100644
index 0000000000000..bc2b7f4e1da21
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/db_iterators_7.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Increment iterator past end.
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/db_iterators_8.pass.cpp b/test/libcxx/containers/sequences/list/db_iterators_8.pass.cpp
new file mode 100644
index 0000000000000..08c10d34a01ee
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/db_iterators_8.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Dereference non-dereferenceable iterator.
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/db_iterators_9.pass.cpp b/test/libcxx/containers/sequences/list/db_iterators_9.pass.cpp
new file mode 100644
index 0000000000000..e2b95d8b16647
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/db_iterators_9.pass.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: c++98, c++03
+// UNSUPPORTED: libcpp-no-exceptions
+
+// <list>
+
+// Operations on "NULL" iterators
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0)
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+struct S { int val; };
+
+int main()
+{
+ {
+ unsigned lib_asserts;
+
+ typedef S T;
+ typedef std::list<T> C;
+ C::iterator i{};
+ C::const_iterator ci{};
+
+ lib_asserts = 0;
+ try { ++i; } catch (int) { ++lib_asserts; }
+ try { i++; } catch (int) { ++lib_asserts; }
+ try { ++ci; } catch (int) { ++lib_asserts; }
+ try { ci++; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+
+ lib_asserts = 0;
+ try { --i; } catch (int) { ++lib_asserts; }
+ try { i--; } catch (int) { ++lib_asserts; }
+ try { --ci; } catch (int) { ++lib_asserts; }
+ try { ci--; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+
+ lib_asserts = 0;
+ try { *i; } catch (int) { ++lib_asserts; }
+ try { *ci; } catch (int) { ++lib_asserts; }
+ try { (void) i->val; } catch (int) { ++lib_asserts; }
+ try { (void) ci->val; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+ }
+}
diff --git a/test/libcxx/containers/sequences/list/list.cons/db_copy.pass.cpp b/test/libcxx/containers/sequences/list/list.cons/db_copy.pass.cpp
new file mode 100644
index 0000000000000..c84960f37686f
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.cons/db_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ std::list<int> l1;
+ l1.push_back(1); l1.push_back(2); l1.push_back(3);
+ std::list<int>::iterator i = l1.begin();
+ std::list<int> l2 = l1;
+ l2.erase(i);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.cons/db_move.pass.cpp b/test/libcxx/containers/sequences/list/list.cons/db_move.pass.cpp
new file mode 100644
index 0000000000000..dd424e89e7568
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.cons/db_move.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <list>
+
+// list(list&& c);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(1))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ std::list<int> l1 = {1, 2, 3};
+ std::list<int>::iterator i = l1.begin();
+ std::list<int> l2 = std::move(l1);
+ assert(*l2.erase(i) == 2);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/emplace_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/emplace_db1.pass.cpp
new file mode 100644
index 0000000000000..1d64f9bd9e275
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/emplace_db1.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <list>
+
+// template <class... Args> void emplace(const_iterator p, Args&&... args);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+int main()
+{
+ std::list<A> c1;
+ std::list<A> c2;
+ std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 0000000000000..ec5de0264cb47
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with end()
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 0000000000000..833e2b54dfaf1
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000000000..eef7a98e739a9
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+}
+
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 0000000000000..0dd03dc50da1b
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 0000000000000..22273a89f1e55
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 0000000000000..d1e03c8ac7109
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000000000..7fadb14affdda
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <InputIterator Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::list<int> v(100);
+ std::list<int> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10),
+ input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp
new file mode 100644
index 0000000000000..0d0fd100fc91b
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+} \ No newline at end of file
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp
new file mode 100644
index 0000000000000..4fdfbfa50cbbb
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ std::list<int> c1(100);
+ std::list<int> c2;
+ std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp
new file mode 100644
index 0000000000000..9a13520b98eb2
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+
+int main()
+{
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.modifiers/pop_back_db1.pass.cpp b/test/libcxx/containers/sequences/list/list.modifiers/pop_back_db1.pass.cpp
new file mode 100644
index 0000000000000..795e66d9702a8
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.modifiers/pop_back_db1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_back();
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ int a[] = {1, 2, 3};
+ std::list<int> c(a, a+3);
+ c.pop_back();
+ assert(c == std::list<int>(a, a+2));
+ c.pop_back();
+ assert(c == std::list<int>(a, a+1));
+ c.pop_back();
+ assert(c.empty());
+ c.pop_back(); // operation under test
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list.pass.cpp b/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list.pass.cpp
new file mode 100644
index 0000000000000..7a1180a9b5857
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v2.begin(), v2);
+ assert(false);
+ }
+}
diff --git a/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter.pass.cpp b/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter.pass.cpp
new file mode 100644
index 0000000000000..fa5243e322bfd
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v1.begin(), v2, v1.begin());
+ assert(false);
+ }
+}
diff --git a/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter_iter.pass.cpp b/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter_iter.pass.cpp
new file mode 100644
index 0000000000000..a385b4cf7afa4
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter_iter.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x, iterator first, iterator last);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+ assert(false);
+ }
+}
diff --git a/test/libcxx/containers/sequences/list/list.special/db_swap_1.pass.cpp b/test/libcxx/containers/sequences/list/list.special/db_swap_1.pass.cpp
new file mode 100644
index 0000000000000..900f338c29eb4
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.special/db_swap_1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int>::iterator i1 = c1.begin();
+ std::list<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::list<int>::iterator j = i1;
+ c1.erase(i1); // called with iterator not refering to list.
+ assert(false);
+}
diff --git a/test/libcxx/containers/sequences/list/list.special/db_swap_2.pass.cpp b/test/libcxx/containers/sequences/list/list.special/db_swap_2.pass.cpp
new file mode 100644
index 0000000000000..ace9a713aae78
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/list.special/db_swap_2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ // allocators do not compare equal
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert(false);
+ }
+}
diff --git a/test/libcxx/containers/sequences/list/version.pass.cpp b/test/libcxx/containers/sequences/list/version.pass.cpp
new file mode 100644
index 0000000000000..097c013f52cb8
--- /dev/null
+++ b/test/libcxx/containers/sequences/list/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+#include <list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/sequences/vector/const_value_type.pass.cpp b/test/libcxx/containers/sequences/vector/const_value_type.pass.cpp
new file mode 100644
index 0000000000000..2a150f7cce542
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/const_value_type.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <vector>
+
+// vector<const int> v; // an extension
+
+#include <vector>
+#include <type_traits>
+
+int main()
+{
+ std::vector<const int> v = {1, 2, 3};
+}
diff --git a/test/libcxx/containers/sequences/vector/db_back.pass.cpp b/test/libcxx/containers/sequences/vector/db_back.pass.cpp
new file mode 100644
index 0000000000000..05f3d07712eb5
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_cback.pass.cpp b/test/libcxx/containers/sequences/vector/db_cback.pass.cpp
new file mode 100644
index 0000000000000..5eb1a353e8b04
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_cback.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp b/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp
new file mode 100644
index 0000000000000..5e54da1d444e9
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp b/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp
new file mode 100644
index 0000000000000..133aa56528245
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_cindex.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index const vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c(1);
+ assert(c[0] == 0);
+ assert(c[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c(1);
+ assert(c[0] == 0);
+ assert(c[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_front.pass.cpp b/test/libcxx/containers/sequences/vector/db_front.pass.cpp
new file mode 100644
index 0000000000000..388058fb31593
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_index.pass.cpp b/test/libcxx/containers/sequences/vector/db_index.pass.cpp
new file mode 100644
index 0000000000000..1daf076da67c1
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_index.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c[0] == 0);
+ c.clear();
+ assert(c[0] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c[0] == 0);
+ c.clear();
+ assert(c[0] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp
new file mode 100644
index 0000000000000..2d43843067b75
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_iterators_2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp
new file mode 100644
index 0000000000000..051d66c33394d
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_iterators_3.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Subtract iterators from different containers.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp
new file mode 100644
index 0000000000000..4c2aa628de143
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_iterators_4.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp
new file mode 100644
index 0000000000000..1b1090499c276
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp
new file mode 100644
index 0000000000000..424bc939b1366
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp
new file mode 100644
index 0000000000000..72cdb10cbc855
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp b/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp
new file mode 100644
index 0000000000000..7b898533197c6
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/db_iterators_8.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/sequences/vector/version.pass.cpp b/test/libcxx/containers/sequences/vector/version.pass.cpp
new file mode 100644
index 0000000000000..2c4fa1263de31
--- /dev/null
+++ b/test/libcxx/containers/sequences/vector/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+#include <vector>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/unord/key_value_traits.pass.cpp b/test/libcxx/containers/unord/key_value_traits.pass.cpp
new file mode 100644
index 0000000000000..a6d1ea7a527cc
--- /dev/null
+++ b/test/libcxx/containers/unord/key_value_traits.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <__hash_table>
+#include <unordered_map>
+#include <unordered_set>
+#include <type_traits>
+
+#include "test_macros.h"
+#include "min_allocator.h"
+
+void testKeyValueTrait() {
+ {
+ typedef int Tp;
+ typedef std::__hash_key_value_types<Tp> Traits;
+ static_assert((std::is_same<Traits::key_type, int>::value), "");
+ static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
+ static_assert(Traits::__is_map == false, "");
+ }
+ {
+ typedef std::pair<int, int> Tp;
+ typedef std::__hash_key_value_types<Tp> Traits;
+ static_assert((std::is_same<Traits::key_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
+ static_assert(Traits::__is_map == false, "");
+ }
+ {
+ typedef std::pair<const int, int> Tp;
+ typedef std::__hash_key_value_types<Tp> Traits;
+ static_assert((std::is_same<Traits::key_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
+ static_assert(Traits::__is_map == false, "");
+ }
+ {
+ typedef std::__hash_value_type<int, int> Tp;
+ typedef std::__hash_key_value_types<Tp> Traits;
+ static_assert((std::is_same<Traits::key_type, int>::value), "");
+ static_assert((std::is_same<Traits::mapped_type, int>::value), "");
+ static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
+ static_assert((std::is_same<Traits::__container_value_type,
+ std::pair<const int, int> >::value), "");
+ static_assert((std::is_same<Traits::__map_value_type,
+ std::pair<const int, int> >::value), "");
+ static_assert(Traits::__is_map == true, "");
+ }
+}
+
+int main() {
+ testKeyValueTrait();
+}
diff --git a/test/libcxx/containers/unord/next_prime.pass.cpp b/test/libcxx/containers/unord/next_prime.pass.cpp
new file mode 100644
index 0000000000000..266d7f1f9d1ea
--- /dev/null
+++ b/test/libcxx/containers/unord/next_prime.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: long_tests
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_prime(size_t n);
+
+// If n == 0, return 0, else return the lowest prime greater than or equal to n
+
+#include <__hash_table>
+#include <cassert>
+
+bool
+is_prime(size_t n)
+{
+ switch (n)
+ {
+ case 0:
+ case 1:
+ return false;
+ }
+ for (size_t i = 2; i*i <= n; ++i)
+ {
+ if (n % i == 0)
+ return false;
+ }
+ return true;
+}
+
+int main()
+{
+ assert(std::__next_prime(0) == 0);
+ for (std::size_t n = 1; n <= 100000; ++n)
+ {
+ std::size_t p = std::__next_prime(n);
+ assert(p >= n);
+ for (std::size_t i = n; i < p; ++i)
+ assert(!is_prime(i));
+ assert(is_prime(p));
+ }
+}
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
new file mode 100644
index 0000000000000..b8db0a35ffc3e
--- /dev/null
+++ b/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
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
new file mode 100644
index 0000000000000..c923dd77862e6
--- /dev/null
+++ b/test/libcxx/containers/unord/unord.map/db_iterators_8.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
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
new file mode 100644
index 0000000000000..fa1886bfff189
--- /dev/null
+++ b/test/libcxx/containers/unord/unord.map/db_local_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
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
new file mode 100644
index 0000000000000..4b071cad7b473
--- /dev/null
+++ b/test/libcxx/containers/unord/unord.map/db_local_iterators_8.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/containers/unord/unord.map/version.pass.cpp b/test/libcxx/containers/unord/unord.map/version.pass.cpp
new file mode 100644
index 0000000000000..fc47a326c571e
--- /dev/null
+++ b/test/libcxx/containers/unord/unord.map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp b/test/libcxx/containers/unord/unord.set/insert_dup_alloc.pass.cpp
deleted file mode 100644
index 76ceafed22088..0000000000000
--- a/test/libcxx/containers/unord/unord.set/insert_dup_alloc.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.
-//
-//===----------------------------------------------------------------------===//
-
-// Check that we don't allocate when trying to insert a duplicate value into a
-// unordered_set. See PR12999 http://llvm.org/bugs/show_bug.cgi?id=12999
-
-#include <cassert>
-#include <unordered_set>
-#include "count_new.hpp"
-#include "MoveOnly.h"
-
-int main()
-{
- {
- std::unordered_set<int> s;
- assert(globalMemCounter.checkNewCalledEq(0));
-
- for(int i=0; i < 100; ++i)
- s.insert(3);
-
- assert(s.size() == 1);
- assert(s.count(3) == 1);
- assert(globalMemCounter.checkNewCalledEq(2));
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
- globalMemCounter.reset();
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- {
- std::unordered_set<MoveOnly> s;
- assert(globalMemCounter.checkNewCalledEq(0));
-
- for(int i=0; i<100; i++)
- s.insert(MoveOnly(3));
-
- assert(s.size() == 1);
- assert(s.count(MoveOnly(3)) == 1);
- assert(globalMemCounter.checkNewCalledEq(2));
- }
- assert(globalMemCounter.checkOutstandingNewEq(0));
- globalMemCounter.reset();
-#endif
-}
diff --git a/test/libcxx/containers/unord/unord.set/version.pass.cpp b/test/libcxx/containers/unord/unord.set/version.pass.cpp
new file mode 100644
index 0000000000000..d651ebdfc456e
--- /dev/null
+++ b/test/libcxx/containers/unord/unord.set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+#include <unordered_set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp b/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp
new file mode 100644
index 0000000000000..d4d8b5fafdde0
--- /dev/null
+++ b/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Sometimes C++'s <foo.h> headers get included within extern "C" contexts. This
+// is ill-formed (no diagnostic required), per [using.headers]p3, but we permit
+// it as an extension.
+
+extern "C" {
+#include <assert.h>
+// complex.h is not supported in extern "C".
+#include <ctype.h>
+#include <errno.h>
+#include <fenv.h>
+#include <float.h>
+#include <inttypes.h>
+#include <iso646.h>
+#include <limits.h>
+#include <locale.h>
+#include <math.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdalign.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+// tgmath.h is not supported in extern "C".
+#include <time.h>
+// FIXME: #include <uchar.h>
+#include <wchar.h>
+#include <wctype.h>
+}
+
+int main() {}
diff --git a/test/libcxx/depr/depr.str.strstreams/version.pass.cpp b/test/libcxx/depr/depr.str.strstreams/version.pass.cpp
new file mode 100644
index 0000000000000..f27665f15bcd7
--- /dev/null
+++ b/test/libcxx/depr/depr.str.strstreams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+#include <strstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/diagnostics/assertions/version_cassert.pass.cpp b/test/libcxx/diagnostics/assertions/version_cassert.pass.cpp
new file mode 100644
index 0000000000000..f123a05256ec2
--- /dev/null
+++ b/test/libcxx/diagnostics/assertions/version_cassert.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <cassert>
+
+#include <cassert>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/diagnostics/errno/version_cerrno.pass.cpp b/test/libcxx/diagnostics/errno/version_cerrno.pass.cpp
new file mode 100644
index 0000000000000..7cd2be8efa92c
--- /dev/null
+++ b/test/libcxx/diagnostics/errno/version_cerrno.pass.cpp
@@ -0,0 +1,19 @@
+// -*- 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 <cerrno>
+
+#include <cerrno>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main() {}
diff --git a/test/libcxx/diagnostics/std.exceptions/version.pass.cpp b/test/libcxx/diagnostics/std.exceptions/version.pass.cpp
new file mode 100644
index 0000000000000..d9ab009a4365f
--- /dev/null
+++ b/test/libcxx/diagnostics/std.exceptions/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stdexcept>
+
+#include <stdexcept>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/diagnostics/syserr/version.pass.cpp b/test/libcxx/diagnostics/syserr/version.pass.cpp
new file mode 100644
index 0000000000000..3851150fdf908
--- /dev/null
+++ b/test/libcxx/diagnostics/syserr/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+#include <system_error>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
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
index d274bc030881e..c6a83cc61bdcb 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// dynarray.cons
// template <class Alloc>
@@ -20,10 +21,8 @@
// ~dynarray();
-
-#include <__config>
-#if _LIBCPP_STD_VER > 11
+#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -44,7 +43,7 @@ void check_allocator ( const dynarray<T> &dyn, const Allocator &alloc ) {
template <class T, class Allocator>
void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( vals, alloc );
assert ( d1.size () == vals.size() );
assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
@@ -55,7 +54,7 @@ void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
template <class T, class Allocator>
void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( 4, alloc1 );
assert ( d1.size () == 4 );
assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
@@ -68,19 +67,17 @@ void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
dynA d3 ( d2, alloc2 );
assert ( d3.size () == 7 );
- assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
+ 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
+// This test is waiting on the resolution of LWG issue #2235
// typedef test_allocator<char> Alloc;
// typedef std::basic_string<char, std::char_traits<char>, Alloc> nstr;
-//
+//
// test ( nstr("fourteen"), Alloc(3), Alloc(4) );
// test ( { nstr("1"), nstr("1"), nstr("2"), nstr("3"), nstr("5"), nstr("8")}, Alloc(6));
}
-#else
-int main() {}
-#endif
+
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
index 738c0c72592e3..cd5c56c7ac51a 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
@@ -35,7 +35,7 @@ using std::experimental::dynarray;
template <class T>
void testInitList( const std::initializer_list<T> &vals ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( vals );
assert ( d1.size () == vals.size() );
assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
@@ -45,7 +45,7 @@ void testInitList( const std::initializer_list<T> &vals ) {
template <class T>
void test ( const T &val, bool DefaultValueIsIndeterminate = false) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( 4 );
assert ( d1.size () == 4 );
if (!DefaultValueIsIndeterminate) {
@@ -58,7 +58,7 @@ void test ( const T &val, bool DefaultValueIsIndeterminate = false) {
dynA d3 ( d2 );
assert ( d3.size () == 7 );
- assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
+ assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
}
void test_bad_length () {
@@ -76,12 +76,12 @@ int main()
test<double> ( 14.0, true );
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "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<long> d1 ( 20, 3 );
assert ( d1.size() == 20 );
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
index 1bbd8cde92fe1..84c602925cb49 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp
@@ -42,7 +42,7 @@ void dyn_test( dynarray<T> &dyn, bool CheckEquals = true) {
}
}
-
+
template <class T>
void test(const T &val, bool DefaultValueIsIndeterminate = false) {
@@ -53,7 +53,7 @@ void test(const T &val, bool DefaultValueIsIndeterminate = false) {
dynA d1(4);
dyn_test(d1, CheckDefaultValues);
dyn_test_const(d1, CheckDefaultValues);
-
+
dynA d2 (7, val);
dyn_test ( d2 );
dyn_test_const ( d2 );
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
index c57887ddaf94c..376c94a6bcd8d 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// dynarray.data
// void fill(const T& v);
// const T* data() const noexcept;
-
-#include <__config>
-#if _LIBCPP_STD_VER > 11
+#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -29,11 +28,11 @@ using std::experimental::dynarray;
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( 4 );
d1.fill ( val );
- assert ( std::all_of ( d1.begin (), d1.end (),
- [&val]( const T &item ){ return item == val; } ));
+ assert ( std::all_of ( d1.begin (), d1.end (),
+ [&val]( const T &item ){ return item == val; } ));
}
int main()
@@ -43,6 +42,4 @@ int main()
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
-#else
-int main() {}
-#endif
+
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
index 8c0d085387166..a6825b68d0f17 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: libcpp-no-exceptions
// dynarray.overview
// const_reference at(size_type n) const;
// reference at(size_type n);
-
-#include <__config>
-#if _LIBCPP_STD_VER > 11
+#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -73,7 +72,7 @@ void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( vals );
dyn_test ( d1, vals );
dyn_test_const ( d1, vals );
@@ -83,13 +82,11 @@ 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"),
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
-#else
-int main() {}
-#endif
+
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
index 695e1aa9f14ae..fe425b7e8c185 100644
--- 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
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// dynarray.overview
@@ -16,7 +17,7 @@
// 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;
@@ -24,10 +25,8 @@
// const_reverse_iterator rend() const noexcept;
// const_reverse_iterator crend() const noexcept;
-
-#include <__config>
-#if _LIBCPP_STD_VER > 11
+#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -86,11 +85,11 @@ void dyn_test ( dynarray<T> &dyn ) {
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( 4 );
dyn_test ( d1 );
dyn_test_const ( d1 );
-
+
dynA d2 ( 7, val );
dyn_test ( d2 );
dyn_test_const ( d2 );
@@ -103,6 +102,4 @@ int main()
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
-#else
-int main() {}
-#endif
+
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
index 6d28eef1b0578..95262aab1bdcc 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp
@@ -7,16 +7,15 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// dynarray.overview
// size_type size() const noexcept;
// size_type max_size() const noexcept;
-// bool empty() const noexcept;
+// bool empty() const noexcept;
#include <__config>
-#if _LIBCPP_STD_VER > 11
-
#include <experimental/dynarray>
#include <cassert>
@@ -36,7 +35,7 @@ void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( vals );
dyn_test ( d1, vals.size ());
}
@@ -45,13 +44,11 @@ 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"),
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
-#else
-int main() {}
-#endif
+
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
index 2af862a5530fb..4f1d0978dd11f 100644
--- 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
@@ -58,7 +58,7 @@ void test ( const T &val, bool DefaultValueIsIndeterminate = false) {
dynA d1 ( 4 );
dyn_test ( d1, CheckDefaultValues );
dyn_test_const ( d1, CheckDefaultValues );
-
+
dynA d2 ( 7, val );
dyn_test ( d2 );
dyn_test_const ( d2 );
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
index 7317a2023cb1e..4bcb229ebce02 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp
@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// dynarray.overview
// const_reference at(size_type n) const;
// reference at(size_type n);
-
-#include <__config>
-#if _LIBCPP_STD_VER > 11
+#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -49,7 +48,7 @@ void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( vals );
dyn_test ( d1, vals );
dyn_test_const ( d1, vals );
@@ -59,13 +58,11 @@ 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"),
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
-#else
-int main() {}
-#endif
+
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
index 9b8240d4cd82f..48da6d885773f 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.traits/default.pass.cpp
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// dynarray.data
// template <class Type, class Alloc>
// struct uses_allocator<dynarray<Type>, Alloc> : true_type { };
-
-#include <__config>
-#if _LIBCPP_STD_VER > 11
+#include <__config>
#include <experimental/dynarray>
#include "test_allocator.h"
@@ -26,6 +25,4 @@ int main()
{
static_assert ( std::uses_allocator<dynarray<int>, test_allocator<int>>::value, "" );
}
-#else
-int main() {}
-#endif
+
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
index 93f3b18f192f5..c0e0180930e9b 100644
--- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp
+++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.zero/default.pass.cpp
@@ -7,18 +7,17 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// 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.
+// 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>
-#if _LIBCPP_STD_VER > 11
+#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -32,7 +31,7 @@ using std::experimental::dynarray;
template <class T>
void test ( ) {
typedef dynarray<T> dynA;
-
+
dynA d1 ( 0 );
assert ( d1.size() == 0 );
assert ( d1.begin() == d1.end ());
@@ -45,6 +44,4 @@ int main()
test<std::complex<double>> ();
test<std::string> ();
}
-#else
-int main() {}
-#endif
+
diff --git a/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp b/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp
new file mode 100644
index 0000000000000..94de2108f8b59
--- /dev/null
+++ b/test/libcxx/experimental/filesystem/class.path/path.req/is_pathable.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/filesystem>
+
+// template <class Tp> struct __is_pathable
+
+// [path.req]
+// In addition to the requirements (5), function template parameters named
+// `Source` shall be one of:
+// * basic_string<_ECharT, _Traits, _Alloc>
+// * InputIterator with a value_type of _ECharT
+// * A character array, which points to a NTCTS after array-to-pointer decay.
+
+
+#include <experimental/filesystem>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+namespace fs = std::experimental::filesystem;
+
+using fs::__is_pathable;
+
+template <class Tp>
+struct Identity { typedef Tp type; };
+
+template <class Source>
+Identity<Source> CheckSourceType(Source const&);
+
+template <class Tp>
+using GetSourceType = typename decltype(CheckSourceType(std::declval<Tp>()))::type;
+
+template <class Tp, class Exp,
+ class ExpQual = typename std::remove_const<Exp>::type>
+using CheckPass = std::is_same<ExpQual, GetSourceType<Tp>>;
+
+template <class Source>
+using CheckPassSource = std::integral_constant<bool,
+ CheckPass<Source&, Source>::value &&
+ CheckPass<Source const&, Source>::value &&
+ CheckPass<Source&&, Source>::value &&
+ CheckPass<Source const&&, Source>::value
+ >;
+
+template <class CharT>
+struct MakeTestType {
+ using value_type = CharT;
+ using string_type = std::basic_string<CharT>;
+ using string_type2 = std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>;
+ using cstr_type = CharT* const;
+ using const_cstr_type = const CharT*;
+ using array_type = CharT[25];
+ using const_array_type = const CharT[25];
+ using iter_type = input_iterator<CharT*>;
+ using bad_iter_type = input_iterator<signed char*>;
+
+ template <class TestT>
+ static void AssertPathable() {
+ static_assert(__is_pathable<TestT>::value, "");
+ static_assert(CheckPassSource<TestT>::value, "cannot pass as Source const&");
+ ASSERT_SAME_TYPE(CharT, typename __is_pathable<TestT>::__char_type);
+ }
+
+ template <class TestT>
+ static void AssertNotPathable() {
+ static_assert(!__is_pathable<TestT>::value, "");
+ }
+
+ static void Test() {
+ AssertPathable<string_type>();
+ AssertPathable<string_type2>();
+ AssertPathable<cstr_type>();
+ AssertPathable<const_cstr_type>();
+ AssertPathable<array_type>();
+ AssertPathable<const_array_type>();
+ AssertPathable<iter_type>();
+
+ AssertNotPathable<CharT>();
+ AssertNotPathable<bad_iter_type>();
+ AssertNotPathable<signed char*>();
+ }
+};
+
+int main() {
+ MakeTestType<char>::Test();
+ MakeTestType<wchar_t>::Test();
+ MakeTestType<char16_t>::Test();
+ MakeTestType<char32_t>::Test();
+}
diff --git a/test/libcxx/experimental/filesystem/lit.local.cfg b/test/libcxx/experimental/filesystem/lit.local.cfg
new file mode 100644
index 0000000000000..3d9360431f486
--- /dev/null
+++ b/test/libcxx/experimental/filesystem/lit.local.cfg
@@ -0,0 +1,3 @@
+# Disable all of the filesystem tests if the correct feature is not available.
+if 'c++filesystem' not in config.available_features:
+ config.unsupported = True
diff --git a/test/libcxx/experimental/filesystem/version.pass.cpp b/test/libcxx/experimental/filesystem/version.pass.cpp
new file mode 100644
index 0000000000000..723380a26fbae
--- /dev/null
+++ b/test/libcxx/experimental/filesystem/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/filesystem>
+
+#include <experimental/filesystem>
+
+#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
new file mode 100644
index 0000000000000..83b3041963719
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp
@@ -0,0 +1,178 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/memory_resource>
+
+// template <class T> class polymorphic_allocator
+
+// template <class U1, class U2, class ...Args1, class ...Args2>
+// void polymorphic_allocator<T>::construct(pair<T1, T2>*, piecewise_construct_t
+// tuple<Args1...> x, tuple<Args2...>)
+
+// The stardard specifiers a tranformation to uses-allocator construction as
+// follows:
+// - If uses_allocator_v<T1,memory_resource*> is false and
+// is_constructible_v<T,Args1...> is true, then xprime is x.
+// - Otherwise, if uses_allocator_v<T1,memory_resource*> is true and
+// is_constructible_v<T1,allocator_arg_t,memory_resource*,Args1...> is true,
+// then xprime is
+// tuple_cat(make_tuple(allocator_arg, this->resource()), std::move(x)).
+// - Otherwise, if uses_allocator_v<T1,memory_resource*> is true and
+// is_constructible_v<T1,Args1...,memory_resource*> is true, then xprime is
+// tuple_cat(std::move(x), make_tuple(this->resource())).
+// - Otherwise the program is ill formed.
+//
+// The use of "xprime = tuple_cat(..., std::move(x), ...)" causes all of the
+// objects in 'x' to be copied into 'xprime'. If 'x' contains any types which
+// are stored by value this causes an unessary copy to occur. To prevent this
+// libc++ changes this call into
+// "xprime = forward_as_tuple(..., std::get<Idx>(std::move(x))..., ...)".
+// 'xprime' contains references to the values in 'x' instead of copying them.
+
+// This test checks the number of copies incurred to the elements in
+// 'tuple<Args1...>' and 'tuple<Args2...>'.
+
+#include <experimental/memory_resource>
+#include <type_traits>
+#include <utility>
+#include <tuple>
+#include <cassert>
+#include <cstdlib>
+#include "test_memory_resource.hpp"
+
+namespace ex = std::experimental::pmr;
+
+template <class T>
+struct TestHarness {
+ TestResource R;
+ ex::memory_resource * M = &R;
+ ex::polymorphic_allocator<T> A = M;
+ bool constructed = false;
+ T * ptr;
+
+ TestHarness() : ptr(A.allocate(1)) {}
+
+ template <class ...Args>
+ void construct(Args&&... args) {
+ A.construct(ptr, std::forward<Args>(args)...);
+ constructed = true;
+ }
+
+ ~TestHarness() {
+ if (constructed) A.destroy(ptr);
+ A.deallocate(ptr, 1);
+ }
+};
+
+struct CountCopies {
+ int count;
+ CountCopies() : count(0) {}
+ CountCopies(CountCopies const& o) : count(o.count + 1) {}
+};
+
+struct CountCopiesAllocV1 {
+ typedef ex::memory_resource* allocator_type;
+ allocator_type alloc;
+ int count;
+ CountCopiesAllocV1() : alloc(nullptr), count(0) {}
+ CountCopiesAllocV1(std::allocator_arg_t, allocator_type const& a,
+ CountCopiesAllocV1 const& o) : alloc(a), count(o.count + 1)
+ {}
+
+ CountCopiesAllocV1(CountCopiesAllocV1 const& o) : count(o.count + 1) {}
+};
+
+
+struct CountCopiesAllocV2 {
+ typedef ex::memory_resource* allocator_type;
+ allocator_type alloc;
+ int count;
+ CountCopiesAllocV2() : alloc(nullptr), count(0) {}
+ CountCopiesAllocV2(CountCopiesAllocV2 const& o, allocator_type const& a)
+ : alloc(a), count(o.count + 1)
+ { }
+
+ CountCopiesAllocV2(CountCopiesAllocV2 const& o) : count(o.count + 1) {}
+};
+
+
+int main()
+{
+ using PMR = ex::memory_resource*;
+ using PMA = ex::polymorphic_allocator<char>;
+
+ {
+ using T = CountCopies;
+ using U = CountCopiesAllocV1;
+ using P = std::pair<T, U>;
+ using TH = TestHarness<P>;
+
+ std::tuple<T> t1;
+ std::tuple<U> t2;
+
+ TestHarness<P> h;
+ h.construct(std::piecewise_construct, t1, t2);
+ P const& p = *h.ptr;
+ assert(p.first.count == 2);
+ assert(p.second.count == 2);
+ assert(p.second.alloc == h.M);
+ }
+ {
+ using T = CountCopiesAllocV1;
+ using U = CountCopiesAllocV2;
+ using P = std::pair<T, U>;
+ using TH = TestHarness<P>;
+
+ std::tuple<T> t1;
+ std::tuple<U> t2;
+
+ TestHarness<P> h;
+ h.construct(std::piecewise_construct, std::move(t1), std::move(t2));
+ P const& p = *h.ptr;
+ assert(p.first.count == 2);
+ assert(p.first.alloc == h.M);
+ assert(p.second.count == 2);
+ assert(p.second.alloc == h.M);
+ }
+ {
+ using T = CountCopiesAllocV2;
+ using U = CountCopiesAllocV1;
+ using P = std::pair<T, U>;
+ using TH = TestHarness<P>;
+
+ std::tuple<T> t1;
+ std::tuple<U> t2;
+
+ TestHarness<P> h;
+ h.construct(std::piecewise_construct, std::move(t1), std::move(t2));
+ P const& p = *h.ptr;
+ assert(p.first.count == 2);
+ assert(p.first.alloc == h.M);
+ assert(p.second.count == 2);
+ assert(p.second.alloc == h.M);
+ }
+ {
+ using T = CountCopiesAllocV2;
+ using U = CountCopies;
+ using P = std::pair<T, U>;
+ using TH = TestHarness<P>;
+
+ std::tuple<T> t1;
+ std::tuple<U> t2;
+
+ TestHarness<P> h;
+ h.construct(std::piecewise_construct, t1, t2);
+ P const& p = *h.ptr;
+ assert(p.first.count == 2);
+ assert(p.first.alloc == h.M);
+ assert(p.second.count == 2);
+ }
+}
diff --git a/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp
new file mode 100644
index 0000000000000..020133fc40481
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/db_deallocate.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/memory_resource>
+
+// template <class T> class polymorphic_allocator
+
+// T* polymorphic_allocator<T>::deallocate(T*, size_t size)
+
+int AssertCount = 0;
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
+#define _LIBCPP_DEBUG 0
+#include <experimental/memory_resource>
+#include <type_traits>
+#include <cassert>
+
+#include "test_memory_resource.hpp"
+
+namespace ex = std::experimental::pmr;
+
+int main()
+{
+ using Alloc = ex::polymorphic_allocator<int>;
+ using Traits = std::allocator_traits<Alloc>;
+ NullResource R;
+ Alloc a(&R);
+ const std::size_t maxSize = Traits::max_size(a);
+
+ a.deallocate(nullptr, maxSize);
+ assert(AssertCount == 0);
+ a.deallocate(nullptr, maxSize + 1);
+ assert(AssertCount == 1);
+}
diff --git a/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp
new file mode 100644
index 0000000000000..ac685a99be494
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/max_size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/memory_resource>
+
+// template <class T> class polymorphic_allocator
+
+// EXTENSION
+// std::size_t polymorphic_allocator<T>::max_size() const noexcept
+
+#include <experimental/memory_resource>
+#include <type_traits>
+#include <cassert>
+
+#include "test_memory_resource.hpp"
+
+namespace ex = std::experimental::pmr;
+
+template <std::size_t S>
+std::size_t getMaxSize() {
+ using T = typename std::aligned_storage<S>::type;
+ static_assert(sizeof(T) == S, "Required for test");
+ return ex::polymorphic_allocator<T>{}.max_size();
+}
+
+template <std::size_t S, std::size_t A>
+std::size_t getMaxSize() {
+ using T = typename std::aligned_storage<S, A>::type;
+ static_assert(sizeof(T) == S, "Required for test");
+ return ex::polymorphic_allocator<T>{}.max_size();
+}
+
+int main()
+{
+ {
+ using Alloc = ex::polymorphic_allocator<int>;
+ using Traits = std::allocator_traits<Alloc>;
+ const Alloc a;
+ static_assert(std::is_same<decltype(a.max_size()), Traits::size_type>::value, "");
+ static_assert(noexcept(a.max_size()), "");
+ }
+ {
+ constexpr std::size_t Max = std::numeric_limits<std::size_t>::max();
+ assert(getMaxSize<1>() == Max);
+ assert(getMaxSize<2>() == Max / 2);
+ assert(getMaxSize<4>() == Max / 4);
+ assert(getMaxSize<8>() == Max / 8);
+ assert(getMaxSize<16>() == Max / 16);
+ assert(getMaxSize<32>() == Max / 32);
+ assert(getMaxSize<64>() == Max / 64);
+ assert(getMaxSize<1024>() == Max / 1024);
+
+ assert((getMaxSize<6, 2>() == Max / 6));
+ assert((getMaxSize<12, 4>() == Max / 12));
+ }
+}
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
new file mode 100644
index 0000000000000..ccb9b710e5dcd
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/db_deallocate.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/memory_resource>
+
+// template <class T> class polymorphic_allocator
+
+// T* polymorphic_allocator<T>::deallocate(T*, size_t size)
+
+int AssertCount = 0;
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
+#define _LIBCPP_DEBUG 0
+#include <experimental/memory_resource>
+#include <type_traits>
+#include <cassert>
+
+#include "test_memory_resource.hpp"
+
+namespace ex = std::experimental::pmr;
+
+int main()
+{
+ using Alloc = NullAllocator<char>;
+ using R = ex::resource_adaptor<Alloc>;
+ AllocController P;
+ ex::resource_adaptor<Alloc> r(Alloc{P});
+ ex::memory_resource & m1 = r;
+
+ std::size_t maxSize = std::numeric_limits<std::size_t>::max()
+ - alignof(std::max_align_t);
+
+ m1.deallocate(nullptr, maxSize);
+ assert(AssertCount == 0);
+ m1.deallocate(nullptr, maxSize + 1);
+ assert(AssertCount >= 1);
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_deque_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_deque_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..04b361dfe5a43
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_deque_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/deque>
+
+#include <experimental/deque>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_forward_list_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_forward_list_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..11fc21b3b03cb
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_forward_list_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/forward_list>
+
+#include <experimental/forward_list>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_list_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_list_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..9a72979e0af04
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_list_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/list>
+
+#include <experimental/list>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_map_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_map_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..24a1bf3042c1a
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_map_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/map>
+
+#include <experimental/map>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_regex_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_regex_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..ff81bc09b850d
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_regex_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/regex>
+
+#include <experimental/regex>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_set_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_set_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..6b02f46b4f73c
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_set_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/set>
+
+#include <experimental/set>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_string_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_string_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..b4b7fdf10f592
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_string_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/string>
+
+#include <experimental/string>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_map_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_map_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..ab9cc189b73d0
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_map_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/unordered_map>
+
+#include <experimental/unordered_map>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_set_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_set_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..37533c7fd87c4
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_unordered_set_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/unordered_set>
+
+#include <experimental/unordered_set>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.aliases/header_vector_libcpp_version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.aliases/header_vector_libcpp_version.pass.cpp
new file mode 100644
index 0000000000000..103d32becf9c1
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.aliases/header_vector_libcpp_version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/vector>
+
+#include <experimental/vector>
+
+#ifndef _LIBCPP_VERSION
+#error header must provide _LIBCPP_VERSION
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp b/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp
new file mode 100644
index 0000000000000..341a88c0bab12
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/memory_resource>
+
+// memory_resource * new_delete_resource()
+
+// The lifetime of the value returned by 'new_delete_resource()' should
+// never end, even very late into program termination. This test constructs
+// attempts to use 'new_delete_resource()' very late in program termination
+// to detect lifetime issues.
+
+#include <experimental/memory_resource>
+#include <type_traits>
+#include <cassert>
+
+namespace ex = std::experimental::pmr;
+
+struct POSType {
+ ex::memory_resource* res = nullptr;
+ void* ptr = nullptr;
+ int n = 0;
+ POSType() {}
+ POSType(ex::memory_resource* r, void* p, int s) : res(r), ptr(p), n(s) {}
+ ~POSType() {
+ if (ptr) {
+ if (!res) res = ex::get_default_resource();
+ res->deallocate(ptr, n);
+ }
+ }
+};
+
+void swap(POSType & L, POSType & R) {
+ std::swap(L.res, R.res);
+ std::swap(L.ptr, R.ptr);
+ std::swap(L.n, R.n);
+}
+
+POSType constructed_before_resources;
+POSType constructed_before_resources2;
+
+// Constructs resources
+ex::memory_resource* resource = ex::get_default_resource();
+
+POSType constructed_after_resources(resource, resource->allocate(1024), 1024);
+POSType constructed_after_resources2(nullptr, resource->allocate(1024), 1024);
+
+int main()
+{
+ swap(constructed_after_resources, constructed_before_resources);
+ swap(constructed_before_resources2, constructed_after_resources2);
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp b/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp
new file mode 100644
index 0000000000000..9b92d02bc4374
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: c++experimental
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/memory_resource>
+
+// memory_resource * new_delete_resource()
+
+// The lifetime of the value returned by 'new_delete_resource()' should
+// never end, even very late into program termination. This test constructs
+// attempts to use 'new_delete_resource()' very late in program termination
+// to detect lifetime issues.
+
+#include <experimental/memory_resource>
+#include <type_traits>
+#include <cassert>
+
+namespace ex = std::experimental::pmr;
+
+struct POSType {
+ ex::memory_resource* res = nullptr;
+ void* ptr = nullptr;
+ int n = 0;
+ POSType() {res = ex::new_delete_resource(); ptr = res->allocate(42); n = 42; }
+ POSType(ex::memory_resource* r, void* p, int s) : res(r), ptr(p), n(s) {}
+ ~POSType() { if (ptr) res->deallocate(ptr, n); }
+};
+
+void swap(POSType & L, POSType & R) {
+ std::swap(L.res, R.res);
+ std::swap(L.ptr, R.ptr);
+ std::swap(L.n, R.n);
+}
+
+POSType constructed_before_resources;
+
+// Constructs resources
+ex::memory_resource* resource = ex::new_delete_resource();
+
+POSType constructed_after_resources(resource, resource->allocate(1024), 1024);
+
+int main()
+{
+ swap(constructed_after_resources, constructed_before_resources);
+}
diff --git a/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp b/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp
new file mode 100644
index 0000000000000..d05575e8849e5
--- /dev/null
+++ b/test/libcxx/experimental/memory/memory.resource.synop/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <experimental/memory_resource>
+
+#include <experimental/memory_resource>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/optional/version.pass.cpp b/test/libcxx/experimental/optional/version.pass.cpp
new file mode 100644
index 0000000000000..585b7a24eea5a
--- /dev/null
+++ b/test/libcxx/experimental/optional/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+#include <experimental/optional>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/meta/version.pass.cpp b/test/libcxx/experimental/utilities/meta/version.pass.cpp
new file mode 100644
index 0000000000000..593fb52a4c3b2
--- /dev/null
+++ b/test/libcxx/experimental/utilities/meta/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/type_traits>
+
+#include <experimental/type_traits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp b/test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp
index db9026aebd84f..ea7ef6cbc1088 100644
--- a/test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp
+++ b/test/libcxx/experimental/utilities/ratio/header.ratio.synop/includes.pass.cpp
@@ -7,16 +7,15 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// <experimental/ratio>
// Test that <ratio> is included.
#include <experimental/ratio>
-#if _LIBCPP_STD_VER > 11
-# ifndef _LIBCPP_RATIO
-# error " <experimental/ratio> must include <ratio>"
-# endif
+#ifndef _LIBCPP_RATIO
+# error " <experimental/ratio> must include <ratio>"
#endif
int main()
diff --git a/test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp b/test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp
index 88c7458395d4b..be3aacdc362ca 100644
--- a/test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp
+++ b/test/libcxx/experimental/utilities/syserror/header.system_error.synop/includes.pass.cpp
@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// <experimental/system_error>
#include <experimental/system_error>
-#if _LIBCPP_STD_VER > 11
-# ifndef _LIBCPP_SYSTEM_ERROR
-# error "<experimental/system_error> must include <system_error>"
-# endif
+#ifndef _LIBCPP_SYSTEM_ERROR
+# error "<experimental/system_error> must include <system_error>"
#endif
int main()
diff --git a/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp b/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
index ad4a79105b0b8..e91068c742e18 100644
--- a/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
+++ b/test/libcxx/experimental/utilities/time/header.chrono.synop/includes.pass.cpp
@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// <experimental/chrono>
#include <experimental/chrono>
-#if _LIBCPP_STD_VER > 11
-# ifndef _LIBCPP_CHRONO
-# error "<experimental/chrono> must include <chrono>"
-# endif
+#ifndef _LIBCPP_CHRONO
+# error "<experimental/chrono> must include <chrono>"
#endif
int main()
diff --git a/test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp b/test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp
index 544ddfb269f2c..defa454d68f75 100644
--- a/test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp
+++ b/test/libcxx/experimental/utilities/tuple/header.tuple.synop/includes.pass.cpp
@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
// <experimental/tuple>
#include <experimental/tuple>
int main()
{
-#if _LIBCPP_STD_VER > 11
-# ifndef _LIBCPP_TUPLE
-# error "<experimental/tuple> must include <tuple>"
-# endif
-#endif /* _LIBCPP_STD_VER > 11 */
+#ifndef _LIBCPP_TUPLE
+# error "<experimental/tuple> must include <tuple>"
+#endif
}
diff --git a/test/libcxx/experimental/utilities/utility/version.pass.cpp b/test/libcxx/experimental/utilities/utility/version.pass.cpp
new file mode 100644
index 0000000000000..437712454ae5c
--- /dev/null
+++ b/test/libcxx/experimental/utilities/utility/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/utility>
+
+#include <experimental/utility>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/extensions/hash/specializations.fail.cpp b/test/libcxx/extensions/hash/specializations.fail.cpp
new file mode 100644
index 0000000000000..8eeffb5802e72
--- /dev/null
+++ b/test/libcxx/extensions/hash/specializations.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <assert.h>
+#include <ext/hash_map>
+#include <string>
+
+int main()
+{
+ assert(__gnu_cxx::hash<std::string>()(std::string()) == 0); // error
+}
diff --git a/test/libcxx/extensions/hash/specializations.pass.cpp b/test/libcxx/extensions/hash/specializations.pass.cpp
new file mode 100644
index 0000000000000..a222b1eb5c6d0
--- /dev/null
+++ b/test/libcxx/extensions/hash/specializations.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.
+//
+//===----------------------------------------------------------------------===//
+
+// NOTE: Undefined __DEPRECATED to prevent this test from failing with -Werror
+#undef __DEPRECATED
+#include <assert.h>
+#include <ext/hash_map>
+#include <string>
+
+int main()
+{
+ char str[] = "test";
+ assert(__gnu_cxx::hash<const char *>()("test") ==
+ std::hash<std::string>()("test"));
+ assert(__gnu_cxx::hash<char *>()(str) == std::hash<std::string>()("test"));
+ assert(__gnu_cxx::hash<char>()(42) == 42);
+ assert(__gnu_cxx::hash<signed char>()(42) == 42);
+ assert(__gnu_cxx::hash<unsigned char>()(42) == 42);
+ assert(__gnu_cxx::hash<short>()(42) == 42);
+ assert(__gnu_cxx::hash<unsigned short>()(42) == 42);
+ assert(__gnu_cxx::hash<int>()(42) == 42);
+ assert(__gnu_cxx::hash<unsigned int>()(42) == 42);
+ assert(__gnu_cxx::hash<long>()(42) == 42);
+ assert(__gnu_cxx::hash<unsigned long>()(42) == 42);
+}
diff --git a/test/libcxx/extensions/hash_map/const_iterator.fail.cpp b/test/libcxx/extensions/hash_map/const_iterator.fail.cpp
new file mode 100644
index 0000000000000..e4c536e8f33ab
--- /dev/null
+++ b/test/libcxx/extensions/hash_map/const_iterator.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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <ext/hash_map>
+
+int main()
+{
+ __gnu_cxx::hash_map<int, int> m;
+ m[1] = 1;
+ const __gnu_cxx::hash_map<int, int> &cm = m;
+ cm.find(1)->second = 2; // error
+}
diff --git a/test/libcxx/extensions/nothing_to_do.pass.cpp b/test/libcxx/extensions/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/libcxx/extensions/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/input.output/file.streams/c.files/version_ccstdio.pass.cpp b/test/libcxx/input.output/file.streams/c.files/version_ccstdio.pass.cpp
new file mode 100644
index 0000000000000..0d7fc5605324b
--- /dev/null
+++ b/test/libcxx/input.output/file.streams/c.files/version_ccstdio.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdio>
+
+#include <cstdio>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/file.streams/c.files/version_cinttypes.pass.cpp b/test/libcxx/input.output/file.streams/c.files/version_cinttypes.pass.cpp
new file mode 100644
index 0000000000000..bfd379e43493b
--- /dev/null
+++ b/test/libcxx/input.output/file.streams/c.files/version_cinttypes.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cinttypes>
+
+#include <cinttypes>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/file.streams/fstreams/version.pass.cpp b/test/libcxx/input.output/file.streams/fstreams/version.pass.cpp
new file mode 100644
index 0000000000000..44b851416808c
--- /dev/null
+++ b/test/libcxx/input.output/file.streams/fstreams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+#include <fstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/iostream.format/input.streams/version.pass.cpp b/test/libcxx/input.output/iostream.format/input.streams/version.pass.cpp
new file mode 100644
index 0000000000000..b03ef2aaa04e0
--- /dev/null
+++ b/test/libcxx/input.output/iostream.format/input.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+#include <istream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/iostream.format/output.streams/version.pass.cpp b/test/libcxx/input.output/iostream.format/output.streams/version.pass.cpp
new file mode 100644
index 0000000000000..662b6987b3c81
--- /dev/null
+++ b/test/libcxx/input.output/iostream.format/output.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+#include <ostream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/iostream.format/std.manip/version.pass.cpp b/test/libcxx/input.output/iostream.format/std.manip/version.pass.cpp
new file mode 100644
index 0000000000000..ca4fd3d463eeb
--- /dev/null
+++ b/test/libcxx/input.output/iostream.format/std.manip/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+#include <iomanip>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/iostream.forward/version.pass.cpp b/test/libcxx/input.output/iostream.forward/version.pass.cpp
new file mode 100644
index 0000000000000..cf91332d55977
--- /dev/null
+++ b/test/libcxx/input.output/iostream.forward/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iosfwd>
+
+#include <iosfwd>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/iostream.objects/version.pass.cpp b/test/libcxx/input.output/iostream.objects/version.pass.cpp
new file mode 100644
index 0000000000000..09b3611f6df92
--- /dev/null
+++ b/test/libcxx/input.output/iostream.objects/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+#include <iostream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/iostreams.base/version.pass.cpp b/test/libcxx/input.output/iostreams.base/version.pass.cpp
new file mode 100644
index 0000000000000..f56846d38b8db
--- /dev/null
+++ b/test/libcxx/input.output/iostreams.base/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+#include <ios>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/stream.buffers/version.pass.cpp b/test/libcxx/input.output/stream.buffers/version.pass.cpp
new file mode 100644
index 0000000000000..c4b06be601871
--- /dev/null
+++ b/test/libcxx/input.output/stream.buffers/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+#include <streambuf>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/input.output/string.streams/version.pass.cpp b/test/libcxx/input.output/string.streams/version.pass.cpp
new file mode 100644
index 0000000000000..103897106d37c
--- /dev/null
+++ b/test/libcxx/input.output/string.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+#include <sstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/iterators/trivial_iterators.pass.cpp b/test/libcxx/iterators/trivial_iterators.pass.cpp
index 0b7a47316d65f..33c8302517694 100644
--- a/test/libcxx/iterators/trivial_iterators.pass.cpp
+++ b/test/libcxx/iterators/trivial_iterators.pass.cpp
@@ -13,7 +13,7 @@
// __libcpp_is_trivial_iterator<Tp>
// __libcpp_is_trivial_iterator determines if an iterator is a "trivial" one,
-// that can be used w/o worrying about its operations throwing exceptions.
+// that can be used w/o worrying about its operations throwing exceptions.
// Pointers are trivial iterators. Libc++ has three "iterator wrappers":
// reverse_iterator, move_iterator, and __wrap_iter. If the underlying iterator
// is trivial, then those are as well.
@@ -113,16 +113,16 @@ int main()
static_assert(( std::__libcpp_is_trivial_iterator<std::__wrap_iter<int *> > ::value), "");
static_assert(( std::__libcpp_is_trivial_iterator<std::__wrap_iter<T *> > ::value), "");
- static_assert(( std::__libcpp_is_trivial_iterator<std::reverse_iterator<std::__wrap_iter<char *> > > ::value), "");
-
+ static_assert(( std::__libcpp_is_trivial_iterator<std::reverse_iterator<std::__wrap_iter<char *> > > ::value), "");
+
// iterators in the libc++ test suite
- static_assert((!std::__libcpp_is_trivial_iterator<output_iterator <char *> >::value), "");
- static_assert((!std::__libcpp_is_trivial_iterator<input_iterator <char *> >::value), "");
- static_assert((!std::__libcpp_is_trivial_iterator<forward_iterator <char *> >::value), "");
- static_assert((!std::__libcpp_is_trivial_iterator<bidirectional_iterator<char *> >::value), "");
- static_assert((!std::__libcpp_is_trivial_iterator<random_access_iterator<char *> >::value), "");
- static_assert((!std::__libcpp_is_trivial_iterator<ThrowingIterator <char *> >::value), "");
- static_assert((!std::__libcpp_is_trivial_iterator<NonThrowingIterator <char *> >::value), "");
+ static_assert((!std::__libcpp_is_trivial_iterator<output_iterator <char *> >::value), "");
+ static_assert((!std::__libcpp_is_trivial_iterator<input_iterator <char *> >::value), "");
+ static_assert((!std::__libcpp_is_trivial_iterator<forward_iterator <char *> >::value), "");
+ static_assert((!std::__libcpp_is_trivial_iterator<bidirectional_iterator<char *> >::value), "");
+ static_assert((!std::__libcpp_is_trivial_iterator<random_access_iterator<char *> >::value), "");
+ static_assert((!std::__libcpp_is_trivial_iterator<ThrowingIterator <char *> >::value), "");
+ static_assert((!std::__libcpp_is_trivial_iterator<NonThrowingIterator <char *> >::value), "");
// Iterator classification
@@ -137,7 +137,7 @@ int main()
static_assert((!std::__is_bidirectional_iterator<input_iterator<char *> >::value), "" );
static_assert((!std::__is_random_access_iterator<input_iterator<char *> >::value), "" );
static_assert(( std::__is_exactly_input_iterator<input_iterator<char *> >::value), "" );
-
+
static_assert(( std::__is_input_iterator <forward_iterator<char *> >::value), "" );
static_assert(( std::__is_forward_iterator <forward_iterator<char *> >::value), "" );
static_assert((!std::__is_bidirectional_iterator<forward_iterator<char *> >::value), "" );
@@ -171,7 +171,7 @@ int main()
static_assert(( std::__libcpp_is_trivial_iterator<std::vector<char>::const_iterator> ::value), "");
static_assert(( std::__libcpp_is_trivial_iterator<std::vector<char>::reverse_iterator> ::value), "");
static_assert(( std::__libcpp_is_trivial_iterator<std::vector<char>::const_reverse_iterator>::value), "");
-
+
// vector
static_assert(( std::__libcpp_is_trivial_iterator<std::basic_string<char>::iterator> ::value), "");
static_assert(( std::__libcpp_is_trivial_iterator<std::basic_string<char>::const_iterator> ::value), "");
diff --git a/test/libcxx/iterators/version.pass.cpp b/test/libcxx/iterators/version.pass.cpp
new file mode 100644
index 0000000000000..dd097850388e5
--- /dev/null
+++ b/test/libcxx/iterators/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+#include <iterator>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/cstdint/version.pass.cpp b/test/libcxx/language.support/cstdint/version.pass.cpp
new file mode 100644
index 0000000000000..4c9a43a62abc0
--- /dev/null
+++ b/test/libcxx/language.support/cstdint/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdint>
+
+#include <cstdint>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
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
new file mode 100644
index 0000000000000..cc99b83aca4e9
--- /dev/null
+++ b/test/libcxx/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// test bad_array_length
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::bad_alloc, std::bad_array_length>::value),
+ "std::is_base_of<std::bad_alloc, std::bad_array_length>::value");
+ static_assert(std::is_polymorphic<std::bad_array_length>::value,
+ "std::is_polymorphic<std::bad_array_length>::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/version.pass.cpp b/test/libcxx/language.support/support.dynamic/version.pass.cpp
new file mode 100644
index 0000000000000..ba1ff518e51f0
--- /dev/null
+++ b/test/libcxx/language.support/support.dynamic/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <new>
+
+#include <new>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.exception/version.pass.cpp b/test/libcxx/language.support/support.exception/version.pass.cpp
new file mode 100644
index 0000000000000..acdedbb31fe32
--- /dev/null
+++ b/test/libcxx/language.support/support.exception/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+#include <exception>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.initlist/version.pass.cpp b/test/libcxx/language.support/support.initlist/version.pass.cpp
new file mode 100644
index 0000000000000..f3f08cd1f864e
--- /dev/null
+++ b/test/libcxx/language.support/support.initlist/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+#include <initializer_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.limits/c.limits/version_cfloat.pass.cpp b/test/libcxx/language.support/support.limits/c.limits/version_cfloat.pass.cpp
new file mode 100644
index 0000000000000..19b463199cd61
--- /dev/null
+++ b/test/libcxx/language.support/support.limits/c.limits/version_cfloat.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cfloat>
+
+#include <cfloat>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.limits/c.limits/version_climits.pass.cpp b/test/libcxx/language.support/support.limits/c.limits/version_climits.pass.cpp
new file mode 100644
index 0000000000000..3fe07a5174b30
--- /dev/null
+++ b/test/libcxx/language.support/support.limits/c.limits/version_climits.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <climits>
+
+#include <climits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.limits/limits/version.pass.cpp b/test/libcxx/language.support/support.limits/limits/version.pass.cpp
new file mode 100644
index 0000000000000..0cb3f6f52a4e6
--- /dev/null
+++ b/test/libcxx/language.support/support.limits/limits/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <limits>
+
+#include <limits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.rtti/version.pass.cpp b/test/libcxx/language.support/support.rtti/version.pass.cpp
new file mode 100644
index 0000000000000..0a9ece34f97ea
--- /dev/null
+++ b/test/libcxx/language.support/support.rtti/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeinfo>
+
+#include <typeinfo>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.runtime/version_csetjmp.pass.cpp b/test/libcxx/language.support/support.runtime/version_csetjmp.pass.cpp
new file mode 100644
index 0000000000000..7e37716d01459
--- /dev/null
+++ b/test/libcxx/language.support/support.runtime/version_csetjmp.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <csetjmp>
+
+#include <csetjmp>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.runtime/version_csignal.pass.cpp b/test/libcxx/language.support/support.runtime/version_csignal.pass.cpp
new file mode 100644
index 0000000000000..be1045f1eb3b1
--- /dev/null
+++ b/test/libcxx/language.support/support.runtime/version_csignal.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <csignal>
+
+#include <csignal>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.runtime/version_cstdarg.pass.cpp b/test/libcxx/language.support/support.runtime/version_cstdarg.pass.cpp
new file mode 100644
index 0000000000000..f3ca9389b15d2
--- /dev/null
+++ b/test/libcxx/language.support/support.runtime/version_cstdarg.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdarg>
+
+#include <cstdarg>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.runtime/version_cstdbool.pass.cpp b/test/libcxx/language.support/support.runtime/version_cstdbool.pass.cpp
new file mode 100644
index 0000000000000..0415227e58ead
--- /dev/null
+++ b/test/libcxx/language.support/support.runtime/version_cstdbool.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdbool>
+
+#include <cstdbool>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.runtime/version_cstdlib.pass.cpp b/test/libcxx/language.support/support.runtime/version_cstdlib.pass.cpp
new file mode 100644
index 0000000000000..db419524f5783
--- /dev/null
+++ b/test/libcxx/language.support/support.runtime/version_cstdlib.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdlib>
+
+#include <cstdlib>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.runtime/version_ctime.pass.cpp b/test/libcxx/language.support/support.runtime/version_ctime.pass.cpp
new file mode 100644
index 0000000000000..ce0bf2cf1853c
--- /dev/null
+++ b/test/libcxx/language.support/support.runtime/version_ctime.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctime>
+
+#include <ctime>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/language.support/support.types/version.pass.cpp b/test/libcxx/language.support/support.types/version.pass.cpp
new file mode 100644
index 0000000000000..2ab7c188de1d8
--- /dev/null
+++ b/test/libcxx/language.support/support.types/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstddef>
+
+#include <cstddef>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/localization/c.locales/version.pass.cpp b/test/libcxx/localization/c.locales/version.pass.cpp
new file mode 100644
index 0000000000000..0fce59e2b0b84
--- /dev/null
+++ b/test/libcxx/localization/c.locales/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <clocale>
+
+#include <clocale>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp b/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp
new file mode 100644
index 0000000000000..b33aab9a730a6
--- /dev/null
+++ b/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// Not a portable test
+
+// __scan_keyword
+// Scans [__b, __e) until a match is found in the basic_strings range
+// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
+// __b will be incremented (visibly), consuming CharT until a match is found
+// or proved to not exist. A keyword may be "", in which will match anything.
+// If one keyword is a prefix of another, and the next CharT in the input
+// might match another keyword, the algorithm will attempt to find the longest
+// matching keyword. If the longer matching keyword ends up not matching, then
+// no keyword match is found. If no keyword match is found, __ke is returned.
+// Else an iterator pointing to the matching keyword is found. If more than
+// one keyword matches, an iterator to the first matching keyword is returned.
+// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false,
+// __ct is used to force to lower case before comparing characters.
+// Examples:
+// Keywords: "a", "abb"
+// If the input is "a", the first keyword matches and eofbit is set.
+// If the input is "abc", no match is found and "ab" are consumed.
+//
+// template <class _InputIterator, class _ForwardIterator, class _Ctype>
+// _ForwardIterator
+// __scan_keyword(_InputIterator& __b, _InputIterator __e,
+// _ForwardIterator __kb, _ForwardIterator __ke,
+// const _Ctype& __ct, ios_base::iostate& __err,
+// bool __case_sensitive = true);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+ const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic());
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ {
+ const char input[] = "a";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 0);
+ assert(in == input+1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char input[] = "abc";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 2);
+ assert(in == input+2);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const char input[] = "abb";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 1);
+ assert(in == input+3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char input[] = "Tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 2);
+ assert(in == input+3);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const char input[] = "tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err);
+ assert(k - keys == 4);
+ assert(in == input+0);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const char input[] = "tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+ keys, keys+sizeof(keys)/sizeof(keys[0]),
+ ct, err, false);
+ assert(k - keys == 2);
+ assert(in == input+3);
+ assert(err == std::ios_base::goodbit);
+ }
+}
diff --git a/test/libcxx/localization/locale.stdcvt/version.pass.cpp b/test/libcxx/localization/locale.stdcvt/version.pass.cpp
new file mode 100644
index 0000000000000..3885380854cc4
--- /dev/null
+++ b/test/libcxx/localization/locale.stdcvt/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+#include <codecvt>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp b/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp
new file mode 100644
index 0000000000000..75e2aeb064eb4
--- /dev/null
+++ b/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wstring_convert(wstring_convert&& other); // EXTENSION
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+ typedef std::codecvt_utf8<wchar_t> Codecvt;
+ typedef std::wstring_convert<Codecvt> Myconv;
+ // create a converter and perform some conversions to generate some
+ // interesting state.
+ Myconv myconv;
+ myconv.from_bytes("\xF1\x80\x80\x83");
+ const int old_converted = myconv.converted();
+ assert(myconv.converted() == 4);
+ // move construct a new converter and make sure the state is the same.
+ Myconv myconv2(std::move(myconv));
+ assert(myconv2.converted() == 4);
+}
diff --git a/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp b/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
new file mode 100644
index 0000000000000..4a7f77ad5d9a3
--- /dev/null
+++ b/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class locale::facet
+// {
+// protected:
+// explicit facet(size_t refs = 0);
+// virtual ~facet();
+// facet(const facet&) = delete;
+// void operator=(const facet&) = delete;
+// };
+
+// This test isn't portable
+
+#include <locale>
+#include <cassert>
+
+struct my_facet
+ : public std::locale::facet
+{
+ static int count;
+ my_facet(unsigned refs = 0)
+ : std::locale::facet(refs)
+ {++count;}
+
+ ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+ my_facet* f = new my_facet;
+ f->__add_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 0);
+ f = new my_facet(1);
+ f->__add_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 0);
+}
diff --git a/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp b/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp
new file mode 100644
index 0000000000000..3233624d87b44
--- /dev/null
+++ b/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class locale::id
+// {
+// public:
+// id();
+// void operator=(const id&) = delete;
+// id(const id&) = delete;
+// };
+
+// This test isn't portable
+
+#include <locale>
+#include <cassert>
+
+std::locale::id id0;
+std::locale::id id2;
+std::locale::id id1;
+
+int main()
+{
+ long id = id0.__get();
+ assert(id0.__get() == id+0);
+ assert(id0.__get() == id+0);
+ assert(id0.__get() == id+0);
+ assert(id1.__get() == id+1);
+ assert(id1.__get() == id+1);
+ assert(id1.__get() == id+1);
+ assert(id2.__get() == id+2);
+ assert(id2.__get() == id+2);
+ assert(id2.__get() == id+2);
+ assert(id0.__get() == id+0);
+ assert(id0.__get() == id+0);
+ assert(id0.__get() == id+0);
+ assert(id1.__get() == id+1);
+ assert(id1.__get() == id+1);
+ assert(id1.__get() == id+1);
+ assert(id2.__get() == id+2);
+ assert(id2.__get() == id+2);
+ assert(id2.__get() == id+2);
+}
diff --git a/test/libcxx/localization/version.pass.cpp b/test/libcxx/localization/version.pass.cpp
new file mode 100644
index 0000000000000..a64534c9f58bf
--- /dev/null
+++ b/test/libcxx/localization/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+#include <locale>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/numerics/cfenv/version.pass.cpp b/test/libcxx/numerics/cfenv/version.pass.cpp
new file mode 100644
index 0000000000000..727d5bdf39946
--- /dev/null
+++ b/test/libcxx/numerics/cfenv/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: newlib
+
+// <cfenv>
+
+#include <cfenv>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/numerics/complex.number/version.pass.cpp b/test/libcxx/numerics/complex.number/version.pass.cpp
new file mode 100644
index 0000000000000..316cfec739a9a
--- /dev/null
+++ b/test/libcxx/numerics/complex.number/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/numerics/numarray/version.pass.cpp b/test/libcxx/numerics/numarray/version.pass.cpp
new file mode 100644
index 0000000000000..85457d4329ece
--- /dev/null
+++ b/test/libcxx/numerics/numarray/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+#include <valarray>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/numerics/numeric.ops/version.pass.cpp b/test/libcxx/numerics/numeric.ops/version.pass.cpp
new file mode 100644
index 0000000000000..fb6e0a1063cee
--- /dev/null
+++ b/test/libcxx/numerics/numeric.ops/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+#include <numeric>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/numerics/rand/rand.synopsis/version.pass.cpp b/test/libcxx/numerics/rand/rand.synopsis/version.pass.cpp
new file mode 100644
index 0000000000000..eae6c493e919e
--- /dev/null
+++ b/test/libcxx/numerics/rand/rand.synopsis/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+#include <random>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/selftest/test_macros.pass.cpp b/test/libcxx/selftest/test_macros.pass.cpp
index 2c8ed4f454a7e..69e75b788711a 100644
--- a/test/libcxx/selftest/test_macros.pass.cpp
+++ b/test/libcxx/selftest/test_macros.pass.cpp
@@ -8,51 +8,59 @@
//===----------------------------------------------------------------------===//
//
// Test the "test_macros.h" header.
+#include <__config>
#include "test_macros.h"
#ifndef TEST_STD_VER
#error TEST_STD_VER must be defined
#endif
-#ifndef TEST_DECLTYPE
-#error TEST_DECLTYPE must be defined
-#endif
-
#ifndef TEST_NOEXCEPT
#error TEST_NOEXCEPT must be defined
#endif
-#ifndef TEST_STATIC_ASSERT
-#error TEST_STATIC_ASSERT must be defined
+#ifndef LIBCPP_ASSERT
+#error LIBCPP_ASSERT must be defined
#endif
-template <class T, class U>
-struct is_same { enum { value = 0 }; };
-
-template <class T>
-struct is_same<T, T> { enum { value = 1 }; };
-
-int foo() { return 0; }
+#ifndef LIBCPP_STATIC_ASSERT
+#error LIBCPP_STATIC_ASSERT must be defined
+#endif
void test_noexcept() TEST_NOEXCEPT
{
}
-void test_decltype()
+void test_libcxx_macros()
{
- typedef TEST_DECLTYPE(foo()) MyType;
- TEST_STATIC_ASSERT((is_same<MyType, int>::value), "is same");
-}
+// ===== C++14 features =====
+// defined(TEST_HAS_EXTENDED_CONSTEXPR) != defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#ifdef TEST_HAS_EXTENDED_CONSTEXPR
+# ifdef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
+# error "TEST_EXTENDED_CONSTEXPR mismatch (1)"
+# endif
+#else
+# ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
+# error "TEST_EXTENDED_CONSTEXPR mismatch (2)"
+# endif
+#endif
-void test_static_assert()
-{
- TEST_STATIC_ASSERT((is_same<int, int>::value), "is same");
- TEST_STATIC_ASSERT((!is_same<int, long>::value), "not same");
+// defined(TEST_HAS_VARIABLE_TEMPLATES) != defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+#ifdef TEST_HAS_VARIABLE_TEMPLATES
+# ifdef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+# error "TEST_VARIABLE_TEMPLATES mismatch (1)"
+# endif
+#else
+# ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
+# error "TEST_VARIABLE_TEMPLATES mismatch (2)"
+# endif
+#endif
+
+// ===== C++1z features =====
}
int main()
{
test_noexcept();
- test_decltype();
- test_static_assert();
+ test_libcxx_macros();
}
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
new file mode 100644
index 0000000000000..6c2929d7f1d3a
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
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
new file mode 100644
index 0000000000000..d20fcd4623b7d
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S l2("123");
+ S::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
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
new file mode 100644
index 0000000000000..5015241ad63ea
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S l2("123");
+ S::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
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
new file mode 100644
index 0000000000000..6a23bf88ca5c0
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S l2("123");
+ S::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
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
new file mode 100644
index 0000000000000..a8443818aea5b
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S l2("123");
+ S::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
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
new file mode 100644
index 0000000000000..0549e816b44c8
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::string l1("123");
+ std::string::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ S l1("123");
+ S::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/test/libcxx/strings/basic.string/string.modifiers/erase_pop_back_db1.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/erase_pop_back_db1.pass.cpp
new file mode 100644
index 0000000000000..8a6c3f0cf38f4
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/erase_pop_back_db1.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::string s;
+ s.pop_back();
+ assert(false);
+ }
+#endif
+}
diff --git a/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp
new file mode 100644
index 0000000000000..fbb26d1789977
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, charT c);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::string S;
+ S s;
+ S s2;
+ s.insert(s2.begin(), '1');
+ assert(false);
+ }
+#endif
+}
diff --git a/test/libcxx/strings/basic.string/string.modifiers/insert_iter_size_char_db1.pass.cpp b/test/libcxx/strings/basic.string/string.modifiers/insert_iter_size_char_db1.pass.cpp
new file mode 100644
index 0000000000000..7ddd2b00d402c
--- /dev/null
+++ b/test/libcxx/strings/basic.string/string.modifiers/insert_iter_size_char_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, size_type n, charT c);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::string s;
+ std::string s2;
+ s.insert(s2.begin(), 1, 'a');
+ assert(false);
+ }
+#endif
+}
diff --git a/test/libcxx/strings/c.strings/version_cctype.pass.cpp b/test/libcxx/strings/c.strings/version_cctype.pass.cpp
new file mode 100644
index 0000000000000..e0919d9d27b0e
--- /dev/null
+++ b/test/libcxx/strings/c.strings/version_cctype.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cctype>
+
+#include <cctype>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/strings/c.strings/version_cstring.pass.cpp b/test/libcxx/strings/c.strings/version_cstring.pass.cpp
new file mode 100644
index 0000000000000..87e705aec4cc7
--- /dev/null
+++ b/test/libcxx/strings/c.strings/version_cstring.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstring>
+
+#include <cstring>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/strings/c.strings/version_cuchar.pass.cpp b/test/libcxx/strings/c.strings/version_cuchar.pass.cpp
new file mode 100644
index 0000000000000..dcfdcc37ac7eb
--- /dev/null
+++ b/test/libcxx/strings/c.strings/version_cuchar.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: *
+
+// <cuchar>
+
+#include <cuchar>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/strings/c.strings/version_cwchar.pass.cpp b/test/libcxx/strings/c.strings/version_cwchar.pass.cpp
new file mode 100644
index 0000000000000..72e9855c54e5a
--- /dev/null
+++ b/test/libcxx/strings/c.strings/version_cwchar.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwchar>
+
+#include <cwchar>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/strings/c.strings/version_cwctype.pass.cpp b/test/libcxx/strings/c.strings/version_cwctype.pass.cpp
new file mode 100644
index 0000000000000..461482abe7652
--- /dev/null
+++ b/test/libcxx/strings/c.strings/version_cwctype.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwctype>
+
+#include <cwctype>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/strings/iterators.exceptions.pass.cpp b/test/libcxx/strings/iterators.exceptions.pass.cpp
index 591782b5dd4a0..02ec921cc6133 100644
--- a/test/libcxx/strings/iterators.exceptions.pass.cpp
+++ b/test/libcxx/strings/iterators.exceptions.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-
+// XFAIL: libcpp-no-exceptions
// <iterator>
// __libcpp_is_trivial_iterator<Tp>
@@ -23,6 +23,7 @@
#include <vector>
#include <initializer_list>
+#include "test_macros.h"
#include "test_iterators.h"
int main()
@@ -30,17 +31,17 @@ int main()
// basic tests
static_assert(( std::__libcpp_string_gets_noexcept_iterator<char *>::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<const char *>::value), "");
-
+
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::move_iterator<char *> > ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::move_iterator<const char *> >::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<char *> > ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<const char *> >::value), "");
-
+
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::__wrap_iter<char *> > ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::__wrap_iter<const char *> >::value), "");
-
+
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<std::__wrap_iter<char *> > > ::value), "");
-
+
// iterators in the libc++ test suite
static_assert((!std::__libcpp_string_gets_noexcept_iterator<output_iterator <char *> >::value), "");
static_assert((!std::__libcpp_string_gets_noexcept_iterator<input_iterator <char *> >::value), "");
@@ -48,13 +49,13 @@ int main()
static_assert((!std::__libcpp_string_gets_noexcept_iterator<bidirectional_iterator<char *> >::value), "");
static_assert((!std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char *> >::value), "");
static_assert((!std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator <char *> >::value), "");
-
-#if __has_feature(cxx_noexcept)
+
+#if TEST_STD_VER >= 11
static_assert(( std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator <char *> >::value), "");
#else
static_assert((!std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator <char *> >::value), "");
#endif
-
+
//
// iterators from libc++'s containers
//
diff --git a/test/libcxx/strings/iterators.noexcept.pass.cpp b/test/libcxx/strings/iterators.noexcept.pass.cpp
index f39a4deac7358..283cf0897cca8 100644
--- a/test/libcxx/strings/iterators.noexcept.pass.cpp
+++ b/test/libcxx/strings/iterators.noexcept.pass.cpp
@@ -34,17 +34,17 @@ int main()
// basic tests
static_assert(( std::__libcpp_string_gets_noexcept_iterator<char *>::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<const char *>::value), "");
-
+
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::move_iterator<char *> > ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::move_iterator<const char *> >::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<char *> > ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<const char *> >::value), "");
-
+
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::__wrap_iter<char *> > ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::__wrap_iter<const char *> >::value), "");
-
+
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::reverse_iterator<std::__wrap_iter<char *> > > ::value), "");
-
+
// iterators in the libc++ test suite
static_assert(( std::__libcpp_string_gets_noexcept_iterator<output_iterator <char *> >::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<input_iterator <char *> >::value), "");
@@ -52,9 +52,9 @@ int main()
static_assert(( std::__libcpp_string_gets_noexcept_iterator<bidirectional_iterator<char *> >::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char *> >::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator <char *> >::value), "");
-
+
static_assert(( std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator <char *> >::value), "");
-
+
//
// iterators from libc++'s containers
//
diff --git a/test/libcxx/strings/version.pass.cpp b/test/libcxx/strings/version.pass.cpp
new file mode 100644
index 0000000000000..0c79c1af2ce84
--- /dev/null
+++ b/test/libcxx/strings/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+#include <string>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py
index f8096ad15f8a0..593f9805447d3 100644
--- a/test/libcxx/test/config.py
+++ b/test/libcxx/test/config.py
@@ -61,6 +61,7 @@ class Configuration(object):
self.libcxx_src_root = None
self.libcxx_obj_root = None
self.cxx_library_root = None
+ self.cxx_runtime_root = None
self.abi_library_root = None
self.env = {}
self.use_target = False
@@ -98,9 +99,11 @@ class Configuration(object):
self.configure_cxx_library_root()
self.configure_use_system_cxx_lib()
self.configure_use_clang_verify()
+ self.configure_use_thread_safety()
self.configure_execute_external()
self.configure_ccache()
self.configure_compile_flags()
+ self.configure_filesystem_compile_flags()
self.configure_link_flags()
self.configure_env()
self.configure_color_diagnostics()
@@ -194,6 +197,8 @@ class Configuration(object):
def configure_cxx_library_root(self):
self.cxx_library_root = self.get_lit_conf('cxx_library_root',
self.libcxx_obj_root)
+ self.cxx_runtime_root = self.get_lit_conf('cxx_runtime_root',
+ self.cxx_library_root)
def configure_use_system_cxx_lib(self):
# This test suite supports testing against either the system library or
@@ -218,6 +223,14 @@ class Configuration(object):
self.lit_config.note(
"inferred use_clang_verify as: %r" % self.use_clang_verify)
+ def configure_use_thread_safety(self):
+ '''If set, run clang with -verify on failing tests.'''
+ has_thread_safety = self.cxx.hasCompileFlag('-Werror=thread-safety')
+ if has_thread_safety:
+ self.cxx.compile_flags += ['-Werror=thread-safety']
+ self.config.available_features.add('thread-safety')
+ self.lit_config.note("enabling thread-safety annotations")
+
def configure_execute_external(self):
# Choose between lit's internal shell pipeline runner and a real shell.
# If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the
@@ -277,10 +290,17 @@ class Configuration(object):
if self.cxx.hasCompileFlag('-fsized-deallocation'):
self.config.available_features.add('fsized-deallocation')
+ if self.get_lit_bool('has_libatomic', False):
+ self.config.available_features.add('libatomic')
+
def configure_compile_flags(self):
no_default_flags = self.get_lit_bool('no_default_flags', False)
if not no_default_flags:
self.configure_default_compile_flags()
+ # This include is always needed so add so add it regardless of
+ # 'no_default_flags'.
+ support_path = os.path.join(self.libcxx_src_root, 'test/support')
+ self.cxx.compile_flags += ['-I' + support_path]
# Configure extra flags
compile_flags_str = self.get_lit_conf('compile_flags', '')
self.cxx.compile_flags += shlex.split(compile_flags_str)
@@ -329,7 +349,6 @@ class Configuration(object):
def configure_compile_flags_header_includes(self):
support_path = os.path.join(self.libcxx_src_root, 'test/support')
- self.cxx.compile_flags += ['-I' + support_path]
self.cxx.compile_flags += ['-include', os.path.join(support_path, 'nasty_macros.hpp')]
self.configure_config_site_header()
libcxx_headers = self.get_lit_conf(
@@ -412,6 +431,37 @@ class Configuration(object):
self.config.available_features.add('libcpp-abi-unstable')
self.cxx.compile_flags += ['-D_LIBCPP_ABI_UNSTABLE']
+ def configure_filesystem_compile_flags(self):
+ enable_fs = self.get_lit_bool('enable_filesystem', default=False)
+ if not enable_fs:
+ return
+ enable_experimental = self.get_lit_bool('enable_experimental', default=False)
+ if not enable_experimental:
+ self.lit_config.fatal(
+ 'filesystem is enabled but libc++experimental.a is not.')
+ self.config.available_features.add('c++filesystem')
+ static_env = os.path.join(self.libcxx_src_root, 'test', 'std',
+ 'experimental', 'filesystem', 'Inputs', 'static_test_env')
+ static_env = os.path.realpath(static_env)
+ assert os.path.isdir(static_env)
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="%s"' % static_env]
+
+ dynamic_env = os.path.join(self.libcxx_obj_root, 'test',
+ 'filesystem', 'Output', 'dynamic_env')
+ dynamic_env = os.path.realpath(dynamic_env)
+ if not os.path.isdir(dynamic_env):
+ os.makedirs(dynamic_env)
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="%s"' % dynamic_env]
+ self.env['LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT'] = ("%s" % dynamic_env)
+
+ dynamic_helper = os.path.join(self.libcxx_src_root, 'test', 'support',
+ 'filesystem_dynamic_test_helper.py')
+ assert os.path.isfile(dynamic_helper)
+
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="%s %s"'
+ % (sys.executable, dynamic_helper)]
+
+
def configure_link_flags(self):
no_default_flags = self.get_lit_bool('no_default_flags', False)
if not no_default_flags:
@@ -430,23 +480,11 @@ class Configuration(object):
self.cxx.link_flags += shlex.split(link_flags_str)
def configure_link_flags_cxx_library_path(self):
- libcxx_library = self.get_lit_conf('libcxx_library')
- # Configure libc++ library paths.
- if libcxx_library is not None:
- # Check that the given value for libcxx_library is valid.
- if not os.path.isfile(libcxx_library):
- self.lit_config.fatal(
- "libcxx_library='%s' is not a valid file." %
- libcxx_library)
- if self.use_system_cxx_lib:
- self.lit_config.fatal(
- "Conflicting options: 'libcxx_library' cannot be used "
- "with 'use_system_cxx_lib=true'")
- self.cxx.link_flags += ['-Wl,-rpath,' +
- os.path.dirname(libcxx_library)]
- elif not self.use_system_cxx_lib and self.cxx_library_root:
- self.cxx.link_flags += ['-L' + self.cxx_library_root,
- '-Wl,-rpath,' + self.cxx_library_root]
+ if not self.use_system_cxx_lib:
+ if self.cxx_library_root:
+ self.cxx.link_flags += ['-L' + self.cxx_library_root]
+ if self.cxx_runtime_root:
+ self.cxx.link_flags += ['-Wl,-rpath,' + self.cxx_runtime_root]
def configure_link_flags_abi_library_path(self):
# Configure ABI library paths.
@@ -456,11 +494,20 @@ class Configuration(object):
'-Wl,-rpath,' + self.abi_library_root]
def configure_link_flags_cxx_library(self):
- libcxx_library = self.get_lit_conf('libcxx_library')
- if libcxx_library:
- self.cxx.link_flags += [libcxx_library]
- else:
+ libcxx_experimental = self.get_lit_bool('enable_experimental', default=False)
+ if libcxx_experimental:
+ self.config.available_features.add('c++experimental')
+ self.cxx.link_flags += ['-lc++experimental']
+ libcxx_shared = self.get_lit_bool('enable_shared', default=True)
+ if libcxx_shared:
self.cxx.link_flags += ['-lc++']
+ else:
+ cxx_library_root = self.get_lit_conf('cxx_library_root')
+ if cxx_library_root:
+ abs_path = os.path.join(cxx_library_root, 'libc++.a')
+ self.cxx.link_flags += [abs_path]
+ else:
+ self.cxx.link_flags += ['-lc++']
def configure_link_flags_abi_library(self):
cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
@@ -470,7 +517,16 @@ class Configuration(object):
self.cxx.link_flags += ['-lsupc++']
elif cxx_abi == 'libcxxabi':
if self.target_info.allow_cxxabi_link():
- self.cxx.link_flags += ['-lc++abi']
+ libcxxabi_shared = self.get_lit_bool('libcxxabi_shared', default=True)
+ if libcxxabi_shared:
+ self.cxx.link_flags += ['-lc++abi']
+ else:
+ cxxabi_library_root = self.get_lit_conf('abi_library_path')
+ if cxxabi_library_root:
+ abs_path = os.path.join(cxxabi_library_root, 'libc++abi.a')
+ self.cxx.link_flags += [abs_path]
+ else:
+ self.cxx.link_flags += ['-lc++abi']
elif cxx_abi == 'libcxxrt':
self.cxx.link_flags += ['-lcxxrt']
elif cxx_abi == 'none':
@@ -515,8 +571,9 @@ class Configuration(object):
if enable_warnings:
self.cxx.compile_flags += [
'-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER',
- '-Wall', '-Werror'
+ '-Wall', '-Wextra', '-Werror'
]
+ self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument')
self.cxx.addWarningFlagIfSupported('-Wno-attributes')
self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move')
self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions')
@@ -525,6 +582,8 @@ class Configuration(object):
# compiles clean with them.
self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
self.cxx.addWarningFlagIfSupported('-Wno-unused-variable')
+ self.cxx.addWarningFlagIfSupported('-Wno-unused-parameter')
+ self.cxx.addWarningFlagIfSupported('-Wno-sign-compare')
std = self.get_lit_conf('std', None)
if std in ['c++98', 'c++03']:
# The '#define static_assert' provided by libc++ in C++03 mode
@@ -551,6 +610,9 @@ class Configuration(object):
self.cxx.flags += ['-fsanitize=address']
if llvm_symbolizer is not None:
self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
+ # FIXME: Turn ODR violation back on after PR28391 is resolved
+ # https://llvm.org/bugs/show_bug.cgi?id=28391
+ self.env['ASAN_OPTIONS'] = 'detect_odr_violation=0'
self.config.available_features.add('asan')
self.config.available_features.add('sanitizer-new-delete')
elif san == 'Memory' or san == 'MemoryWithOrigins':
@@ -563,9 +625,12 @@ class Configuration(object):
self.config.available_features.add('msan')
self.config.available_features.add('sanitizer-new-delete')
elif san == 'Undefined':
+ blacklist = os.path.join(self.libcxx_src_root,
+ 'test/ubsan_blacklist.txt')
self.cxx.flags += ['-fsanitize=undefined',
- '-fno-sanitize=vptr,function',
- '-fno-sanitize-recover']
+ '-fno-sanitize=vptr,function,float-divide-by-zero',
+ '-fno-sanitize-recover=all',
+ '-fsanitize-blacklist=' + blacklist]
self.cxx.compile_flags += ['-O3']
self.env['UBSAN_OPTIONS'] = 'print_stacktrace=1'
self.config.available_features.add('ubsan')
diff --git a/test/libcxx/test/format.py b/test/libcxx/test/format.py
index aaa9a1845ae40..b9ec2ba2aa7bb 100644
--- a/test/libcxx/test/format.py
+++ b/test/libcxx/test/format.py
@@ -161,12 +161,19 @@ class LibcxxTestFormat(object):
'expected-error', 'expected-no-diagnostics']
use_verify = self.use_verify_for_fail and \
any([tag in contents for tag in verify_tags])
- extra_flags = ['-fsyntax-only']
+ # FIXME(EricWF): GCC 5 does not evaluate static assertions that
+ # are dependant on a template parameter when '-fsyntax-only' is passed.
+ # This is fixed in GCC 6. However for now we only pass "-fsyntax-only"
+ # when using Clang.
+ extra_flags = []
+ if self.cxx.type != 'gcc':
+ extra_flags += ['-fsyntax-only']
if use_verify:
extra_flags += ['-Xclang', '-verify',
'-Xclang', '-verify-ignore-unexpected=note']
cmd, out, err, rc = self.cxx.compile(source_path, out=os.devnull,
- flags=extra_flags)
+ flags=extra_flags,
+ disable_ccache=True)
expected_rc = 0 if use_verify else 1
if rc == expected_rc:
return lit.Test.PASS, ''
diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py
index 7ca08bea193af..a743595a1046d 100644
--- a/test/libcxx/test/target_info.py
+++ b/test/libcxx/test/target_info.py
@@ -90,13 +90,10 @@ class DarwinLocalTI(DefaultTargetInfo):
def configure_env(self, env):
library_paths = []
# Configure the library path for libc++
- libcxx_library = self.full_config.get_lit_conf('libcxx_library')
if self.full_config.use_system_cxx_lib:
pass
- elif libcxx_library:
- library_paths += [os.path.dirname(libcxx_library)]
- elif self.full_config.cxx_library_root:
- library_paths += [self.full_config.cxx_library_root]
+ elif self.full_config.cxx_runtime_root:
+ library_paths += [self.full_config.cxx_runtime_root]
# Configure the abi library path
if self.full_config.abi_library_root:
library_paths += [self.full_config.abi_library_root]
@@ -104,6 +101,15 @@ class DarwinLocalTI(DefaultTargetInfo):
env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths)
def allow_cxxabi_link(self):
+ # FIXME: PR27405
+ # libc++ *should* export all of the symbols found in libc++abi on OS X.
+ # For this reason LibcxxConfiguration will not link libc++abi in OS X.
+ # However __cxa_throw_bad_new_array_length doesn't get exported into
+ # libc++ yet so we still need to explicitly link libc++abi when testing
+ # libc++abi
+ # See PR22654.
+ if(self.full_config.get_lit_conf('name', '') == 'libc++abi'):
+ return True
# Don't link libc++abi explicitly on OS X because the symbols
# should be available in libc++ directly.
return False
@@ -162,16 +168,22 @@ class LinuxLocalTI(DefaultTargetInfo):
enable_threads = ('libcpp-has-no-threads' not in
self.full_config.config.available_features)
llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False)
+ shared_libcxx = self.full_config.get_lit_bool('enable_shared', True)
flags += ['-lm']
if not llvm_unwinder:
flags += ['-lgcc_s', '-lgcc']
if enable_threads:
flags += ['-lpthread']
+ if not shared_libcxx:
+ flags += ['-lrt']
flags += ['-lc']
if llvm_unwinder:
flags += ['-lunwind', '-ldl']
else:
flags += ['-lgcc_s', '-lgcc']
+ use_libatomic = self.full_config.get_lit_bool('use_libatomic', False)
+ if use_libatomic:
+ flags += ['-latomic']
san = self.full_config.get_lit_conf('use_sanitizer', '').strip()
if san:
# The libraries and their order are taken from the
diff --git a/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp b/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
new file mode 100644
index 0000000000000..bf567a30243ad
--- /dev/null
+++ b/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// <future>
+
+// class promise<R>
+
+// void set_exception(exception_ptr p);
+// Test that a null exception_ptr is diagnosed.
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? ((void)0) : throw 42)
+
+#define _LIBCPP_DEBUG 0
+#include <future>
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ try {
+ p.set_exception(std::exception_ptr());
+ assert(false);
+ } catch (int const& value) {
+ assert(value == 42);
+ }
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ try {
+ p.set_exception(std::exception_ptr());
+ assert(false);
+ } catch (int const& value) {
+ assert(value == 42);
+ }
+ }
+}
diff --git a/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
new file mode 100644
index 0000000000000..1cb61d9af297e
--- /dev/null
+++ b/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// <future>
+
+// class promise<R>
+
+// void set_exception_on_thread_exit(exception_ptr p);
+// Test that a null exception_ptr is diagnosed.
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? ((void)0) : throw 42)
+
+#define _LIBCPP_DEBUG 0
+#include <future>
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ try {
+ p.set_exception_at_thread_exit(std::exception_ptr());
+ assert(false);
+ } catch (int const& value) {
+ assert(value == 42);
+ }
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ try {
+ p.set_exception_at_thread_exit(std::exception_ptr());
+ assert(false);
+ } catch (int const& value) {
+ assert(value == 42);
+ }
+ }
+}
diff --git a/test/libcxx/thread/futures/futures.task/types.pass.cpp b/test/libcxx/thread/futures/futures.task/types.pass.cpp
new file mode 100644
index 0000000000000..cb0fb803c6ab2
--- /dev/null
+++ b/test/libcxx/thread/futures/futures.task/types.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: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// <future>
+
+// template<class R, class... ArgTypes>
+// class packaged_task<R(ArgTypes...)>
+// {
+// public:
+// typedef R result_type; // extension
+
+// This is a libc++ extension.
+
+#include <future>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ static_assert((std::is_same<std::packaged_task<A(int, char)>::result_type, A>::value), "");
+}
diff --git a/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp b/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
new file mode 100644
index 0000000000000..bf28e01a0e861
--- /dev/null
+++ b/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+
+// <condition_variable>
+
+// class condition_variable;
+
+// typedef pthread_cond_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_same<std::condition_variable::native_handle_type,
+ pthread_cond_t*>::value), "");
+ std::condition_variable cv;
+ std::condition_variable::native_handle_type h = cv.native_handle();
+ assert(h != nullptr);
+}
diff --git a/test/libcxx/thread/thread.condition/version.pass.cpp b/test/libcxx/thread/thread.condition/version.pass.cpp
new file mode 100644
index 0000000000000..12a775e833982
--- /dev/null
+++ b/test/libcxx/thread/thread.condition/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+
+// <condition_variable>
+
+#include <condition_variable>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.pass.cpp b/test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.pass.cpp
new file mode 100644
index 0000000000000..aae0afbffd37a
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_mangling.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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// TODO(EricWF) Investigate why typeid(...).name() returns a different string
+// on GCC 4.9 but not newer GCCs.
+// XFAIL: gcc-4.9
+
+// THIS TESTS C++03 EXTENSIONS.
+
+// <mutex>
+
+// template <class ...Mutex> class lock_guard;
+
+// Test that the the variadic lock guard implementation mangles the same in
+// C++11 and C++03. This is important since the mangling of `lock_guard` depends
+// on it being declared as a variadic template, even in C++03.
+
+#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
+#include <mutex>
+#include <string>
+#include <typeinfo>
+#include <cassert>
+
+int main() {
+ const std::string expect = "NSt3__110lock_guardIJNS_5mutexEEEE";
+ assert(typeid(std::lock_guard<std::mutex>).name() == expect);
+}
diff --git a/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp b/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
new file mode 100644
index 0000000000000..12c80f02c340d
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+
+// <mutex>
+
+// class mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+ std::mutex m;
+ pthread_mutex_t* h = m.native_handle();
+ assert(h);
+}
diff --git a/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp b/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
new file mode 100644
index 0000000000000..10626bc4072e0
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+
+// <mutex>
+
+// class recursive_mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+ std::recursive_mutex m;
+ pthread_mutex_t* h = m.native_handle();
+ assert(h);
+}
diff --git a/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp b/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
new file mode 100644
index 0000000000000..d9ac92c270c30
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <mutex>
+
+// This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it
+// should compile without any warnings or errors even though this pattern is not
+// understood by the thread safety annotations.
+
+#include <mutex>
+
+int main() {
+ std::mutex m;
+ m.lock();
+ {
+ std::unique_lock<std::mutex> g(m, std::adopt_lock);
+ }
+}
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
new file mode 100644
index 0000000000000..4e85a039686a0
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+// REQUIRES: thread-safety
+
+// <mutex>
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include <mutex>
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+ std::lock_guard<std::mutex> lock(m);
+ foo++;
+}
diff --git a/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp b/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
new file mode 100644
index 0000000000000..40b97c396ad66
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.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.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: libcpp-has-no-threads
+// REQUIRES: thread-safety
+
+// <mutex>
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include <mutex>
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+int main() {
+ m.lock();
+ foo++;
+ m.unlock();
+}
diff --git a/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp b/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
new file mode 100644
index 0000000000000..c1425c960c005
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+// REQUIRES: thread-safety
+
+// <mutex>
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include <mutex>
+
+std::mutex m;
+
+int main() {
+ m.lock();
+} // expected-error {{mutex 'm' is still held at the end of function}}
diff --git a/test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp b/test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
new file mode 100644
index 0000000000000..e03f5eabffcfe
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+// REQUIRES: thread-safety
+
+// <mutex>
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include <mutex>
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(m))) {
+ foo++;
+}
+
+int main() {
+ m.lock();
+ increment();
+ m.unlock();
+}
diff --git a/test/libcxx/thread/thread.mutex/version.pass.cpp b/test/libcxx/thread/thread.mutex/version.pass.cpp
new file mode 100644
index 0000000000000..81b52c79204b8
--- /dev/null
+++ b/test/libcxx/thread/thread.mutex/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+#include <mutex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp b/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
new file mode 100644
index 0000000000000..c8807a965c44b
--- /dev/null
+++ b/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.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: libcpp-has-no-threads
+
+// <thread>
+
+// class thread
+
+// native_handle_type native_handle();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+ int alive_;
+public:
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) {++n_alive;}
+ G(const G& g) : alive_(g.alive_) {++n_alive;}
+ ~G() {alive_ = 0; --n_alive;}
+
+ void operator()()
+ {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+ {
+ G g;
+ std::thread t0(g);
+ pthread_t pid = t0.native_handle();
+ assert(pid != 0);
+ t0.join();
+ }
+}
diff --git a/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp b/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
new file mode 100644
index 0000000000000..a5bf77031ccaf
--- /dev/null
+++ b/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+
+// <thread>
+
+// class thread
+// {
+// public:
+// typedef pthread_t native_handle_type;
+// ...
+// };
+
+#include <thread>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::thread::native_handle_type, pthread_t>::value), "");
+}
diff --git a/test/libcxx/thread/thread.threads/version.pass.cpp b/test/libcxx/thread/thread.threads/version.pass.cpp
new file mode 100644
index 0000000000000..d16b0eb068428
--- /dev/null
+++ b/test/libcxx/thread/thread.threads/version.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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-has-no-threads
+
+// <thread>
+
+#include <thread>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp b/test/libcxx/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp
new file mode 100644
index 0000000000000..509c751b455dd
--- /dev/null
+++ b/test/libcxx/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp
@@ -0,0 +1,370 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+// - Bullet 1 -- (t1.*f)(t2, ..., tN)
+// - Bullet 2 -- (t1.get().*f)(t2, ..., tN) // t1 is a reference_wrapper
+// - Bullet 3 -- ((*t1).*f)(t2, ..., tN)
+//
+// Overview:
+// Bullets 1, 2 and 3 handle the case where 'f' is a pointer to member function.
+// Bullet 1 only handles the cases where t1 is an object of type T or a
+// type derived from 'T'. Bullet 2 handles the case where 't1' is a reference
+// wrapper and bullet 3 handles all other cases.
+//
+// Concerns:
+// 1) cv-qualified member function signatures are accepted.
+// 2) reference qualified member function signatures are accepted.
+// 3) member functions with varargs at the end are accepted.
+// 4) The arguments are perfect forwarded to the member function call.
+// 5) Classes that are publicly derived from 'T' are accepted as the call object
+// 6) All types that dereference to T or a type derived from T can be used
+// as the call object.
+// 7) Pointers to T or a type derived from T can be used as the call object.
+// 8) Reference return types are properly deduced.
+// 9) reference_wrappers are properly handled and unwrapped.
+//
+//
+// Plan:
+// 1) Create a class that contains a set, 'S', of non-static functions.
+// 'S' should include functions that cover every single combination
+// of qualifiers and varargs for arities of 0, 1 and 2 (C-1,2,3).
+// The argument types used in the functions should be non-copyable (C-4).
+// The functions should return 'MethodID::setUncheckedCall()'.
+//
+// 2) Create a set of supported call object, 'Objs', of different types
+// and behaviors. (C-5,6,7)
+//
+// 3) Attempt to call each function, 'f', in 'S' with each call object, 'c',
+// in 'Objs'. After every attempted call to 'f' check that 'f' was
+// actually called using 'MethodID::checkCalled(<return-value>)'
+//
+// 3b) If 'f' is reference qualified call 'f' with the properly qualified
+// call object. Otherwise call 'f' with lvalue call objects.
+//
+// 3a) If 'f' is const, volatile, or cv qualified then call it with call
+// objects that are equally or less cv-qualified.
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+//==============================================================================
+// MemFun03 - C++03 compatible set of test member functions.
+struct MemFun03 {
+ typedef void*& R;
+#define F(...) \
+ R f(__VA_ARGS__) { return MethodID<R(MemFun03::*)(__VA_ARGS__)>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const { return MethodID<R(MemFun03::*)(__VA_ARGS__) const>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) volatile>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) const volatile>::setUncheckedCall(); }
+#
+ F()
+ F(...)
+ F(ArgType&)
+ F(ArgType&, ...)
+ F(ArgType&, ArgType&)
+ F(ArgType&, ArgType&, ...)
+ F(ArgType&, ArgType&, ArgType&)
+ F(ArgType&, ArgType&, ArgType&, ...)
+#undef F
+public:
+ MemFun03() {}
+private:
+ MemFun03(MemFun03 const&);
+ MemFun03& operator=(MemFun03 const&);
+};
+
+
+#if TEST_STD_VER >= 11
+
+//==============================================================================
+// MemFun11 - C++11 reference qualified test member functions.
+struct MemFun11 {
+ typedef void*& R;
+ typedef MemFun11 C;
+#define F(...) \
+ R f(__VA_ARGS__) & { return MethodID<R(C::*)(__VA_ARGS__) &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const & { return MethodID<R(C::*)(__VA_ARGS__) const &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile & { return MethodID<R(C::*)(__VA_ARGS__) volatile &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile & { return MethodID<R(C::*)(__VA_ARGS__) const volatile &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) && { return MethodID<R(C::*)(__VA_ARGS__) &&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const && { return MethodID<R(C::*)(__VA_ARGS__) const &&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile && { return MethodID<R(C::*)(__VA_ARGS__) volatile &&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile && { return MethodID<R(C::*)(__VA_ARGS__) const volatile &&>::setUncheckedCall(); }
+#
+ F()
+ F(...)
+ F(ArgType&&)
+ F(ArgType&&, ...)
+ F(ArgType&&, ArgType&&)
+ F(ArgType&&, ArgType&&, ...)
+ F(ArgType&&, ArgType&&, ArgType&&)
+ F(ArgType&&, ArgType&&, ArgType&&, ...)
+#undef F
+public:
+ MemFun11() {}
+private:
+ MemFun11(MemFun11 const&);
+ MemFun11& operator=(MemFun11 const&);
+};
+
+#endif // TEST_STD_VER >= 11
+
+
+
+//==============================================================================
+// TestCase - A test case for a single member function.
+// ClassType - The type of the class being tested.
+// CallSig - The function signature of the method being tested.
+// Arity - the arity of 'CallSig'
+// CV - the cv qualifiers of 'CallSig' represented as a type tag.
+// RValue - The method is RValue qualified.
+// ArgRValue - Call the method with RValue arguments.
+template <class ClassType, class CallSig, int Arity, class CV,
+ bool RValue = false, bool ArgRValue = false>
+struct TestCaseImp {
+public:
+
+ static void run() { TestCaseImp().doTest(); }
+
+private:
+ //==========================================================================
+ // TEST DISPATCH
+ void doTest() {
+ // (Plan-2) Create test call objects.
+ typedef ClassType T;
+ typedef DerivedFromType<T> D;
+ T obj;
+ T* obj_ptr = &obj;
+ D der;
+ D* der_ptr = &der;
+ DerefToType<T> dref;
+ DerefPropType<T> dref2;
+ std::reference_wrapper<T> rref(obj);
+ std::reference_wrapper<D> drref(der);
+
+ // (Plan-3) Dispatch based on the CV tags.
+ CV tag;
+ Bool<!RValue> NotRValue;
+ runTestDispatch(tag, obj);
+ runTestDispatch(tag, der);
+ runTestDispatch(tag, dref2);
+ runTestDispatchIf(NotRValue, tag, dref);
+ runTestDispatchIf(NotRValue, tag, obj_ptr);
+ runTestDispatchIf(NotRValue, tag, der_ptr);
+#if TEST_STD_VER >= 11
+ runTestDispatchIf(NotRValue, tag, rref);
+ runTestDispatchIf(NotRValue, tag, drref);
+#endif
+ }
+
+ template <class QT, class Tp>
+ void runTestDispatchIf(Bool<true>, QT q, Tp& v) {
+ runTestDispatch(q, v);
+ }
+
+ template <class QT, class Tp>
+ void runTestDispatchIf(Bool<false>, QT, Tp&) {
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_None, Tp& v) {
+ runTest(v);
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_Const, Tp& v) {
+ runTest(v);
+ runTest(makeConst(v));
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_Volatile, Tp& v) {
+ runTest(v);
+ runTest(makeVolatile(v));
+
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_CV, Tp& v) {
+ runTest(v);
+ runTest(makeConst(v));
+ runTest(makeVolatile(v));
+ runTest(makeCV(v));
+ }
+
+ template <class T>
+ void runTest(const std::reference_wrapper<T>& obj) {
+ typedef Caster<Q_None, RValue> SCast;
+ typedef Caster<Q_None, ArgRValue> ACast;
+ typedef CallSig (ClassType::*MemPtr);
+ // Delegate test to logic in invoke_helpers.h
+ BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+ b.runTest( (MemPtr)&ClassType::f, obj);
+ }
+
+ template <class T>
+ void runTest(T* obj) {
+ typedef Caster<Q_None, RValue> SCast;
+ typedef Caster<Q_None, ArgRValue> ACast;
+ typedef CallSig (ClassType::*MemPtr);
+ // Delegate test to logic in invoke_helpers.h
+ BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+ b.runTest( (MemPtr)&ClassType::f, obj);
+ }
+
+ template <class Obj>
+ void runTest(Obj& obj) {
+ typedef Caster<Q_None, RValue> SCast;
+ typedef Caster<Q_None, ArgRValue> ACast;
+ typedef CallSig (ClassType::*MemPtr);
+ // Delegate test to logic in invoke_helpers.h
+ BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+ b.runTest( (MemPtr)&ClassType::f, obj);
+ }
+};
+
+template <class Sig, int Arity, class CV>
+struct TestCase : public TestCaseImp<MemFun03, Sig, Arity, CV> {};
+
+#if TEST_STD_VER >= 11
+template <class Sig, int Arity, class CV, bool RValue = false>
+struct TestCase11 : public TestCaseImp<MemFun11, Sig, Arity, CV, RValue, true> {};
+#endif
+
+template <class Tp>
+struct DerivedFromRefWrap : public std::reference_wrapper<Tp> {
+ DerivedFromRefWrap(Tp& tp) : std::reference_wrapper<Tp>(tp) {}
+};
+
+#if TEST_STD_VER >= 11
+void test_derived_from_ref_wrap() {
+ int x = 42;
+ std::reference_wrapper<int> r(x);
+ std::reference_wrapper<std::reference_wrapper<int>> r2(r);
+ DerivedFromRefWrap<int> d(x);
+ auto get_fn = &std::reference_wrapper<int>::get;
+ auto& ret = std::__invoke(get_fn, r);
+ auto& cret = std::__invoke_constexpr(get_fn, r);
+ assert(&ret == &x);
+ assert(&cret == &x);
+ auto& ret2 = std::__invoke(get_fn, d);
+ auto& cret2 = std::__invoke_constexpr(get_fn, d);
+ assert(&ret2 == &x);
+ auto& ret3 = std::__invoke(get_fn, r2);
+ assert(&ret3 == &x);
+}
+#endif
+
+int main() {
+ typedef void*& R;
+ typedef ArgType A;
+ TestCase<R(), 0, Q_None>::run();
+ TestCase<R() const, 0, Q_Const>::run();
+ TestCase<R() volatile, 0, Q_Volatile>::run();
+ TestCase<R() const volatile, 0, Q_CV>::run();
+ TestCase<R(...), 0, Q_None>::run();
+ TestCase<R(...) const, 0, Q_Const>::run();
+ TestCase<R(...) volatile, 0, Q_Volatile>::run();
+ TestCase<R(...) const volatile, 0, Q_CV>::run();
+ TestCase<R(A&), 1, Q_None>::run();
+ TestCase<R(A&) const, 1, Q_Const>::run();
+ TestCase<R(A&) volatile, 1, Q_Volatile>::run();
+ TestCase<R(A&) const volatile, 1, Q_CV>::run();
+ TestCase<R(A&, ...), 1, Q_None>::run();
+ TestCase<R(A&, ...) const, 1, Q_Const>::run();
+ TestCase<R(A&, ...) volatile, 1, Q_Volatile>::run();
+ TestCase<R(A&, ...) const volatile, 1, Q_CV>::run();
+ TestCase<R(A&, A&), 2, Q_None>::run();
+ TestCase<R(A&, A&) const, 2, Q_Const>::run();
+ TestCase<R(A&, A&) volatile, 2, Q_Volatile>::run();
+ TestCase<R(A&, A&) const volatile, 2, Q_CV>::run();
+ TestCase<R(A&, A&, ...), 2, Q_None>::run();
+ TestCase<R(A&, A&, ...) const, 2, Q_Const>::run();
+ TestCase<R(A&, A&, ...) volatile, 2, Q_Volatile>::run();
+ TestCase<R(A&, A&, ...) const volatile, 2, Q_CV>::run();
+ TestCase<R(A&, A&, A&), 3, Q_None>::run();
+ TestCase<R(A&, A&, A&) const, 3, Q_Const>::run();
+ TestCase<R(A&, A&, A&) volatile, 3, Q_Volatile>::run();
+ TestCase<R(A&, A&, A&) const volatile, 3, Q_CV>::run();
+ TestCase<R(A&, A&, A&, ...), 3, Q_None>::run();
+ TestCase<R(A&, A&, A&, ...) const, 3, Q_Const>::run();
+ TestCase<R(A&, A&, A&, ...) volatile, 3, Q_Volatile>::run();
+ TestCase<R(A&, A&, A&, ...) const volatile, 3, Q_CV>::run();
+
+#if TEST_STD_VER >= 11
+ TestCase11<R() &, 0, Q_None>::run();
+ TestCase11<R() const &, 0, Q_Const>::run();
+ TestCase11<R() volatile &, 0, Q_Volatile>::run();
+ TestCase11<R() const volatile &, 0, Q_CV>::run();
+ TestCase11<R(...) &, 0, Q_None>::run();
+ TestCase11<R(...) const &, 0, Q_Const>::run();
+ TestCase11<R(...) volatile &, 0, Q_Volatile>::run();
+ TestCase11<R(...) const volatile &, 0, Q_CV>::run();
+ TestCase11<R(A&&) &, 1, Q_None>::run();
+ TestCase11<R(A&&) const &, 1, Q_Const>::run();
+ TestCase11<R(A&&) volatile &, 1, Q_Volatile>::run();
+ TestCase11<R(A&&) const volatile &, 1, Q_CV>::run();
+ TestCase11<R(A&&, ...) &, 1, Q_None>::run();
+ TestCase11<R(A&&, ...) const &, 1, Q_Const>::run();
+ TestCase11<R(A&&, ...) volatile &, 1, Q_Volatile>::run();
+ TestCase11<R(A&&, ...) const volatile &, 1, Q_CV>::run();
+ TestCase11<R(A&&, A&&) &, 2, Q_None>::run();
+ TestCase11<R(A&&, A&&) const &, 2, Q_Const>::run();
+ TestCase11<R(A&&, A&&) volatile &, 2, Q_Volatile>::run();
+ TestCase11<R(A&&, A&&) const volatile &, 2, Q_CV>::run();
+ TestCase11<R(A&&, A&&, ...) &, 2, Q_None>::run();
+ TestCase11<R(A&&, A&&, ...) const &, 2, Q_Const>::run();
+ TestCase11<R(A&&, A&&, ...) volatile &, 2, Q_Volatile>::run();
+ TestCase11<R(A&&, A&&, ...) const volatile &, 2, Q_CV>::run();
+ TestCase11<R() &&, 0, Q_None, /* RValue */ true>::run();
+ TestCase11<R() const &&, 0, Q_Const, /* RValue */ true>::run();
+ TestCase11<R() volatile &&, 0, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R() const volatile &&, 0, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(...) &&, 0, Q_None, /* RValue */ true>::run();
+ TestCase11<R(...) const &&, 0, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(...) volatile &&, 0, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(...) const volatile &&, 0, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&) &&, 1, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&) const &&, 1, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&) volatile &&, 1, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&) const volatile &&, 1, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) &&, 1, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) const &&, 1, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) volatile &&, 1, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) const volatile &&, 1, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) &&, 2, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) const &&, 2, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) volatile &&, 2, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) const volatile &&, 2, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) &&, 2, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) const &&, 2, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) volatile &&, 2, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) const volatile &&, 2, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) &&, 3, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) const &&, 3, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) volatile &&, 3, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) const volatile &&, 3, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) &&, 3, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) const &&, 3, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) volatile &&, 3, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) const volatile &&, 3, Q_CV, /* RValue */ true>::run();
+
+ test_derived_from_ref_wrap();
+#endif
+} \ No newline at end of file
diff --git a/test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp b/test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
new file mode 100644
index 0000000000000..803c501f8c9e3
--- /dev/null
+++ b/test/libcxx/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
@@ -0,0 +1,216 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+// - Bullet 4 -- t1.*f
+// - Bullet 5 -- t1.get().*f // t1 is a reference wrapper.
+// - Bullet 6 -- (*t1).*f
+//
+// Overview:
+// Bullets 4, 5 and 6 handle the case where 'f' is a pointer to member object.
+// Bullet 4 only handles the cases where t1 is an object of type T or a
+// type derived from 'T'. Bullet 5 handles cases where 't1' is a reference_wrapper
+// and bullet 6 handles all other cases.
+//
+// Concerns:
+// 1) The return type is always an lvalue reference.
+// 2) The return type is not less cv-qualified that the object that contains it.
+// 3) The return type is not less cv-qualified than object type.
+// 4) The call object is perfectly forwarded.
+// 5) Classes that are publicly derived from 'T' are accepted as the call object
+// 6) All types that dereference to T or a type derived from T can be used
+// as the call object.
+// 7) Pointers to T or a type derived from T can be used as the call object.
+// 8) reference_wrapper's are properly unwrapped before invoking the function.
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+template <class Tp>
+struct TestMemberObject {
+ TestMemberObject() : object() {}
+ Tp object;
+private:
+ TestMemberObject(TestMemberObject const&);
+ TestMemberObject& operator=(TestMemberObject const&);
+};
+
+template <class ObjectType>
+struct TestCase {
+ public:
+
+ static void run() { TestCase().doTest(); }
+
+private:
+ typedef TestMemberObject<ObjectType> TestType;
+
+ //==========================================================================
+ // TEST DISPATCH
+ void doTest() {
+ typedef DerivedFromType<TestType> Derived;
+ TestType obj;
+ TestType* obj_ptr = &obj;
+ Derived der;
+ Derived* der_ptr = &der;
+ DerefToType<TestType> dref;
+ DerefPropType<TestType> dref2;
+ std::reference_wrapper<TestType> rref(obj);
+ std::reference_wrapper<Derived> drref(der);
+
+ {
+ typedef ObjectType (TestType::*MemPtr);
+ typedef ObjectType E;
+ MemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+#if TEST_STD_VER >= 11
+ runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+ runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+#endif
+ runTestNoPropDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType const (TestType::*CMemPtr);
+ typedef ObjectType const E;
+ CMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+#if TEST_STD_VER >= 11
+ runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+ runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+#endif
+ runTestNoPropDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType volatile (TestType::*VMemPtr);
+ typedef ObjectType volatile E;
+ VMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+#if TEST_STD_VER >= 11
+ runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+ runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+#endif
+ runTestNoPropDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType const volatile (TestType::*CVMemPtr);
+ typedef ObjectType const volatile E;
+ CVMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+#if TEST_STD_VER >= 11
+ runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+ runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+#endif
+ runTestNoPropDispatch<E>(M, dref, &dref.object.object);
+ }
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTestDispatch(Fn M, T& obj, ObjectType* expect) {
+ runTest<Expect &> (M, C_<T&>(obj), expect);
+ runTest<Expect const&> (M, C_<T const&>(obj), expect);
+ runTest<Expect volatile&> (M, C_<T volatile&>(obj), expect);
+ runTest<Expect const volatile&>(M, C_<T const volatile&>(obj), expect);
+#if TEST_STD_VER >= 11
+ runTest<Expect&&> (M, C_<T&&>(obj), expect);
+ runTest<Expect const&&> (M, C_<T const&&>(obj), expect);
+ runTest<Expect volatile&&> (M, C_<T volatile&&>(obj), expect);
+ runTest<Expect const volatile&&>(M, C_<T const volatile&&>(obj), expect);
+#endif
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTestPropCVDispatch(Fn M, T& obj, ObjectType* expect) {
+ runTest<Expect &> (M, obj, expect);
+ runTest<Expect const&> (M, makeConst(obj), expect);
+ runTest<Expect volatile&> (M, makeVolatile(obj), expect);
+ runTest<Expect const volatile&>(M, makeCV(obj), expect);
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTestNoPropDispatch(Fn M, T& obj, ObjectType* expect) {
+ runTest<Expect&>(M, C_<T &>(obj), expect);
+ runTest<Expect&>(M, C_<T const&>(obj), expect);
+ runTest<Expect&>(M, C_<T volatile&>(obj), expect);
+ runTest<Expect&>(M, C_<T const volatile&>(obj), expect);
+#if TEST_STD_VER >= 11
+ runTest<Expect&>(M, C_<T&&>(obj), expect);
+ runTest<Expect&>(M, C_<T const&&>(obj), expect);
+ runTest<Expect&>(M, C_<T volatile&&>(obj), expect);
+ runTest<Expect&>(M, C_<T const volatile&&>(obj), expect);
+#endif
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTest(Fn M, const T& obj, ObjectType* expect) {
+ static_assert((std::is_same<
+ decltype(std::__invoke(M, obj)), Expect
+ >::value), "");
+ Expect e = std::__invoke(M, obj);
+ assert(&e == expect);
+ }
+
+ template <class Expect, class Fn, class T>
+#if TEST_STD_VER >= 11
+ void runTest(Fn M, T&& obj, ObjectType* expect) {
+#else
+ void runTest(Fn M, T& obj, ObjectType* expect ) {
+#endif
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(M, std::forward<T>(obj))), Expect
+ >::value), "");
+ Expect e = std::__invoke(M, std::forward<T>(obj));
+ assert(&e == expect);
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(M, std::forward<T>(obj))), Expect
+ >::value), "");
+ Expect e = std::__invoke_constexpr(M, std::forward<T>(obj));
+ assert(&e == expect);
+ }
+#endif
+ }
+};
+
+
+
+
+int main() {
+ TestCase<ArgType>::run();
+ TestCase<ArgType const>::run();
+ TestCase<ArgType volatile>::run();
+ TestCase<ArgType const volatile>::run();
+ TestCase<ArgType*>::run();
+} \ No newline at end of file
diff --git a/test/libcxx/utilities/function.objects/func.require/bullet_7.pass.cpp b/test/libcxx/utilities/function.objects/func.require/bullet_7.pass.cpp
new file mode 100644
index 0000000000000..0d14a350c8974
--- /dev/null
+++ b/test/libcxx/utilities/function.objects/func.require/bullet_7.pass.cpp
@@ -0,0 +1,327 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// INVOKE (f, t1, t2, ..., tN)
+
+//------------------------------------------------------------------------------
+// TESTING INVOKE(f, t1, t2, ..., tN)
+// - Bullet 7 -- f(t2, ..., tN)
+//
+// Overview:
+// Bullet 7 handles the cases where the first argument is not a member
+// function.
+//
+// Concerns:
+// 1) Different types of callable objects are supported. Including
+// 1a) Free Function pointers and references.
+// 1b) Classes which provide a call operator
+// 1c) lambdas
+// 2) The callable objects are perfect forwarded.
+// 3) The arguments are perfect forwarded.
+// 4) Signatures which include varargs are supported.
+// 5) In C++03 3 extra arguments should be allowed.
+//
+// Plan:
+// 1) Define a set of free functions, 'SF', and class types with call
+// operators, 'SC', that address concerns 4 and 5. The free functions should
+// return 'FunctionID::setUncheckedCall()' and the call operators should
+// return 'MethodID::setUncheckedCall()'.
+//
+// 2) For each function 'f' in 'SF' and 'SC' attempt to call 'f'
+// using the correct number of arguments and cv-ref qualifiers. Check that
+// 'f' has been called using 'FunctionID::checkCall()' if 'f' is a free
+// function and 'MethodID::checkCall()' otherwise.
+
+
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+#include "invoke_helpers.h"
+
+
+//==============================================================================
+// freeFunction03 - A C++03 free function.
+void*& freeFunction03() {
+ return FunctionPtrID<void*&(), freeFunction03>::setUncheckedCall();
+}
+
+void*& freeFunction03(...) {
+ return FunctionPtrID<void*&(...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0>
+void*& freeFunction03(A0&) {
+ return FunctionPtrID<void*&(A0&), freeFunction03>::setUncheckedCall();
+}
+
+
+template <class A0>
+void*& freeFunction03(A0&, ...) {
+ return FunctionPtrID<void*&(A0&, ...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1>
+void*& freeFunction03(A0&, A1&) {
+ return FunctionPtrID<void*&(A0&, A1&), freeFunction03>::setUncheckedCall();
+}
+
+
+template <class A0, class A1>
+void*& freeFunction03(A0&, A1&, ...) {
+ return FunctionPtrID<void*&(A0&, A1&, ...), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1, class A2>
+void*& freeFunction03(A0&, A1&, A2&) {
+ return FunctionPtrID<void*&(A0&, A1&, A2&), freeFunction03>::setUncheckedCall();
+}
+
+template <class A0, class A1, class A2>
+void*& freeFunction03(A0&, A1&, A2&, ...) {
+ return FunctionPtrID<void*&(A0&, A1&, A2&, ...), freeFunction03>::setUncheckedCall();
+}
+
+//==============================================================================
+// Functor03 - C++03 compatible functor object
+struct Functor03 {
+ typedef void*& R;
+ typedef Functor03 C;
+#define F(Args, ...) \
+ __VA_ARGS__ R operator() Args { return MethodID<R(C::*) Args>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args const { return MethodID<R(C::*) Args const>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args volatile { return MethodID<R(C::*) Args volatile>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args const volatile { return MethodID<R(C::*) Args const volatile>::setUncheckedCall(); }
+#
+ F(())
+ F((A0&), template <class A0>)
+ F((A0&, A1&), template <class A0, class A1>)
+ F((A0&, A1&, A2&), template <class A0, class A1, class A2>)
+#undef F
+public:
+ Functor03() {}
+private:
+ Functor03(Functor03 const&);
+ Functor03& operator=(Functor03 const&);
+};
+
+
+#if TEST_STD_VER >= 11
+
+//==============================================================================
+// freeFunction11 - A C++11 free function.
+template <class ...Args>
+void*& freeFunction11(Args&&...) {
+ return FunctionPtrID<void*&(Args&&...), freeFunction11>::setUncheckedCall();
+}
+
+template <class ...Args>
+void*& freeFunction11(Args&&...,...) {
+ return FunctionPtrID<void*&(Args&&...,...), freeFunction11>::setUncheckedCall();
+}
+
+//==============================================================================
+// Functor11 - C++11 reference qualified test member functions.
+struct Functor11 {
+ typedef void*& R;
+ typedef Functor11 C;
+
+#define F(CV) \
+ template <class ...Args> \
+ R operator()(Args&&...) CV { return MethodID<R(C::*)(Args&&...) CV>::setUncheckedCall(); }
+#
+ F(&)
+ F(const &)
+ F(volatile &)
+ F(const volatile &)
+ F(&&)
+ F(const &&)
+ F(volatile &&)
+ F(const volatile &&)
+#undef F
+public:
+ Functor11() {}
+private:
+ Functor11(Functor11 const&);
+ Functor11& operator=(Functor11 const&);
+};
+
+#endif // TEST_STD_VER >= 11
+
+
+//==============================================================================
+// TestCaseFunctorImp - A test case for an operator() class method.
+// ClassType - The type of the call object.
+// CallSig - The function signature of the call operator being tested.
+// Arity - the arity of 'CallSig'
+// ObjCaster - Transformation function applied to call object.
+// ArgCaster - Transformation function applied to the extra arguments.
+template <class ClassType, class CallSig, int Arity,
+ class ObjCaster, class ArgCaster = LValueCaster>
+struct TestCaseFunctorImp {
+public:
+ static void run() {
+ typedef MethodID<CallSig ClassType::*> MID;
+ BasicTest<MID, Arity, ObjCaster, ArgCaster> t;
+ typedef ClassType T;
+ typedef DerivedFromType<T> D;
+ T obj;
+ D der;
+ t.runTest(obj);
+ t.runTest(der);
+ }
+};
+
+//==============================================================================
+// TestCaseFreeFunction - A test case for a free function.
+// CallSig - The function signature of the free function being tested.
+// FnPtr - The function being tested.
+// Arity - the arity of 'CallSig'
+// ArgCaster - Transformation function to be applied to the extra arguments.
+template <class CallSig, CallSig* FnPtr, int Arity, class ArgCaster>
+struct TestCaseFreeFunction {
+public:
+ static void run() {
+ typedef FunctionPtrID<CallSig, FnPtr> FID;
+ BasicTest<FID, Arity, LValueCaster, ArgCaster> t;
+
+ DerefToType<CallSig*> deref_to(FnPtr);
+ DerefToType<CallSig&> deref_to_ref(*FnPtr);
+
+ t.runTest(FnPtr);
+ t.runTest(*FnPtr);
+ t.runTest(deref_to);
+ t.runTest(deref_to_ref);
+ }
+};
+
+//==============================================================================
+// runTest Helpers
+//==============================================================================
+#if TEST_STD_VER >= 11
+template <class Sig, int Arity, class ArgCaster>
+void runFunctionTestCase11() {
+ TestCaseFreeFunction<Sig, freeFunction11, Arity, ArgCaster>();
+}
+#endif
+
+template <class Sig, int Arity, class ArgCaster>
+void runFunctionTestCase() {
+ TestCaseFreeFunction<Sig, freeFunction03, Arity, ArgCaster>();
+#if TEST_STD_VER >= 11
+ runFunctionTestCase11<Sig, Arity, ArgCaster>();
+#endif
+}
+
+template <class Sig, int Arity, class ObjCaster, class ArgCaster>
+void runFunctorTestCase() {
+ TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster, ArgCaster>::run();
+}
+
+template <class Sig, int Arity, class ObjCaster>
+void runFunctorTestCase() {
+ TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster>::run();
+}
+
+#if TEST_STD_VER >= 11
+// runTestCase - Run a test case for C++11 class functor types
+template <class Sig, int Arity, class ObjCaster, class ArgCaster = LValueCaster>
+void runFunctorTestCase11() {
+ TestCaseFunctorImp<Functor11, Sig, Arity, ObjCaster, ArgCaster>::run();
+}
+#endif
+
+// runTestCase - Run a test case for both function and functor types.
+template <class Sig, int Arity, class ArgCaster>
+void runTestCase() {
+ runFunctionTestCase<Sig, Arity, ArgCaster>();
+ runFunctorTestCase <Sig, Arity, LValueCaster, ArgCaster>();
+};
+
+int main() {
+ typedef void*& R;
+ typedef ArgType A;
+ typedef A const CA;
+
+ runTestCase< R(), 0, LValueCaster >();
+ runTestCase< R(A&), 1, LValueCaster >();
+ runTestCase< R(A&, A&), 2, LValueCaster >();
+ runTestCase< R(A&, A&, A&), 3, LValueCaster >();
+ runTestCase< R(CA&), 1, ConstCaster >();
+ runTestCase< R(CA&, CA&), 2, ConstCaster >();
+ runTestCase< R(CA&, CA&, CA&), 3, ConstCaster >();
+
+ runFunctionTestCase<R(...), 0, LValueCaster >();
+ runFunctionTestCase<R(A&, ...), 1, LValueCaster >();
+ runFunctionTestCase<R(A&, A&, ...), 2, LValueCaster >();
+ runFunctionTestCase<R(A&, A&, A&, ...), 3, LValueCaster >();
+
+#if TEST_STD_VER >= 11
+ runFunctionTestCase11<R(A&&), 1, MoveCaster >();
+ runFunctionTestCase11<R(A&&, ...), 1, MoveCaster >();
+#endif
+
+ runFunctorTestCase<R(), 0, LValueCaster >();
+ runFunctorTestCase<R() const, 0, ConstCaster >();
+ runFunctorTestCase<R() volatile, 0, VolatileCaster >();
+ runFunctorTestCase<R() const volatile, 0, CVCaster >();
+ runFunctorTestCase<R(A&), 1, LValueCaster >();
+ runFunctorTestCase<R(A&) const, 1, ConstCaster >();
+ runFunctorTestCase<R(A&) volatile, 1, VolatileCaster >();
+ runFunctorTestCase<R(A&) const volatile, 1, CVCaster >();
+ runFunctorTestCase<R(A&, A&), 2, LValueCaster >();
+ runFunctorTestCase<R(A&, A&) const, 2, ConstCaster >();
+ runFunctorTestCase<R(A&, A&) volatile, 2, VolatileCaster >();
+ runFunctorTestCase<R(A&, A&) const volatile, 2, CVCaster >();
+ runFunctorTestCase<R(A&, A&, A&), 3, LValueCaster >();
+ runFunctorTestCase<R(A&, A&, A&) const, 3, ConstCaster >();
+ runFunctorTestCase<R(A&, A&, A&) volatile, 3, VolatileCaster >();
+ runFunctorTestCase<R(A&, A&, A&) const volatile, 3, CVCaster >();
+ {
+ typedef ConstCaster CC;
+ runFunctorTestCase<R(CA&), 1, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&) const, 1, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&) volatile, 1, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&) const volatile, 1, CVCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&), 2, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) const, 2, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) volatile, 2, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) const volatile, 2, CVCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&), 3, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) const, 3, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) volatile, 3, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) const volatile, 3, CVCaster, CC>();
+ }
+
+#if TEST_STD_VER >= 11
+ runFunctorTestCase11<R() &, 0, LValueCaster >();
+ runFunctorTestCase11<R() const &, 0, ConstCaster >();
+ runFunctorTestCase11<R() volatile &, 0, VolatileCaster >();
+ runFunctorTestCase11<R() const volatile &, 0, CVCaster >();
+ runFunctorTestCase11<R() &&, 0, MoveCaster >();
+ runFunctorTestCase11<R() const &&, 0, MoveConstCaster >();
+ runFunctorTestCase11<R() volatile &&, 0, MoveVolatileCaster >();
+ runFunctorTestCase11<R() const volatile &&, 0, MoveCVCaster >();
+ {
+ typedef MoveCaster MC;
+ runFunctorTestCase11<R(A&&) &, 1, LValueCaster, MC>();
+ runFunctorTestCase11<R(A&&) const &, 1, ConstCaster, MC>();
+ runFunctorTestCase11<R(A&&) volatile &, 1, VolatileCaster, MC>();
+ runFunctorTestCase11<R(A&&) const volatile &, 1, CVCaster, MC>();
+ runFunctorTestCase11<R(A&&) &&, 1, MoveCaster, MC>();
+ runFunctorTestCase11<R(A&&) const &&, 1, MoveConstCaster, MC>();
+ runFunctorTestCase11<R(A&&) volatile &&, 1, MoveVolatileCaster, MC>();
+ runFunctorTestCase11<R(A&&) const volatile &&, 1, MoveCVCaster, MC>();
+ }
+#endif
+}
diff --git a/test/libcxx/utilities/function.objects/func.require/invoke.pass.cpp b/test/libcxx/utilities/function.objects/func.require/invoke.pass.cpp
new file mode 100644
index 0000000000000..1d4251354dc53
--- /dev/null
+++ b/test/libcxx/utilities/function.objects/func.require/invoke.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// [func.require]
+
+#include <type_traits>
+#include <functional>
+
+#include "test_macros.h"
+
+template <typename T, int N>
+struct Array
+{
+ typedef T type[N];
+};
+
+struct Type
+{
+ Array<char, 1>::type& f1();
+ Array<char, 2>::type& f2() const;
+#if TEST_STD_VER >= 11
+ Array<char, 1>::type& g1() &;
+ Array<char, 2>::type& g2() const &;
+ Array<char, 3>::type& g3() &&;
+ Array<char, 4>::type& g4() const &&;
+#endif
+};
+
+int main()
+{
+ static_assert(sizeof(std::__invoke(&Type::f1, std::declval<Type >())) == 1, "");
+ static_assert(sizeof(std::__invoke(&Type::f2, std::declval<Type const >())) == 2, "");
+#if TEST_STD_VER >= 11
+ static_assert(sizeof(std::__invoke(&Type::g1, std::declval<Type &>())) == 1, "");
+ static_assert(sizeof(std::__invoke(&Type::g2, std::declval<Type const &>())) == 2, "");
+ static_assert(sizeof(std::__invoke(&Type::g3, std::declval<Type &&>())) == 3, "");
+ static_assert(sizeof(std::__invoke(&Type::g4, std::declval<Type const&&>())) == 4, "");
+#endif
+}
diff --git a/test/libcxx/utilities/function.objects/func.require/invoke_helpers.h b/test/libcxx/utilities/function.objects/func.require/invoke_helpers.h
new file mode 100644
index 0000000000000..7e7a5fd24a627
--- /dev/null
+++ b/test/libcxx/utilities/function.objects/func.require/invoke_helpers.h
@@ -0,0 +1,456 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef INVOKE_HELPERS_H
+#define INVOKE_HELPERS_H
+
+#include <type_traits>
+#include <cassert>
+#include <functional>
+
+#include "test_macros.h"
+
+template <int I>
+struct Int : public std::integral_constant<int, I> {};
+
+template <bool P>
+struct Bool : public std::integral_constant<bool, P> {};
+
+struct Q_None {
+ template <class T>
+ struct apply { typedef T type; };
+};
+
+struct Q_Const {
+ template <class T>
+ struct apply { typedef T const type; };
+};
+
+struct Q_Volatile {
+ template <class T>
+ struct apply { typedef T volatile type; };
+};
+
+struct Q_CV {
+ template <class T>
+ struct apply { typedef T const volatile type; };
+};
+
+// Caster - A functor object that performs cv-qualifier and value category
+// conversions.
+// QualTag - A metafunction type that applies cv-qualifiers to its argument.
+// RValue - True if the resulting object should be an RValue reference.
+// False otherwise.
+template <class QualTag, bool RValue = false>
+struct Caster {
+ template <class T>
+ struct apply {
+ typedef typename std::remove_reference<T>::type RawType;
+ typedef typename QualTag::template apply<RawType>::type CVType;
+#if TEST_STD_VER >= 11
+ typedef typename std::conditional<RValue,
+ CVType&&, CVType&
+ >::type type;
+#else
+ typedef CVType& type;
+#endif
+ };
+
+ template <class T>
+ typename apply<T>::type
+ operator()(T& obj) const {
+ typedef typename apply<T>::type OutType;
+ return static_cast<OutType>(obj);
+ }
+};
+
+typedef Caster<Q_None> LValueCaster;
+typedef Caster<Q_Const> ConstCaster;
+typedef Caster<Q_Volatile> VolatileCaster;
+typedef Caster<Q_CV> CVCaster;
+typedef Caster<Q_None, true> MoveCaster;
+typedef Caster<Q_Const, true> MoveConstCaster;
+typedef Caster<Q_Volatile, true> MoveVolatileCaster;
+typedef Caster<Q_CV, true> MoveCVCaster;
+
+
+template <class Tp>
+Tp const& makeConst(Tp& ref) { return ref; }
+
+template <class Tp>
+Tp const* makeConst(Tp* ptr) { return ptr; }
+
+template <class Tp>
+std::reference_wrapper<const Tp> makeConst(std::reference_wrapper<Tp>& ref) {
+ return std::reference_wrapper<const Tp>(ref.get());
+}
+
+template <class Tp>
+Tp volatile& makeVolatile(Tp& ref) { return ref; }
+
+template <class Tp>
+Tp volatile* makeVolatile(Tp* ptr) { return ptr; }
+
+template <class Tp>
+std::reference_wrapper<volatile Tp> makeVolatile(std::reference_wrapper<Tp>& ref) {
+ return std::reference_wrapper<volatile Tp>(ref.get());
+}
+
+template <class Tp>
+Tp const volatile& makeCV(Tp& ref) { return ref; }
+
+template <class Tp>
+Tp const volatile* makeCV(Tp* ptr) { return ptr; }
+
+template <class Tp>
+std::reference_wrapper<const volatile Tp> makeCV(std::reference_wrapper<Tp>& ref) {
+ return std::reference_wrapper<const volatile Tp>(ref.get());
+}
+
+// A shorter name for 'static_cast'
+template <class QualType, class Tp>
+QualType C_(Tp& v) { return static_cast<QualType>(v); };
+
+//==============================================================================
+// ArgType - A non-copyable type intended to be used as a dummy argument type
+// to test functions.
+struct ArgType {
+ int value;
+ explicit ArgType(int val = 0) : value(val) {}
+private:
+ ArgType(ArgType const&);
+ ArgType& operator=(ArgType const&);
+};
+
+//==============================================================================
+// DerivedFromBase - A type that derives from it's template argument 'Base'
+template <class Base>
+struct DerivedFromType : public Base {
+ DerivedFromType() : Base() {}
+ template <class Tp>
+ explicit DerivedFromType(Tp const& t) : Base(t) {}
+};
+
+//==============================================================================
+// DerefToType - A type that dereferences to it's template argument 'To'.
+// The cv-ref qualifiers of the 'DerefToType' object do not propagate
+// to the resulting 'To' object.
+template <class To>
+struct DerefToType {
+ To object;
+
+ DerefToType() {}
+
+ template <class Up>
+ explicit DerefToType(Up const& val) : object(val) {}
+
+ To& operator*() const volatile { return const_cast<To&>(object); }
+};
+
+//==============================================================================
+// DerefPropToType - A type that dereferences to it's template argument 'To'.
+// The cv-ref qualifiers of the 'DerefPropToType' object propagate
+// to the resulting 'To' object.
+template <class To>
+struct DerefPropType {
+ To object;
+
+ DerefPropType() {}
+
+ template <class Up>
+ explicit DerefPropType(Up const& val) : object(val) {}
+
+#if TEST_STD_VER < 11
+ To& operator*() { return object; }
+ To const& operator*() const { return object; }
+ To volatile& operator*() volatile { return object; }
+ To const volatile& operator*() const volatile { return object; }
+#else
+ To& operator*() & { return object; }
+ To const& operator*() const & { return object; }
+ To volatile& operator*() volatile & { return object; }
+ To const volatile& operator*() const volatile & { return object; }
+ To&& operator*() && { return static_cast<To &&>(object); }
+ To const&& operator*() const && { return static_cast<To const&&>(object); }
+ To volatile&& operator*() volatile && { return static_cast<To volatile&&>(object); }
+ To const volatile&& operator*() const volatile && { return static_cast<To const volatile&&>(object); }
+#endif
+};
+
+//==============================================================================
+// MethodID - A type that uniquely identifies a member function for a class.
+// This type is used to communicate between the member functions being tested
+// and the tests invoking them.
+// - Test methods should call 'setUncheckedCall()' whenever they are invoked.
+// - Tests consume the unchecked call using checkCall(<return-value>)` to assert
+// that the method has been called and that the return value of `__invoke`
+// matches what the method actually returned.
+template <class T>
+struct MethodID {
+ typedef void* IDType;
+
+ static int dummy; // A dummy memory location.
+ static void* id; // The "ID" is the value of this pointer.
+ static bool unchecked_call; // Has a call happened that has not been checked.
+
+ static void*& setUncheckedCall() {
+ assert(unchecked_call == false);
+ unchecked_call = true;
+ return id;
+ }
+
+ static bool checkCalled(void*& return_value) {
+ bool old = unchecked_call;
+ unchecked_call = false;
+ return old && id == return_value && &id == &return_value;
+ }
+};
+
+template <class T> int MethodID<T>::dummy = 0;
+template <class T> void* MethodID<T>::id = (void*)&MethodID<T>::dummy;
+template <class T> bool MethodID<T>::unchecked_call = false;
+
+
+//==============================================================================
+// FunctionPtrID - Like MethodID but for free function pointers.
+template <class T, T*>
+struct FunctionPtrID {
+ static int dummy; // A dummy memory location.
+ static void* id; // The "ID" is the value of this pointer.
+ static bool unchecked_call; // Has a call happened that has not been checked.
+
+ static void*& setUncheckedCall() {
+ assert(unchecked_call == false);
+ unchecked_call = true;
+ return id;
+ }
+
+ static bool checkCalled(void*& return_value) {
+ bool old = unchecked_call;
+ unchecked_call = false;
+ return old && id == return_value && &id == &return_value;
+ }
+};
+
+template <class T, T* Ptr> int FunctionPtrID<T, Ptr>::dummy = 0;
+template <class T, T* Ptr> void* FunctionPtrID<T, Ptr>::id = (void*)&FunctionPtrID<T, Ptr>::dummy;
+template <class T, T* Ptr> bool FunctionPtrID<T, Ptr>::unchecked_call = false;
+
+//==============================================================================
+// BasicTest - The basic test structure for everything except
+// member object pointers.
+// ID - The "Function Identifier" type used either MethodID or FunctionPtrID.
+// Arity - The Arity of the call signature.
+// ObjectCaster - The object transformation functor type.
+// ArgCaster - The extra argument transformation functor type.
+template <class ID, int Arity, class ObjectCaster = LValueCaster,
+ class ArgCaster = LValueCaster>
+struct BasicTest {
+ template <class ObjectT>
+ void runTest(ObjectT& object) {
+ Int<Arity> A;
+ runTestImp(A, object);
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTest(MethodPtr ptr, ObjectT& object) {
+ Int<Arity> A;
+ runTestImp(A, ptr, object);
+ }
+
+private:
+ typedef void*& CallRet;
+ ObjectCaster object_cast;
+ ArgCaster arg_cast;
+ ArgType a0, a1, a2;
+
+ //==========================================================================
+ // BULLET 1, 2 AND 3 TEST METHODS
+ //==========================================================================
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<0>, MethodPtr ptr, ObjectT& object) {
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(ptr, object_cast(object)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object));
+ assert(ID::checkCalled(ret));
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(ptr, object_cast(object)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke_constexpr(ptr, object_cast(object));
+ assert(ID::checkCalled(ret));
+ }
+#endif
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<1>, MethodPtr ptr, ObjectT& object) {
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0));
+ assert(ID::checkCalled(ret));
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(ptr, object_cast(object), arg_cast(a0)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke_constexpr(ptr, object_cast(object), arg_cast(a0));
+ assert(ID::checkCalled(ret));
+ }
+#endif
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<2>, MethodPtr ptr, ObjectT& object) {
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1));
+ assert(ID::checkCalled(ret));
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(ptr, object_cast(object), arg_cast(a0), arg_cast(a1)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke_constexpr(ptr, object_cast(object), arg_cast(a0), arg_cast(a1));
+ assert(ID::checkCalled(ret));
+ }
+#endif
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<3>, MethodPtr ptr, ObjectT& object) {
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
+ assert(ID::checkCalled(ret));
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke_constexpr(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
+ assert(ID::checkCalled(ret));
+ }
+#endif
+ }
+
+ //==========================================================================
+ // BULLET 7 TEST METHODS
+ //==========================================================================
+ template <class ObjectT>
+ void runTestImp(Int<0>, ObjectT& object) {
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(object_cast(object)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object));
+ assert(ID::checkCalled(ret));
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(object_cast(object)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke_constexpr(object_cast(object));
+ assert(ID::checkCalled(ret));
+ }
+#endif
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<1>, ObjectT& object) {
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(object_cast(object), arg_cast(a0)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0));
+ assert(ID::checkCalled(ret));
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(object_cast(object), arg_cast(a0)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke_constexpr(object_cast(object), arg_cast(a0));
+ assert(ID::checkCalled(ret));
+ }
+#endif
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<2>, ObjectT& object) {
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1));
+ assert(ID::checkCalled(ret));
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(object_cast(object), arg_cast(a0), arg_cast(a1)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke_constexpr(object_cast(object), arg_cast(a0), arg_cast(a1));
+ assert(ID::checkCalled(ret));
+ }
+#endif
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<3>, ObjectT& object) {
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
+ assert(ID::checkCalled(ret));
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert((std::is_same<
+ decltype(std::__invoke_constexpr(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)))
+ , CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke_constexpr(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
+ assert(ID::checkCalled(ret));
+ }
+#endif
+ }
+};
+
+#endif // INVOKE_HELPERS_H
diff --git a/test/libcxx/utilities/function.objects/version.pass.cpp b/test/libcxx/utilities/function.objects/version.pass.cpp
new file mode 100644
index 0000000000000..99d731a74543c
--- /dev/null
+++ b/test/libcxx/utilities/function.objects/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+#include <functional>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/utilities/memory/version.pass.cpp b/test/libcxx/utilities/memory/version.pass.cpp
new file mode 100644
index 0000000000000..790c08a3bd2d9
--- /dev/null
+++ b/test/libcxx/utilities/memory/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+#include <memory>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/utilities/meta/is_referenceable.pass.cpp b/test/libcxx/utilities/meta/is_referenceable.pass.cpp
new file mode 100644
index 0000000000000..42b1f2dc3014b
--- /dev/null
+++ b/test/libcxx/utilities/meta/is_referenceable.pass.cpp
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+//
+
+// __is_referenceable<Tp>
+//
+// [defns.referenceable] defines "a referenceable type" as:
+// An object type, a function type that does not have cv-qualifiers
+// or a ref-qualifier, or a reference type.
+//
+
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+struct Foo {};
+
+static_assert((!std::__is_referenceable<void>::value), "");
+static_assert(( std::__is_referenceable<int>::value), "");
+static_assert(( std::__is_referenceable<int[3]>::value), "");
+static_assert(( std::__is_referenceable<int[]>::value), "");
+static_assert(( std::__is_referenceable<int &>::value), "");
+static_assert(( std::__is_referenceable<const int &>::value), "");
+static_assert(( std::__is_referenceable<int *>::value), "");
+static_assert(( std::__is_referenceable<const int *>::value), "");
+static_assert(( std::__is_referenceable<Foo>::value), "");
+static_assert(( std::__is_referenceable<const Foo>::value), "");
+static_assert(( std::__is_referenceable<Foo &>::value), "");
+static_assert(( std::__is_referenceable<const Foo &>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<Foo &&>::value), "");
+static_assert(( std::__is_referenceable<const Foo &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<int __attribute__((__vector_size__( 8)))>::value), "");
+static_assert(( std::__is_referenceable<const int __attribute__((__vector_size__( 8)))>::value), "");
+static_assert(( std::__is_referenceable<float __attribute__((__vector_size__(16)))>::value), "");
+static_assert(( std::__is_referenceable<const float __attribute__((__vector_size__(16)))>::value), "");
+
+// Functions without cv-qualifiers are referenceable
+static_assert(( std::__is_referenceable<void ()>::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::__is_referenceable<void () const>::value), "");
+static_assert((!std::__is_referenceable<void () &>::value), "");
+static_assert((!std::__is_referenceable<void () const &>::value), "");
+static_assert((!std::__is_referenceable<void () &&>::value), "");
+static_assert((!std::__is_referenceable<void () const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (int)>::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::__is_referenceable<void (int) const>::value), "");
+static_assert((!std::__is_referenceable<void (int) &>::value), "");
+static_assert((!std::__is_referenceable<void (int) const &>::value), "");
+static_assert((!std::__is_referenceable<void (int) &&>::value), "");
+static_assert((!std::__is_referenceable<void (int) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (int, float)>::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::__is_referenceable<void (int, float) const>::value), "");
+static_assert((!std::__is_referenceable<void (int, float) &>::value), "");
+static_assert((!std::__is_referenceable<void (int, float) const &>::value), "");
+static_assert((!std::__is_referenceable<void (int, float) &&>::value), "");
+static_assert((!std::__is_referenceable<void (int, float) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (int, float, Foo &)>::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::__is_referenceable<void (int, float, Foo &) const>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, Foo &) &>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, Foo &) const &>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, Foo &) &&>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, Foo &) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (...)>::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::__is_referenceable<void (...) const>::value), "");
+static_assert((!std::__is_referenceable<void (...) &>::value), "");
+static_assert((!std::__is_referenceable<void (...) const &>::value), "");
+static_assert((!std::__is_referenceable<void (...) &&>::value), "");
+static_assert((!std::__is_referenceable<void (...) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (int, ...)>::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::__is_referenceable<void (int, ...) const>::value), "");
+static_assert((!std::__is_referenceable<void (int, ...) &>::value), "");
+static_assert((!std::__is_referenceable<void (int, ...) const &>::value), "");
+static_assert((!std::__is_referenceable<void (int, ...) &&>::value), "");
+static_assert((!std::__is_referenceable<void (int, ...) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (int, float, ...)>::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::__is_referenceable<void (int, float, ...) const>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, ...) &>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, ...) const &>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, ...) &&>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, ...) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (int, float, Foo &, ...)>::value), "");
+#if TEST_STD_VER >= 11
+static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) &>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const &>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) &&>::value), "");
+static_assert((!std::__is_referenceable<void (int, float, Foo &, ...) const &&>::value), "");
+#endif
+
+// member functions with or without cv-qualifiers are referenceable
+static_assert(( std::__is_referenceable<void (Foo::*)()>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)() const>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<void (Foo::*)() &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)() const &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)() &&>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)() const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (Foo::*)(int)>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int) const>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<void (Foo::*)(int) &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int) const &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int) &&>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float)>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float) &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float) &&>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &)>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) &&>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (Foo::*)(...)>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(...) const>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<void (Foo::*)(...) &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(...) const &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(...) &&>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(...) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (Foo::*)(int, ...)>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) &&>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, ...) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...)>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) &&>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, ...) const &&>::value), "");
+#endif
+
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...)>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const>::value), "");
+#if TEST_STD_VER >= 11
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) &&>::value), "");
+static_assert(( std::__is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &&>::value), "");
+#endif
+
+int main () {}
diff --git a/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
new file mode 100644
index 0000000000000..1c715e04970c7
--- /dev/null
+++ b/test/libcxx/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// extension
+
+// template <typename _Tp> struct __has_operator_addressof
+
+
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+
+struct A
+{
+};
+
+struct B
+{
+ constexpr B* operator&() const;
+};
+
+struct D;
+
+struct C
+{
+ template <class U>
+ D operator,(U&&);
+};
+
+struct E
+{
+ constexpr C operator&() const;
+};
+
+struct F {};
+constexpr F* operator&(F const &) { return nullptr; }
+
+struct G {};
+constexpr G* operator&(G &&) { return nullptr; }
+
+struct H {};
+constexpr H* operator&(H const &&) { return nullptr; }
+
+struct J
+{
+ constexpr J* operator&() const &&;
+};
+
+#endif // _LIBCPP_HAS_NO_CONSTEXPR
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ static_assert(std::__has_operator_addressof<int>::value == false, "");
+ static_assert(std::__has_operator_addressof<A>::value == false, "");
+ static_assert(std::__has_operator_addressof<B>::value == true, "");
+ static_assert(std::__has_operator_addressof<E>::value == true, "");
+ static_assert(std::__has_operator_addressof<F>::value == true, "");
+ static_assert(std::__has_operator_addressof<G>::value == true, "");
+ static_assert(std::__has_operator_addressof<H>::value == true, "");
+ static_assert(std::__has_operator_addressof<J>::value == true, "");
+#endif // _LIBCPP_HAS_NO_CONSTEXPR
+}
diff --git a/test/libcxx/utilities/meta/version.pass.cpp b/test/libcxx/utilities/meta/version.pass.cpp
new file mode 100644
index 0000000000000..3a1033bbb5605
--- /dev/null
+++ b/test/libcxx/utilities/meta/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <type_traits>
+
+#include <type_traits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/utilities/ratio/version.pass.cpp b/test/libcxx/utilities/ratio/version.pass.cpp
new file mode 100644
index 0000000000000..26c455fb0a9ab
--- /dev/null
+++ b/test/libcxx/utilities/ratio/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ratio>
+
+#include <ratio>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/utilities/template.bitset/version.pass.cpp b/test/libcxx/utilities/template.bitset/version.pass.cpp
new file mode 100644
index 0000000000000..5ae984c0092df
--- /dev/null
+++ b/test/libcxx/utilities/template.bitset/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <bitset>
+
+#include <bitset>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/utilities/time/version.pass.cpp b/test/libcxx/utilities/time/version.pass.cpp
new file mode 100644
index 0000000000000..bfa3f6d6797d9
--- /dev/null
+++ b/test/libcxx/utilities/time/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/utilities/tuple/version.pass.cpp b/test/libcxx/utilities/tuple/version.pass.cpp
new file mode 100644
index 0000000000000..2fdbb5d2784a8
--- /dev/null
+++ b/test/libcxx/utilities/tuple/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+#include <tuple>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/test/libcxx/utilities/type.index/version.pass.cpp b/test/libcxx/utilities/type.index/version.pass.cpp
new file mode 100644
index 0000000000000..26f462042fd33
--- /dev/null
+++ b/test/libcxx/utilities/type.index/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+#include <typeindex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
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
new file mode 100644
index 0000000000000..c012ac6265e01
--- /dev/null
+++ b/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// Test that we properly provide the old non-trivial copy operations
+// when the ABI macro is defined.
+
+#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
+#include <utility>
+#include <cassert>
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+struct Dummy {
+ Dummy(Dummy const&) = delete;
+ Dummy(Dummy &&) = default;
+};
+#endif
+
+int main()
+{
+ typedef std::pair<int, short> P;
+ {
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copyable<P>::value, "");
+ }
+#if TEST_STD_VER >= 11
+ {
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copyable<P>::value, "");
+ }
+ {
+ using P1 = std::pair<Dummy, int>;
+ // These lines fail because the non-trivial constructors do not provide
+ // SFINAE.
+ // static_assert(!std::is_copy_constructible<P1>::value, "");
+ // static_assert(!std::is_trivially_copy_constructible<P1>::value, "");
+ static_assert(std::is_move_constructible<P1>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P1>::value, "");
+ static_assert(!std::is_trivially_copyable<P>::value, "");
+ }
+#endif
+}
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
new file mode 100644
index 0000000000000..ec9cc7ec3e020
--- /dev/null
+++ b/test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move_ABI.pass.cpp
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// The test fails due to the missing is_trivially_constructible intrinsic.
+// XFAIL: gcc-4.9
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// Test that we properly provide the trivial copy operations by default.
+
+// FreeBSD provides the old ABI. This test checks the new ABI so we need
+// to manually turn it on.
+#if defined(__FreeBSD__)
+#define _LIBCPP_ABI_UNSTABLE
+#endif
+
+#include <utility>
+#include <type_traits>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+
+#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+#error Non-trivial ctor ABI macro defined
+#endif
+
+template <class T>
+struct HasTrivialABI : std::integral_constant<bool,
+ std::is_trivially_destructible<T>::value
+ && (!std::is_copy_constructible<T>::value || std::is_trivially_copy_constructible<T>::value)
+#if TEST_STD_VER >= 11
+ && (!std::is_move_constructible<T>::value || std::is_trivially_move_constructible<T>::value)
+#endif
+> {};
+
+#if TEST_STD_VER >= 11
+struct NonTrivialDtor {
+ NonTrivialDtor(NonTrivialDtor const&) = default;
+ ~NonTrivialDtor();
+};
+NonTrivialDtor::~NonTrivialDtor() {}
+static_assert(!HasTrivialABI<NonTrivialDtor>::value, "");
+
+struct NonTrivialCopy {
+ NonTrivialCopy(NonTrivialCopy const&);
+};
+NonTrivialCopy::NonTrivialCopy(NonTrivialCopy const&) {}
+static_assert(!HasTrivialABI<NonTrivialCopy>::value, "");
+
+struct NonTrivialMove {
+ NonTrivialMove(NonTrivialMove const&) = default;
+ NonTrivialMove(NonTrivialMove&&);
+};
+NonTrivialMove::NonTrivialMove(NonTrivialMove&&) {}
+static_assert(!HasTrivialABI<NonTrivialMove>::value, "");
+
+struct DeletedCopy {
+ DeletedCopy(DeletedCopy const&) = delete;
+ DeletedCopy(DeletedCopy&&) = default;
+};
+static_assert(HasTrivialABI<DeletedCopy>::value, "");
+
+struct TrivialMove {
+ TrivialMove(TrivialMove &&) = default;
+};
+static_assert(HasTrivialABI<TrivialMove>::value, "");
+
+struct Trivial {
+ Trivial(Trivial const&) = default;
+};
+static_assert(HasTrivialABI<Trivial>::value, "");
+#endif
+
+
+int main()
+{
+ {
+ typedef std::pair<int, short> P;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::pair<int, short> P;
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialDtor, int>;
+ static_assert(!std::is_trivially_destructible<P>::value, "");
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(!HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialCopy, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(!HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialMove, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(!HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<DeletedCopy, int>;
+ static_assert(!std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<Trivial, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<TrivialMove, int>;
+ static_assert(!std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
+#endif
+}
diff --git a/test/libcxx/utilities/utility/version.pass.cpp b/test/libcxx/utilities/utility/version.pass.cpp
new file mode 100644
index 0000000000000..77d145d944574
--- /dev/null
+++ b/test/libcxx/utilities/utility/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+#include <utility>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}