summaryrefslogtreecommitdiff
path: root/test/std/utilities/memory
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/utilities/memory')
-rw-r--r--test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp22
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp38
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp60
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp143
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp42
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp80
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp70
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp68
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp55
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp55
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp62
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.pass.cpp52
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp42
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp40
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp40
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp40
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp79
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp63
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp55
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp31
-rw-r--r--test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp79
-rw-r--r--test/std/utilities/memory/allocator.traits/value_type.pass.cpp31
-rw-r--r--test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp33
-rw-r--r--test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp14
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp31
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp39
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp52
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp142
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp27
-rw-r--r--test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp116
-rw-r--r--test/std/utilities/memory/default.allocator/allocator_types.pass.cpp55
-rw-r--r--test/std/utilities/memory/default.allocator/allocator_void.pass.cpp36
-rw-r--r--test/std/utilities/memory/pointer.traits/difference_type.pass.cpp25
-rw-r--r--test/std/utilities/memory/pointer.traits/element_type.pass.cpp25
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.pass.cpp32
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp48
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp48
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp49
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp69
-rw-r--r--test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp32
-rw-r--r--test/std/utilities/memory/pointer.traits/rebind.pass.cpp29
-rw-r--r--test/std/utilities/memory/ptr.align/align.pass.cpp84
-rw-r--r--test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp51
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp75
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp74
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp75
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp72
-rw-r--r--test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.pass.cpp48
-rw-r--r--test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp44
-rw-r--r--test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/deleter.h182
-rw-r--r--test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp45
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp17
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp17
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp17
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp17
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp33
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp48
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp34
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp26
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp24
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp32
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp36
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp26
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp44
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp34
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp38
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp47
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp30
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp87
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp86
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp87
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp46
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp36
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp95
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp67
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp43
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp27
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp50
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp64
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp24
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp37
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp47
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp30
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp34
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp38
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp75
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp38
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp57
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp36
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp41
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp68
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp67
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp61
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp35
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp46
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp84
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp142
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp143
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp56
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp51
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp62
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp118
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp118
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp79
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp35
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp46
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp35
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp63
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp95
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp78
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp99
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp60
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp55
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp58
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp66
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp44
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp27
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp50
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp66
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp29
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp59
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp23
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp39
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp24
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp37
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp47
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp30
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp69
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp86
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp100
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp77
-rw-r--r--test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp23
-rw-r--r--test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp24
-rw-r--r--test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp23
-rw-r--r--test/std/utilities/memory/util.smartptr/nothing_to_do.pass.cpp12
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp53
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp30
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp30
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp53
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp58
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp53
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp58
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp39
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp39
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp37
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp37
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp38
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp38
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h68
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp26
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp67
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp113
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp121
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp121
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp123
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp123
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp113
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp57
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp57
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp69
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp69
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp30
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp104
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp22
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp22
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp47
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp85
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp46
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp63
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp46
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp48
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp89
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp47
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp64
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp62
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp62
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp97
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp109
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp61
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp73
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp115
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp79
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp78
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp118
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp80
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.pass.cpp61
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp29
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp62
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp64
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp79
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp88
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp104
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp29
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp25
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp29
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp28
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp28
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp104
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp26
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp82
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp61
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp78
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp78
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp25
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp95
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp114
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp108
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp41
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp49
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp46
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp58
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp27
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp31
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp49
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp31
-rw-r--r--test/std/utilities/memory/version.pass.cpp20
313 files changed, 17316 insertions, 0 deletions
diff --git a/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp b/test/std/utilities/memory/allocator.tag/allocator_arg.pass.cpp
new file mode 100644
index 0000000000000..636998aa0d726
--- /dev/null
+++ b/test/std/utilities/memory/allocator.tag/allocator_arg.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// struct allocator_arg_t { };
+// const allocator_arg_t allocator_arg = allocator_arg_t();
+
+#include <memory>
+
+void test(std::allocator_arg_t) {}
+
+int main()
+{
+ test(std::allocator_arg);
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
new file mode 100644
index 0000000000000..490fdf5d332bb
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static pointer allocate(allocator_type& a, size_type n);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ value_type* allocate(std::size_t n)
+ {
+ assert(n == 10);
+ return (value_type*)0xDEADBEEF;
+ }
+};
+
+int main()
+{
+ A<int> a;
+ assert(std::allocator_traits<A<int> >::allocate(a, 10) == (int*)0xDEADBEEF);
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
new file mode 100644
index 0000000000000..079db3526ac78
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ value_type* allocate(std::size_t n)
+ {
+ assert(n == 10);
+ return (value_type*)0xDEADBEEF;
+ }
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+ value_type* allocate(std::size_t n)
+ {
+ assert(n == 12);
+ return (value_type*)0xEEADBEEF;
+ }
+ value_type* allocate(std::size_t n, const void* p)
+ {
+ assert(n == 11);
+ assert(p == 0);
+ return (value_type*)0xFEADBEEF;
+ }
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ A<int> a;
+ assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == (int*)0xDEADBEEF);
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ B<int> b;
+ assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == (int*)0xFEADBEEF);
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
new file mode 100644
index 0000000000000..634019758e703
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// template <class Ptr, class... Args>
+// static void construct(allocator_type& a, Ptr p, Args&&... args);
+// ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+};
+
+int b_construct = 0;
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ template <class U, class ...Args>
+ void construct(U* p, Args&& ...args)
+ {
+ ++b_construct;
+ ::new ((void*)p) U(std::forward<Args>(args)...);
+ }
+#endif // _LIBCPP_HAS_NO_VARIADICS
+};
+
+struct A0
+{
+ static int count;
+ A0() {++count;}
+};
+
+int A0::count = 0;
+
+struct A1
+{
+ static int count;
+ A1(char c)
+ {
+ assert(c == 'c');
+ ++count;
+ }
+};
+
+int A1::count = 0;
+
+struct A2
+{
+ static int count;
+ A2(char c, int i)
+ {
+ assert(c == 'd');
+ assert(i == 5);
+ ++count;
+ }
+};
+
+int A2::count = 0;
+
+int main()
+{
+ {
+ A0::count = 0;
+ A<int> a;
+ std::aligned_storage<sizeof(A0)>::type a0;
+ assert(A0::count == 0);
+ std::allocator_traits<A<int> >::construct(a, (A0*)&a0);
+ assert(A0::count == 1);
+ }
+ {
+ A1::count = 0;
+ A<int> a;
+ std::aligned_storage<sizeof(A1)>::type a1;
+ assert(A1::count == 0);
+ std::allocator_traits<A<int> >::construct(a, (A1*)&a1, 'c');
+ assert(A1::count == 1);
+ }
+ {
+ A2::count = 0;
+ A<int> a;
+ std::aligned_storage<sizeof(A2)>::type a2;
+ assert(A2::count == 0);
+ std::allocator_traits<A<int> >::construct(a, (A2*)&a2, 'd', 5);
+ assert(A2::count == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ {
+ A0::count = 0;
+ b_construct = 0;
+ B<int> b;
+ std::aligned_storage<sizeof(A0)>::type a0;
+ assert(A0::count == 0);
+ assert(b_construct == 0);
+ std::allocator_traits<B<int> >::construct(b, (A0*)&a0);
+ assert(A0::count == 1);
+ assert(b_construct == 1);
+ }
+ {
+ A1::count = 0;
+ b_construct = 0;
+ B<int> b;
+ std::aligned_storage<sizeof(A1)>::type a1;
+ assert(A1::count == 0);
+ assert(b_construct == 0);
+ std::allocator_traits<B<int> >::construct(b, (A1*)&a1, 'c');
+ assert(A1::count == 1);
+ assert(b_construct == 1);
+ }
+ {
+ A2::count = 0;
+ b_construct = 0;
+ B<int> b;
+ std::aligned_storage<sizeof(A2)>::type a2;
+ assert(A2::count == 0);
+ assert(b_construct == 0);
+ std::allocator_traits<B<int> >::construct(b, (A2*)&a2, 'd', 5);
+ assert(A2::count == 1);
+ assert(b_construct == 1);
+ }
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
new file mode 100644
index 0000000000000..b137dc6d36c3d
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static void deallocate(allocator_type& a, pointer p, size_type n);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int called = 0;
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ void deallocate(value_type* p, std::size_t n)
+ {
+ assert(p == (value_type*)0xDEADBEEF);
+ assert(n == 10);
+ ++called;
+ }
+};
+
+int main()
+{
+ A<int> a;
+ std::allocator_traits<A<int> >::deallocate(a, (int*)0xDEADBEEF, 10);
+ assert(called == 1);
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
new file mode 100644
index 0000000000000..54726c929efe6
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// template <class Ptr>
+// static void destroy(allocator_type& a, Ptr p);
+// ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+};
+
+int b_destroy = 0;
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+ template <class U>
+ void destroy(U* p)
+ {
+ ++b_destroy;
+ p->~U();
+ }
+};
+
+struct A0
+{
+ static int count;
+ ~A0() {++count;}
+};
+
+int A0::count = 0;
+
+int main()
+{
+ {
+ A0::count = 0;
+ A<int> a;
+ std::aligned_storage<sizeof(A0)>::type a0;
+ std::allocator_traits<A<int> >::construct(a, (A0*)&a0);
+ assert(A0::count == 0);
+ std::allocator_traits<A<int> >::destroy(a, (A0*)&a0);
+ assert(A0::count == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ A0::count = 0;
+ b_destroy = 0;
+ B<int> b;
+ std::aligned_storage<sizeof(A0)>::type a0;
+ std::allocator_traits<B<int> >::construct(b, (A0*)&a0);
+ assert(A0::count == 0);
+ assert(b_destroy == 0);
+ std::allocator_traits<B<int> >::destroy(b, (A0*)&a0);
+ assert(A0::count == 1);
+ assert(b_destroy == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
new file mode 100644
index 0000000000000..1fa7291203ed4
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static size_type max_size(const allocator_type& a) noexcept;
+// ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+ size_t max_size() const
+ {
+ return 100;
+ }
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ A<int> a;
+ assert(std::allocator_traits<A<int> >::max_size(a) ==
+ std::numeric_limits<std::size_t>::max());
+ }
+ {
+ const A<int> a = {};
+ assert(std::allocator_traits<A<int> >::max_size(a) ==
+ std::numeric_limits<std::size_t>::max());
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ B<int> b;
+ assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+ }
+ {
+ const B<int> b = {};
+ assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+ }
+#if __cplusplus >= 201103
+ {
+ std::allocator<int> a;
+ static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, "");
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
new file mode 100644
index 0000000000000..29fe2be126f3f
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static allocator_type
+// select_on_container_copy_construction(const allocator_type& a);
+// ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ int id;
+ explicit A(int i = 0) : id(i) {}
+
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+
+ int id;
+ explicit B(int i = 0) : id(i) {}
+
+ B select_on_container_copy_construction() const
+ {
+ return B(100);
+ }
+};
+
+int main()
+{
+ {
+ A<int> a;
+ assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
+ }
+ {
+ const A<int> a(0);
+ assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ B<int> b;
+ assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
+ }
+ {
+ const B<int> b(0);
+ assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
new file mode 100644
index 0000000000000..20348d20c10cd
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::const_pointer
+// | pointer_traits<pointer>::rebind<const value_type>
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ typedef CPtr<T> pointer;
+ typedef CPtr<const T> const_pointer;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::const_pointer, Ptr<const char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::const_pointer, const char*>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::const_pointer, CPtr<const char> >::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
new file mode 100644
index 0000000000000..4b4045a51bae0
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::const_void_pointer
+// | pointer_traits<pointer>::rebind<const void>
+// const_void_pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ typedef CPtr<const void> const_void_pointer;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::const_void_pointer, Ptr<const void> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::const_void_pointer, const void*>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::const_void_pointer, CPtr<const void> >::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
new file mode 100644
index 0000000000000..085c911b07035
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::difference_type
+// | pointer_traits<pointer>::difference_type difference_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef short difference_type;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ struct pointer {};
+ struct const_pointer {};
+ struct void_pointer {};
+ struct const_void_pointer {};
+};
+
+namespace std
+{
+
+template <>
+struct pointer_traits<C<char>::pointer>
+{
+ typedef signed char difference_type;
+};
+
+}
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::difference_type, short>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::difference_type, signed char>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.pass.cpp
new file mode 100644
index 0000000000000..31a0f171d33d0
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/is_always_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::is_always_equal
+// | is_empty is_always_equal;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef std::true_type is_always_equal;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ int not_empty_; // some random member variable
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::is_always_equal, std::false_type>::value), "");
+
+ static_assert((std::is_same<std::allocator_traits<A<const char> >::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<const char> >::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<const char> >::is_always_equal, std::false_type>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
new file mode 100644
index 0000000000000..60ba094993428
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::pointer | value_type* pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::pointer, Ptr<char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::pointer, char*>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
new file mode 100644
index 0000000000000..604e890efaaee
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::propagate_on_container_copy_assignment
+// | false_type propagate_on_container_copy_assignment;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef std::true_type propagate_on_container_copy_assignment;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_copy_assignment, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_copy_assignment, std::false_type>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
new file mode 100644
index 0000000000000..1d2b18686d0f1
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::propagate_on_container_move_assignment
+// | false_type propagate_on_container_move_assignment;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef std::true_type propagate_on_container_move_assignment;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_move_assignment, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_move_assignment, std::false_type>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
new file mode 100644
index 0000000000000..6730d1ae261a6
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::propagate_on_container_swap
+// | false_type propagate_on_container_swap;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_swap, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_swap, std::false_type>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
new file mode 100644
index 0000000000000..50611b99da9a8
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+template <class T, class U>
+struct ReboundB {};
+
+template <class T, class U>
+struct B
+{
+ typedef T value_type;
+
+ template <class V> struct rebind {typedef ReboundB<V, U> other;};
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+};
+
+template <class T, class U>
+struct D
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct E
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> otter;};
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>, ReboundA<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>, ReboundB<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>, C<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>, D<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>, E<double> >::value), "");
+#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>::other, ReboundA<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>::other, ReboundB<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>::other, C<double> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>::other, D<double, char> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>::other, E<double> >::value), "");
+#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
new file mode 100644
index 0000000000000..e9c175fe86a54
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::size_type | size_t size_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef unsigned short size_type;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ struct pointer {};
+ struct const_pointer {};
+ struct void_pointer {};
+ struct const_void_pointer {};
+};
+
+namespace std
+{
+
+template <>
+struct pointer_traits<C<char>::pointer>
+{
+ typedef signed char difference_type;
+};
+
+}
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::size_type, unsigned short>::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::size_type,
+ std::make_unsigned<std::ptrdiff_t>::type>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::size_type,
+ unsigned char>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
new file mode 100644
index 0000000000000..74cd3475f6645
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::void_pointer
+// | pointer_traits<pointer>::rebind<void>
+// void_pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+ typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+ typedef CPtr<void> void_pointer;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::void_pointer, Ptr<void> >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<char> >::void_pointer, void*>::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::void_pointer, CPtr<void> >::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp
new file mode 100644
index 0000000000000..fe35ae487576c
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/allocator_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc allocator_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::allocator_type, A<char> >::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp b/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
new file mode 100644
index 0000000000000..87da9a0a85dab
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+template <class T, class U>
+struct ReboundB {};
+
+template <class T, class U>
+struct B
+{
+ typedef T value_type;
+
+ template <class V> struct rebind {typedef ReboundB<V, U> other;};
+};
+
+template <class T>
+struct C
+{
+ typedef T value_type;
+};
+
+template <class T, class U>
+struct D
+{
+ typedef T value_type;
+};
+
+template <class T>
+struct E
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> otter;};
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<ReboundA<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<ReboundB<double, char> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), "");
+#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<ReboundA<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<ReboundB<double, char> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), "");
+ static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), "");
+#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/test/std/utilities/memory/allocator.traits/value_type.pass.cpp b/test/std/utilities/memory/allocator.traits/value_type.pass.cpp
new file mode 100644
index 0000000000000..d0c3d2c09a1f2
--- /dev/null
+++ b/test/std/utilities/memory/allocator.traits/value_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef typename Alloc::value_type value_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::allocator_traits<A<char> >::value_type, char>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp b/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.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/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp b/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
new file mode 100644
index 0000000000000..0477d9912e6ec
--- /dev/null
+++ b/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T, class Alloc> struct uses_allocator;
+
+#include <memory>
+#include <vector>
+
+struct A
+{
+};
+
+struct B
+{
+ typedef int allocator_type;
+};
+
+int main()
+{
+ static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
+ static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
+ static_assert(( std::uses_allocator<B, double>::value), "");
+}
diff --git a/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp b/test/std/utilities/memory/allocator.uses/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/allocator.uses/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/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp b/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..a71806330062c
--- /dev/null
+++ b/test/std/utilities/memory/c.malloc/nothing_to_do.pass.cpp
@@ -0,0 +1,14 @@
+//===----------------------------------------------------------------------===//
+//
+// 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> and <cstring> are already tested elsewhere
+
+int main()
+{
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
new file mode 100644
index 0000000000000..8ce49b90d4891
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.globals/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+
+// template <class T1, class T2>
+// bool
+// operator==(const allocator<T1>&, const allocator<T2>&) throw();
+//
+// template <class T1, class T2>
+// bool
+// operator!=(const allocator<T1>&, const allocator<T2>&) throw();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::allocator<int> a1;
+ std::allocator<int> a2;
+ assert(a1 == a2);
+ assert(!(a1 != a2));
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp
new file mode 100644
index 0000000000000..04534f24d502e
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.members/address.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// pointer address(reference x) const;
+// const_pointer address(const_reference x) const;
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+void test_address()
+{
+ T* tp = new T();
+ const T* ctp = tp;
+ const std::allocator<T> a;
+ assert(a.address(*tp) == tp);
+ assert(a.address(*ctp) == tp);
+ delete tp;
+}
+
+struct A
+{
+ void operator&() const {}
+};
+
+int main()
+{
+ test_address<int>();
+ test_address<A>();
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
new file mode 100644
index 0000000000000..253515e3db3c2
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.members/allocate.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
+
+#include <memory>
+#include <cassert>
+
+#include "count_new.hpp"
+
+int A_constructed = 0;
+
+struct A
+{
+ int data;
+ A() {++A_constructed;}
+ A(const A&) {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int main()
+{
+ std::allocator<A> a;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+ globalMemCounter.last_new_size = 0;
+ A* ap = a.allocate(3);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
+ assert(A_constructed == 0);
+ a.deallocate(ap, 3);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+
+ globalMemCounter.last_new_size = 0;
+ A* ap2 = a.allocate(3, (const void*)5);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
+ assert(A_constructed == 0);
+ a.deallocate(ap2, 3);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
new file mode 100644
index 0000000000000..d0a870e60690c
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// allocator:
+// template <class... Args> void construct(pointer p, Args&&... args);
+
+#include <memory>
+#include <cassert>
+
+#include "count_new.hpp"
+
+int A_constructed = 0;
+
+struct A
+{
+ int data;
+ A() {++A_constructed;}
+
+ A(const A&) {++A_constructed;}
+
+ explicit A(int) {++A_constructed;}
+ A(int, int*) {++A_constructed;}
+
+ ~A() {--A_constructed;}
+};
+
+int move_only_constructed = 0;
+
+class move_only
+{
+ int data;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(const move_only&);
+ move_only& operator=(const move_only&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&);
+ move_only& operator=(move_only&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ move_only(move_only&&) {++move_only_constructed;}
+ move_only& operator=(move_only&&) {return *this;}
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+ move_only(std::__rv<move_only>) {++move_only_constructed;}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ move_only() {++move_only_constructed;}
+ ~move_only() {--move_only_constructed;}
+};
+
+int main()
+{
+ {
+ std::allocator<A> a;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+
+ globalMemCounter.last_new_size = 0;
+ A* ap = a.allocate(3);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
+ assert(A_constructed == 0);
+
+ a.construct(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 0);
+
+ a.construct(ap, A());
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 0);
+
+ a.construct(ap, 5);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 0);
+
+ a.construct(ap, 5, (int*)0);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(A_constructed == 0);
+
+ a.deallocate(ap, 3);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(A_constructed == 0);
+ }
+ {
+ std::allocator<move_only> a;
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(move_only_constructed == 0);
+
+ globalMemCounter.last_new_size = 0;
+ move_only* ap = a.allocate(3);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
+ assert(move_only_constructed == 0);
+
+ a.construct(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(move_only_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(move_only_constructed == 0);
+
+ a.construct(ap, move_only());
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(move_only_constructed == 1);
+
+ a.destroy(ap);
+ assert(globalMemCounter.checkOutstandingNewEq(1));
+ assert(move_only_constructed == 0);
+
+ a.deallocate(ap, 3);
+ assert(globalMemCounter.checkOutstandingNewEq(0));
+ assert(move_only_constructed == 0);
+ }
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
new file mode 100644
index 0000000000000..6ec9339bc48ff
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator.members/max_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// size_type max_size() const throw();
+
+#include <memory>
+#include <limits>
+#include <cstddef>
+#include <cassert>
+
+int new_called = 0;
+
+int main()
+{
+ const std::allocator<int> a;
+ std::size_t M = a.max_size() * sizeof(int);
+ assert(M > 0xFFFF && M <= std::numeric_limits<std::size_t>::max());
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp b/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp
new file mode 100644
index 0000000000000..5a8f7a28a042c
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <memory>
+#include <cassert>
+
+#if __cplusplus >= 201103L
+// #include <memory>
+//
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc allocator_type;
+// typedef typename allocator_type::value_type
+// value_type;
+//
+// typedef Alloc::pointer | value_type* pointer;
+// typedef Alloc::const_pointer
+// | pointer_traits<pointer>::rebind<const value_type>
+// const_pointer;
+// typedef Alloc::void_pointer
+// | pointer_traits<pointer>::rebind<void>
+// void_pointer;
+// typedef Alloc::const_void_pointer
+// | pointer_traits<pointer>::rebind<const void>
+// const_void_pointer;
+
+template <typename Alloc>
+void test_pointer()
+{
+ typename std::allocator_traits<Alloc>::pointer vp;
+ typename std::allocator_traits<Alloc>::const_pointer cvp;
+
+ static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+template <typename Alloc>
+void test_void_pointer()
+{
+ typename std::allocator_traits<Alloc>::void_pointer vp;
+ typename std::allocator_traits<Alloc>::const_void_pointer cvp;
+
+ static_assert(std::is_same<bool, decltype( vp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp == vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < vp)>::value, "");
+ static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, "");
+
+ static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, "");
+ static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+struct Foo { int x; };
+
+int main()
+{
+ test_pointer<std::allocator<char>> ();
+ test_pointer<std::allocator<int>> ();
+ test_pointer<std::allocator<Foo>> ();
+
+ test_void_pointer<std::allocator<char>> ();
+ test_void_pointer<std::allocator<int>> ();
+ test_void_pointer<std::allocator<Foo>> ();
+}
+#else
+int main() {}
+#endif
diff --git a/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp b/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
new file mode 100644
index 0000000000000..cba32103dcd47
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator_types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// check nested types:
+
+// template <class T>
+// class allocator
+// {
+// public:
+// typedef size_t size_type;
+// typedef ptrdiff_t difference_type;
+// typedef T* pointer;
+// typedef const T* const_pointer;
+// typedef typename add_lvalue_reference<T>::type reference;
+// typedef typename add_lvalue_reference<const T>::type const_reference;
+// typedef T value_type;
+// typedef true_type is_always_equal;
+//
+// template <class U> struct rebind {typedef allocator<U> other;};
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+#include <cstddef>
+
+int main()
+{
+ static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<std::allocator<char>::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::allocator<char>::pointer, char*>::value), "");
+ static_assert((std::is_same<std::allocator<char>::const_pointer, const char*>::value), "");
+ static_assert((std::is_same<std::allocator<char>::value_type, char>::value), "");
+ static_assert((std::is_same<std::allocator<char>::reference, char&>::value), "");
+ static_assert((std::is_same<std::allocator<char>::const_reference, const char&>::value), "");
+ static_assert((std::is_same<std::allocator<char>::rebind<int>::other,
+ std::allocator<int> >::value), "");
+
+ static_assert((std::is_same<std::allocator< char>::is_always_equal, std::true_type>::value), "");
+ static_assert((std::is_same<std::allocator<const char>::is_always_equal, std::true_type>::value), "");
+
+ std::allocator<char> a;
+ std::allocator<char> a2 = a;
+ a2 = a;
+ std::allocator<int> a3 = a2;
+ ((void)a3);
+}
diff --git a/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp b/test/std/utilities/memory/default.allocator/allocator_void.pass.cpp
new file mode 100644
index 0000000000000..cc1dbebae033c
--- /dev/null
+++ b/test/std/utilities/memory/default.allocator/allocator_void.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <>
+// class allocator<void>
+// {
+// public:
+// typedef void* pointer;
+// typedef const void* const_pointer;
+// typedef void value_type;
+//
+// template <class _Up> struct rebind {typedef allocator<_Up> other;};
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::allocator<void>::pointer, void*>::value), "");
+ static_assert((std::is_same<std::allocator<void>::const_pointer, const void*>::value), "");
+ static_assert((std::is_same<std::allocator<void>::value_type, void>::value), "");
+ static_assert((std::is_same<std::allocator<void>::rebind<int>::other,
+ std::allocator<int> >::value), "");
+ std::allocator<void> a;
+ std::allocator<void> a2 = a;
+ a2 = a;
+}
diff --git a/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp b/test/std/utilities/memory/pointer.traits/difference_type.pass.cpp
new file mode 100644
index 0000000000000..483c32561e85b
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+// typedef ptrdiff_t difference_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<double*>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/element_type.pass.cpp b/test/std/utilities/memory/pointer.traits/element_type.pass.cpp
new file mode 100644
index 0000000000000..44694fcb013cf
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/element_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+// typedef T element_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<const short*>::element_type, const short>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.pass.cpp
new file mode 100644
index 0000000000000..66e90cfcb8543
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// typedef Ptr pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef short element_type;
+ typedef char difference_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::pointer, A>::value), "");
+ static_assert((std::is_same<std::pointer_traits<int*>::pointer, int*>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
new file mode 100644
index 0000000000000..a8ad936c9366f
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// static pointer pointer_to(<details>);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+private:
+ struct nat {};
+public:
+ typedef T element_type;
+ element_type* t_;
+
+ A(element_type* t) : t_(t) {}
+
+ static A pointer_to(typename std::conditional<std::is_void<element_type>::value,
+ nat, element_type>::type& et)
+ {return A(&et);}
+};
+
+int main()
+{
+ {
+ int i = 0;
+ A<int> a = std::pointer_traits<A<int> >::pointer_to(i);
+ assert(a.t_ == &i);
+ }
+ {
+ (std::pointer_traits<A<void> >::element_type)0;
+ }
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
new file mode 100644
index 0000000000000..4efe61342420c
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// typedef <details> difference_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef short element_type;
+ typedef char difference_type;
+};
+
+struct B
+{
+ typedef short element_type;
+};
+
+template <class T>
+struct C {};
+
+template <class T>
+struct D
+{
+ typedef char difference_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::difference_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<B>::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<double> >::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<int> >::difference_type, char>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
new file mode 100644
index 0000000000000..0ee1e8c93a674
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// typedef <details> element_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef char element_type;
+};
+
+template <class T>
+struct B
+{
+ typedef char element_type;
+};
+
+template <class T>
+struct C
+{
+};
+
+template <class T, class U>
+struct D
+{
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::element_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::element_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<int> >::element_type, int>::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<double, int> >::element_type, double>::value), "");
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
new file mode 100644
index 0000000000000..4a1455c53ef6f
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+// template <class U> using rebind = <details>;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+};
+
+template <class T> struct B1 {};
+
+template <class T>
+struct B
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ template <class U> using rebind = B1<U>;
+#else
+ template <class U> struct rebind {typedef B1<U> other;};
+#endif
+};
+
+template <class T, class U>
+struct C
+{
+};
+
+template <class T, class U> struct D1 {};
+
+template <class T, class U>
+struct D
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ template <class V> using rebind = D1<V, U>;
+#else
+ template <class V> struct rebind {typedef D1<V, U> other;};
+#endif
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>, A<double*> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>, B1<double> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>, C<double, int> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>, D1<double, int> >::value), "");
+#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>::other, A<double*> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>::other, B1<double> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>::other, C<double, int> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>::other, D1<double, int> >::value), "");
+#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp b/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp
new file mode 100644
index 0000000000000..fc44d9d77a2f8
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/pointer_to.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+// static pointer pointer_to(<details>);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ int i = 0;
+ int* a = std::pointer_traits<int*>::pointer_to(i);
+ assert(a == &i);
+ }
+ {
+ (std::pointer_traits<void*>::element_type)0;
+ }
+}
diff --git a/test/std/utilities/memory/pointer.traits/rebind.pass.cpp b/test/std/utilities/memory/pointer.traits/rebind.pass.cpp
new file mode 100644
index 0000000000000..8716c05f3335a
--- /dev/null
+++ b/test/std/utilities/memory/pointer.traits/rebind.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+// template <class U> using rebind = U*;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), "");
+#else
+ static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), "");
+#endif
+}
diff --git a/test/std/utilities/memory/ptr.align/align.pass.cpp b/test/std/utilities/memory/ptr.align/align.pass.cpp
new file mode 100644
index 0000000000000..d77d13c906de7
--- /dev/null
+++ b/test/std/utilities/memory/ptr.align/align.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <memory>
+
+// void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const unsigned N = 20;
+ char buf[N];
+ void* r;
+ void* p = &buf[0];
+ std::size_t s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[0]);
+ assert(r == p);
+ assert(s == N);
+
+ p = &buf[1];
+ s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N-3);
+
+ p = &buf[2];
+ s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N-2);
+
+ p = &buf[3];
+ s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N-1);
+
+ p = &buf[4];
+ s = N;
+ r = std::align(4, 10, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N);
+
+ p = &buf[0];
+ s = N;
+ r = std::align(4, N, p, s);
+ assert(p == &buf[0]);
+ assert(r == p);
+ assert(s == N);
+
+ p = &buf[1];
+ s = N-1;
+ r = std::align(4, N-4, p, s);
+ assert(p == &buf[4]);
+ assert(r == p);
+ assert(s == N-4);
+
+ p = &buf[1];
+ s = N-1;
+ r = std::align(4, N-3, p, s);
+ assert(p == &buf[1]);
+ assert(r == nullptr);
+ assert(s == N-1);
+
+ p = &buf[0];
+ s = N;
+ r = std::align(1, N+1, p, s);
+ assert(p == &buf[0]);
+ assert(r == nullptr);
+ assert(s == N);
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp b/test/std/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/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/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp
new file mode 100644
index 0000000000000..e07bec4d0a47e
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <ObjectType T> T* addressof(T& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ void operator&() const {}
+};
+
+struct nothing {
+ operator char&()
+ {
+ static char c;
+ return c;
+ }
+};
+
+int main()
+{
+ {
+ int i;
+ double d;
+ assert(std::addressof(i) == &i);
+ assert(std::addressof(d) == &d);
+ A* tp = new A;
+ const A* ctp = tp;
+ assert(std::addressof(*tp) == tp);
+ assert(std::addressof(*ctp) == tp);
+ delete tp;
+ }
+ {
+ union
+ {
+ nothing n;
+ int i;
+ };
+ assert(std::addressof(n) == (void*)std::addressof(i));
+ }
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
new file mode 100644
index 0000000000000..f431335db732b
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class InputIterator, class ForwardIterator>
+// ForwardIterator
+// uninitialized_copy(InputIterator first, InputIterator last,
+// ForwardIterator result);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count_;
+ int data_;
+ explicit B() : data_(1) {}
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+ ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
+int main()
+{
+ {
+ const int N = 5;
+ char pool[sizeof(B)*N] = {0};
+ B* bp = (B*)pool;
+ B b[N];
+ try
+ {
+ std::uninitialized_copy(b, b+N, bp);
+ assert(false);
+ }
+ catch (...)
+ {
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].data_ == 0);
+ }
+ B::count_ = 0;
+ std::uninitialized_copy(b, b+2, bp);
+ for (int i = 0; i < 2; ++i)
+ assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[sizeof(Nasty)*N] = {0};
+ Nasty * p = (Nasty *) pool;
+ Nasty arr[N];
+ std::uninitialized_copy(arr, arr+N, p);
+ for (int i = 0; i < N; ++i) {
+ assert(arr[i].i_ == i);
+ assert( p[i].i_ == i);
+ }
+ }
+
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
new file mode 100644
index 0000000000000..3b2007b969c3f
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class InputIterator, class Size, class ForwardIterator>
+// ForwardIterator
+// uninitialized_copy_n(InputIterator first, Size n,
+// ForwardIterator result);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count_;
+ int data_;
+ explicit B() : data_(1) {}
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+ ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
+int main()
+{
+ {
+ const int N = 5;
+ char pool[sizeof(B)*N] = {0};
+ B* bp = (B*)pool;
+ B b[N];
+ try
+ {
+ std::uninitialized_copy_n(b, 5, bp);
+ assert(false);
+ }
+ catch (...)
+ {
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].data_ == 0);
+ }
+ B::count_ = 0;
+ std::uninitialized_copy_n(b, 2, bp);
+ for (int i = 0; i < 2; ++i)
+ assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[sizeof(Nasty)*N] = {0};
+ Nasty * p = (Nasty *) pool;
+ Nasty arr[N];
+ std::uninitialized_copy_n(arr, N, p);
+ for (int i = 0; i < N; ++i) {
+ assert(arr[i].i_ == i);
+ assert( p[i].i_ == i);
+ }
+ }
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
new file mode 100644
index 0000000000000..d2b1dfa288686
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class ForwardIterator, class Size, class T>
+// ForwardIterator
+// uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count_;
+ int data_;
+ explicit B() : data_(1) {}
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+ ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
+int main()
+{
+ {
+ const int N = 5;
+ char pool[sizeof(B)*N] = {0};
+ B* bp = (B*)pool;
+ try
+ {
+ std::uninitialized_fill_n(bp, 5, B());
+ assert(false);
+ }
+ catch (...)
+ {
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].data_ == 0);
+ }
+ B::count_ = 0;
+ B* r = std::uninitialized_fill_n(bp, 2, B());
+ assert(r == bp + 2);
+ for (int i = 0; i < 2; ++i)
+ assert(bp[i].data_ == 1);
+ }
+ {
+ {
+ const int N = 5;
+ char pool[N*sizeof(Nasty)] = {0};
+ Nasty* bp = (Nasty*)pool;
+
+ Nasty::counter_ = 23;
+ std::uninitialized_fill_n(bp, N, Nasty());
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].i_ == 23);
+ }
+
+ }
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
new file mode 100644
index 0000000000000..47cabdfa478a6
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class ForwardIterator, class T>
+// void
+// uninitialized_fill(ForwardIterator first, ForwardIterator last,
+// const T& x);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count_;
+ int data_;
+ explicit B() : data_(1) {}
+ B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+ ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+struct Nasty
+{
+ Nasty() : i_ ( counter_++ ) {}
+ Nasty * operator &() const { return NULL; }
+ int i_;
+ static int counter_;
+};
+
+int Nasty::counter_ = 0;
+
+int main()
+{
+ {
+ const int N = 5;
+ char pool[sizeof(B)*N] = {0};
+ B* bp = (B*)pool;
+ try
+ {
+ std::uninitialized_fill(bp, bp+N, B());
+ assert(false);
+ }
+ catch (...)
+ {
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].data_ == 0);
+ }
+ B::count_ = 0;
+ std::uninitialized_fill(bp, bp+2, B());
+ for (int i = 0; i < 2; ++i)
+ assert(bp[i].data_ == 1);
+ }
+ {
+ const int N = 5;
+ char pool[N*sizeof(Nasty)] = {0};
+ Nasty* bp = (Nasty*)pool;
+
+ Nasty::counter_ = 23;
+ std::uninitialized_fill(bp, bp+N, Nasty());
+ for (int i = 0; i < N; ++i)
+ assert(bp[i].i_ == 23);
+ }
+}
diff --git a/test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.pass.cpp b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.pass.cpp
new file mode 100644
index 0000000000000..27b620569b83f
--- /dev/null
+++ b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.base.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.
+//
+//===----------------------------------------------------------------------===//
+
+// raw_storage_iterator
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+ int data_;
+public:
+ explicit A(int i) : data_(i) {++A_constructed;}
+
+ A(const A& a) : data_(a.data_) {++A_constructed;}
+ ~A() {--A_constructed; data_ = 0;}
+
+ bool operator==(int i) const {return data_ == i;}
+};
+
+int main()
+{
+#if __cplusplus >= 201402L
+ typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
+ Storage;
+ Storage buffer;
+ std::raw_storage_iterator<A*, A> it((A*)&buffer);
+ assert(A_constructed == 0);
+ assert(it.base() == (A*)&buffer);
+ for (int i = 0; i < 3; ++i)
+ {
+ *it++ = A(i+1);
+ A* ap = (A*)&buffer + i;
+ assert(*ap == i+1);
+ assert(A_constructed == i+1);
+ assert(it.base() == ap + 1); // next place to write
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
new file mode 100644
index 0000000000000..f77d6c75e17a4
--- /dev/null
+++ b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// raw_storage_iterator
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+ int data_;
+public:
+ explicit A(int i) : data_(i) {++A_constructed;}
+
+ A(const A& a) : data_(a.data_) {++A_constructed;}
+ ~A() {--A_constructed; data_ = 0;}
+
+ bool operator==(int i) const {return data_ == i;}
+};
+
+int main()
+{
+ typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
+ Storage;
+ Storage buffer;
+ std::raw_storage_iterator<A*, A> it((A*)&buffer);
+ assert(A_constructed == 0);
+ for (int i = 0; i < 3; ++i)
+ {
+ *it++ = A(i+1);
+ A* ap = (A*)&buffer + i;
+ assert(*ap == i+1);
+ assert(A_constructed == i+1);
+ }
+}
diff --git a/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp b/test/std/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
new file mode 100644
index 0000000000000..c1575bda2bac6
--- /dev/null
+++ b/test/std/utilities/memory/temporary.buffer/temporary_buffer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// pair<T*, ptrdiff_t>
+// get_temporary_buffer(ptrdiff_t n);
+//
+// template <class T>
+// void
+// return_temporary_buffer(T* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::pair<int*, std::ptrdiff_t> ip = std::get_temporary_buffer<int>(5);
+ assert(ip.first);
+ assert(ip.second == 5);
+ std::return_temporary_buffer(ip.first);
+}
diff --git a/test/std/utilities/memory/unique.ptr/deleter.h b/test/std/utilities/memory/unique.ptr/deleter.h
new file mode 100644
index 0000000000000..fb26044d98ff6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/deleter.h
@@ -0,0 +1,182 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Example move-only deleter
+
+#ifndef DELETER_H
+#define DELETER_H
+
+#include <type_traits>
+#include <utility>
+#include <cassert>
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(0) {}
+ explicit Deleter(int s) : state_(s) {}
+ ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class Deleter<T[]>
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(0) {}
+ explicit Deleter(int s) : state_(s) {}
+ ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete [] p;}
+};
+
+template <class T>
+void
+swap(Deleter<T>& x, Deleter<T>& y)
+{
+ Deleter<T> t(std::move(x));
+ x = std::move(y);
+ y = std::move(t);
+}
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+public:
+
+ CDeleter() : state_(0) {}
+ explicit CDeleter(int s) : state_(s) {}
+ ~CDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ template <class U>
+ CDeleter(const CDeleter<U>& d)
+ : state_(d.state()) {}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class CDeleter<T[]>
+{
+ int state_;
+
+public:
+
+ CDeleter() : state_(0) {}
+ explicit CDeleter(int s) : state_(s) {}
+ ~CDeleter() {assert(state_ >= 0); state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete [] p;}
+};
+
+template <class T>
+void
+swap(CDeleter<T>& x, CDeleter<T>& y)
+{
+ CDeleter<T> t(std::move(x));
+ x = std::move(y);
+ y = std::move(t);
+}
+
+#endif // DELETER_H
diff --git a/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp b/test/std/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/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/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp
new file mode 100644
index 0000000000000..b2fb58f529f31
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+// The only way to create an unique_ptr<T[]> is to default construct them.
+
+class foo {
+public:
+ foo () : val_(3) {}
+ int get () const { return val_; }
+private:
+ int val_;
+ };
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ auto p1 = std::make_unique<int[]>(5);
+ for ( int i = 0; i < 5; ++i )
+ assert ( p1[i] == 0 );
+ }
+
+ {
+ auto p2 = std::make_unique<std::string[]>(5);
+ for ( int i = 0; i < 5; ++i )
+ assert ( p2[i].size () == 0 );
+ }
+
+ {
+ auto p3 = std::make_unique<foo[]>(7);
+ for ( int i = 0; i < 7; ++i )
+ assert ( p3[i].get () == 3 );
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp
new file mode 100644
index 0000000000000..00987919413bb
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ auto up1 = std::make_unique<std::string[]>("error"); // doesn't compile - no bound
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp
new file mode 100644
index 0000000000000..cc94e9ab3aaab
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ auto up2 = std::make_unique<int[]>(10, 20, 30, 40);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp
new file mode 100644
index 0000000000000..cfdc2e1d886b0
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ auto up3 = std::make_unique<int[5]>(); // this is deleted
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp
new file mode 100644
index 0000000000000..26eb59bbfd711
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ auto up4 = std::make_unique<int[5]>(11, 22, 33, 44, 55); // deleted
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp
new file mode 100644
index 0000000000000..7326ed226557c
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ std::unique_ptr<int> p1 = std::make_unique<int>(1);
+ assert ( *p1 == 1 );
+ p1 = std::make_unique<int> ();
+ assert ( *p1 == 0 );
+ }
+
+ {
+ std::unique_ptr<std::string> p2 = std::make_unique<std::string> ( "Meow!" );
+ assert ( *p2 == "Meow!" );
+ p2 = std::make_unique<std::string> ();
+ assert ( *p2 == "" );
+ p2 = std::make_unique<std::string> ( 6, 'z' );
+ assert ( *p2 == "zzzzzz" );
+ }
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/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/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp
new file mode 100644
index 0000000000000..9bf794caeda27
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ std::default_delete<B> d2;
+ std::default_delete<A> d1 = d2;
+ A* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d1(p);
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp
new file mode 100644
index 0000000000000..f686e9f01f113
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ std::default_delete<A> d;
+ A* p = new A;
+ assert(A::count == 1);
+ d(p);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp
new file mode 100644
index 0000000000000..255e5cd39c69b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete's operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+ std::default_delete<A> d;
+ A* p = 0;
+ d(p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp
new file mode 100644
index 0000000000000..5d1cf1ff4981e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// default_delete
+
+// Test that default_delete's operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::default_delete<const void> d;
+ const void* p = 0;
+ d(p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp
new file mode 100644
index 0000000000000..41209d977b71e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]> does not have a working converting constructor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+};
+
+struct B
+ : public A
+{
+};
+
+int main()
+{
+ std::default_delete<B[]> d2;
+ std::default_delete<A[]> d1 = d2;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
new file mode 100644
index 0000000000000..7a409766412fd
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]> has a working default constructor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ std::default_delete<A[]> d;
+ A* p = new A[3];
+ assert(A::count == 3);
+ d(p);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp
new file mode 100644
index 0000000000000..528b10e9085d6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]>'s operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+ std::default_delete<A[]> d;
+ A* p = 0;
+ d(p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/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/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
new file mode 100644
index 0000000000000..17375ede00f59
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ std::unique_ptr<A> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
new file mode 100644
index 0000000000000..286e6bc9a7b91
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> s1(new A[3]);
+ A* p = s1.get();
+ assert(A::count == 3);
+ std::unique_ptr<A[]> s2(new A[2]);
+ assert(A::count == 5);
+ s2 = std::move(s1);
+ assert(A::count == 3);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A[], Deleter<A[]> > s1(new A[4], Deleter<A[]>(5));
+ A* p = s1.get();
+ assert(A::count == 4);
+ std::unique_ptr<A[], Deleter<A[]> > s2(new A[5]);
+ assert(A::count == 9);
+ s2 = std::move(s1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(A::count == 4);
+ assert(s2.get_deleter().state() == 5);
+ assert(s1.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ CDeleter<A[]> d1(5);
+ std::unique_ptr<A[], CDeleter<A[]>&> s1(new A[6], d1);
+ A* p = s1.get();
+ assert(A::count == 6);
+ CDeleter<A[]> d2(6);
+ std::unique_ptr<A[], CDeleter<A[]>&> s2(new A[3], d2);
+ assert(A::count == 9);
+ s2 = std::move(s1);
+ assert(A::count == 6);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(d1.state() == 5);
+ assert(d2.state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
new file mode 100644
index 0000000000000..6e13873c2fb3b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A[]> s(new A[3]);
+ std::unique_ptr<A[]> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp
new file mode 100644
index 0000000000000..3712a27963929
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp
new file mode 100644
index 0000000000000..4e85e5b0fb906
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp
new file mode 100644
index 0000000000000..9461958a431dd
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp
new file mode 100644
index 0000000000000..1737136f4d72a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ boost::unique_ptr<B[], Deleter<B> > s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[], Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
new file mode 100644
index 0000000000000..3c89bb12344eb
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp
new file mode 100644
index 0000000000000..970beb5a150e9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const boost::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[]> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp
new file mode 100644
index 0000000000000..786858dd40169
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const boost::unique_ptr<B[], Deleter<B> > s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[], Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
new file mode 100644
index 0000000000000..46d4c0985d716
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ const boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp
new file mode 100644
index 0000000000000..65ee2694156f6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ boost::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[]> s2(new A);
+ assert(A::count == 2);
+ s2 = boost::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp
new file mode 100644
index 0000000000000..da08195ffdd3a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ boost::unique_ptr<B[], Deleter<B> > s(new B);
+ A* p = s.get();
+ boost::unique_ptr<A[], Deleter<A> > s2(new A);
+ assert(A::count == 2);
+ s2 = (boost::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
new file mode 100644
index 0000000000000..aeec076cb86ab
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+ s2 = boost::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
new file mode 100644
index 0000000000000..e2d7956cda643
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 1);
+ s2 = 0;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
new file mode 100644
index 0000000000000..6d752b9951a57
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// The deleter is not called if get() == 0
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(0) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {++state_;}
+};
+
+int main()
+{
+ Deleter d;
+ assert(d.state() == 0);
+ {
+ std::unique_ptr<int[], Deleter&> p(0, d);
+ assert(p.get() == 0);
+ assert(&p.get_deleter() == &d);
+ }
+ assert(d.state() == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
new file mode 100644
index 0000000000000..30ecdded3cf7b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> s2(new A[3]);
+ assert(A::count == 3);
+ s2 = nullptr;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp
new file mode 100644
index 0000000000000..e7ad6ad7ef33d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>::pointer type
+
+#include <memory>
+#include <type_traits>
+
+struct Deleter
+{
+ struct pointer {};
+};
+
+int main()
+{
+ {
+ typedef std::unique_ptr<int[]> P;
+ static_assert((std::is_same<P::pointer, int*>::value), "");
+ }
+ {
+ typedef std::unique_ptr<int[], Deleter> P;
+ static_assert((std::is_same<P::pointer, Deleter::pointer>::value), "");
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
new file mode 100644
index 0000000000000..b6bcad9a91c66
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require default Deleter ctor
+
+
+#include <memory>
+
+class Deleter
+{
+ // expected-error@memory:* {{base class 'Deleter' has private default constructor}}
+ // expected-note@memory:* + {{in instantiation of member function}}
+ Deleter() {} // expected-note {{implicitly declared private here}}
+
+public:
+
+ Deleter(Deleter&) {}
+ Deleter& operator=(Deleter&) { return *this; }
+
+ void operator()(void*) const {}
+};
+
+int main()
+{
+ std::unique_ptr<int[], Deleter> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
new file mode 100644
index 0000000000000..0cc54382b98df
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should only require default Deleter ctor
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int[]> p;
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int[], Deleter> p;
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 5);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp
new file mode 100644
index 0000000000000..82b84948f3f0d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require non-reference Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+public:
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<int[], Deleter&> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
new file mode 100644
index 0000000000000..3ded41c419c88
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test default unique_ptr<T[]> ctor
+
+// default unique_ptr<T[]> ctor shouldn't require complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+ std::unique_ptr<A[], D> a_;
+ B();
+ ~B();
+
+ A* get() const {return a_.get();}
+ D& get_deleter() {return a_.get_deleter();}
+};
+
+int main()
+{
+ {
+ B<> s;
+ assert(s.get() == 0);
+ }
+ check(0);
+ {
+ B<Deleter> s;
+ assert(s.get() == 0);
+ assert(s.get_deleter().state() == 5);
+ }
+ check(0);
+}
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+ assert(A::count == i);
+}
+
+template <class D>
+B<D>::B() {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp
new file mode 100644
index 0000000000000..74d24fd488b65
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require non-pointer Deleter
+
+#include <memory>
+
+int main()
+{
+ std::unique_ptr<int[], void (*)(void*)> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp
new file mode 100644
index 0000000000000..bc49a0e5c31e1
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
new file mode 100644
index 0000000000000..03747b4f89cf6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class NCDeleter
+{
+ int state_;
+
+ NCDeleter(NCDeleter&);
+ NCDeleter& operator=(NCDeleter&);
+public:
+
+ NCDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 3);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A[], Deleter<A[]> > s(new A[3], Deleter<A[]>(5));
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 3);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ NCDeleter d;
+ std::unique_ptr<A[], NCDeleter&> s(new A[3], d);
+ A* p = s.get();
+ std::unique_ptr<A[], NCDeleter&> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 3);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp
new file mode 100644
index 0000000000000..8e44c78bf1e94
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Can't copy from const lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A[]> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
new file mode 100644
index 0000000000000..ef821a915e449
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class NCDeleter
+{
+ int state_;
+
+ NCDeleter(NCDeleter&);
+ NCDeleter& operator=(NCDeleter&);
+public:
+
+ NCDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+std::unique_ptr<A[]>
+source1()
+{
+ return std::unique_ptr<A[]>(new A[3]);
+}
+
+void sink1(std::unique_ptr<A[]> p)
+{
+}
+
+std::unique_ptr<A[], Deleter<A[]> >
+source2()
+{
+ return std::unique_ptr<A[], Deleter<A[]> >(new A[3]);
+}
+
+void sink2(std::unique_ptr<A[], Deleter<A[]> > p)
+{
+}
+
+std::unique_ptr<A[], NCDeleter&>
+source3()
+{
+ static NCDeleter d;
+ return std::unique_ptr<A[], NCDeleter&>(new A[3], d);
+}
+
+void sink3(std::unique_ptr<A[], NCDeleter&> p)
+{
+}
+
+int main()
+{
+ sink1(source1());
+ sink2(source2());
+ sink3(source3());
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp
new file mode 100644
index 0000000000000..c952cf2d4e13c
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Can't copy from lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A[], Deleter> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp
new file mode 100644
index 0000000000000..0d091ff346d12
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor. Can't copy from const lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A[], Deleter> s(new A[3]);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp
new file mode 100644
index 0000000000000..d175fbf93adc5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp
new file mode 100644
index 0000000000000..1838511b49297
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
new file mode 100644
index 0000000000000..36ad75d8331a5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp
new file mode 100644
index 0000000000000..3a19bde928890
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp
new file mode 100644
index 0000000000000..bda2a70a4ef30
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
new file mode 100644
index 0000000000000..fba895137b05f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp
new file mode 100644
index 0000000000000..24c646988f0a3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp
new file mode 100644
index 0000000000000..486d90825d9ef
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
new file mode 100644
index 0000000000000..e4cbef5c05606
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ const std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp
new file mode 100644
index 0000000000000..73423d1b3751f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp
new file mode 100644
index 0000000000000..cfc097ba0b841
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
new file mode 100644
index 0000000000000..fdb088250b9fe
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ const std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp
new file mode 100644
index 0000000000000..d9ef8e96fe8fc
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp
new file mode 100644
index 0000000000000..b4577a126c68a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
new file mode 100644
index 0000000000000..9325d07d0d0c1
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp
new file mode 100644
index 0000000000000..b090e593ec62d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[]> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[]> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp
new file mode 100644
index 0000000000000..b2af3c7a69385
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B[], Deleter<B[]> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
new file mode 100644
index 0000000000000..d1c0e8a781e67
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A[], CDeleter<A>&> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
new file mode 100644
index 0000000000000..9a8c17547bca8
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// unique_ptr(nullptr_t);
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int[]> p(nullptr);
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int[], Deleter> p(nullptr);
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 5);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp
new file mode 100644
index 0000000000000..4c31611508315
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should require default Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+
+ Deleter() {}
+
+public:
+
+ Deleter(Deleter&) {}
+ Deleter& operator=(Deleter&) {}
+
+ void operator()(void*) const {}
+};
+
+int main()
+{
+ std::unique_ptr<int[], Deleter> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
new file mode 100644
index 0000000000000..dab42f277411b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should only require default Deleter ctor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ std::unique_ptr<A[]> s(p);
+ assert(s.get() == p);
+ }
+ assert(A::count == 0);
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ std::unique_ptr<A[], Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp
new file mode 100644
index 0000000000000..af7f27f73fc59
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+#include <memory>
+
+// unique_ptr<T[]>(pointer) ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<int[], Deleter&> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
new file mode 100644
index 0000000000000..1afb1c32ce8c4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor shouldn't require complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A[]> >
+struct B
+{
+ std::unique_ptr<A[], D> a_;
+ explicit B(A*);
+ ~B();
+
+ A* get() const {return a_.get();}
+ D& get_deleter() {return a_.get_deleter();}
+};
+
+A* get();
+
+int main()
+{
+ {
+ A* p = get();
+ check(3);
+ B<> s(p);
+ assert(s.get() == p);
+ }
+ check(0);
+ {
+ A* p = get();
+ check(3);
+ B<Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ check(0);
+}
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+A* get() {return new A[3];}
+
+void Deleter::operator()(A* p) {delete [] p;}
+
+void check(int i)
+{
+ assert(A::count == i);
+}
+
+template <class D>
+B<D>::B(A* a) : a_(a) {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp
new file mode 100644
index 0000000000000..31f7ce367e3dc
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should require non-pointer Deleter
+
+#include <memory>
+
+int main()
+{
+ std::unique_ptr<int[], void (*)(void*)> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
new file mode 100644
index 0000000000000..591144f7aa588
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+// unique_ptr(pointer) ctor should not work with derived pointers
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ B* p = new B[3];
+ std::unique_ptr<A[]> s(p);
+ }
+ {
+ B* p = new B[3];
+ std::unique_ptr<A[], Deleter> s(p);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
new file mode 100644
index 0000000000000..2d62bccdce501
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ std::unique_ptr<A[], Deleter<A[]> > s(p, Deleter<A[]>());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
new file mode 100644
index 0000000000000..914076b50f428
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, d) requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ Deleter d;
+ std::unique_ptr<A[], Deleter> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
new file mode 100644
index 0000000000000..a6f535f38f088
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T[], D&>(pointer, d) does not requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ Deleter d;
+ std::unique_ptr<A[], Deleter&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 6);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
new file mode 100644
index 0000000000000..b635d507b2ecb
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T, const D&>(pointer, D()) should not compile
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) const {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ std::unique_ptr<A[], const Deleter&> s(p, Deleter());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
new file mode 100644
index 0000000000000..a4c917c1af76c
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T[], const D&>(pointer, d) does not requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) const {delete [] p;}
+};
+
+int main()
+{
+ {
+ A* p = new A[3];
+ assert(A::count == 3);
+ Deleter d;
+ std::unique_ptr<A[], const Deleter&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp
new file mode 100644
index 0000000000000..0e03a7da07fb6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, deleter) should not work with derived pointers
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+ B* p = new B[3];
+ std::unique_ptr<A[], Deleter> s(p, Deleter());
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp
new file mode 100644
index 0000000000000..d79a4e396eeda
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test release
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int[]> p(new int[3]);
+ int* i = p.get();
+ int* j = p.release();
+ assert(p.get() == 0);
+ assert(i == j);
+ delete [] j;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp
new file mode 100644
index 0000000000000..195d877bbb700
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> p(new A[3]);
+ assert(A::count == 3);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset();
+ assert(A::count == 0);
+ assert(p.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A[]> p(new A[4]);
+ assert(A::count == 4);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset(new A[5]);
+ assert(A::count == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
new file mode 100644
index 0000000000000..bca6cb2470ac4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A[]> p(new A);
+ assert(A::count == 1);
+ assert(B::count == 0);
+ A* i = p.get();
+ p.reset(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ std::unique_ptr<A[]> p(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ A* i = p.get();
+ p.reset(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp
new file mode 100644
index 0000000000000..e9754cc0f2266
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ int state_;
+ static int count;
+ A() : state_(0) {++count;}
+ explicit A(int i) : state_(i) {++count;}
+ A(const A& a) : state_(a.state_) {++count;}
+ A& operator=(const A& a) {state_ = a.state_; return *this;}
+ ~A() {--count;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* p1 = new A[3];
+ std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1));
+ A* p2 = new A[3];
+ std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2));
+ assert(s1.get() == p1);
+ assert(s1.get_deleter().state() == 1);
+ assert(s2.get() == p2);
+ assert(s2.get_deleter().state() == 2);
+ s1.swap(s2);
+ assert(s1.get() == p2);
+ assert(s1.get_deleter().state() == 2);
+ assert(s2.get() == p1);
+ assert(s2.get_deleter().state() == 1);
+ assert(A::count == 6);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp
new file mode 100644
index 0000000000000..46ba1395bb857
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int[]> p(new int(3));
+ assert(*p == 3);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
new file mode 100644
index 0000000000000..9ec9b9527e8ab
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ std::unique_ptr<int[]> p(new int [3]);
+ if (p)
+ ;
+ else
+ assert(false);
+ if (!p)
+ assert(false);
+ }
+ {
+ std::unique_ptr<int[]> p;
+ if (!p)
+ ;
+ else
+ assert(false);
+ if (p)
+ assert(false);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
new file mode 100644
index 0000000000000..2ae0659adc260
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// test get
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* p = new int[3];
+ std::unique_ptr<int[]> s(p);
+ assert(s.get() == p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
new file mode 100644
index 0000000000000..4496740715a51
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// test get_deleter()
+
+#include <memory>
+#include <cassert>
+
+struct Deleter
+{
+ void operator()(void*) {}
+
+ int test() {return 5;}
+ int test() const {return 6;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int[], Deleter> p;
+ assert(p.get_deleter().test() == 5);
+ }
+ {
+ const std::unique_ptr<int[], Deleter> p;
+ assert(p.get_deleter().test() == 6);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
new file mode 100644
index 0000000000000..519eae688ec1b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// test op[](size_t)
+
+#include <memory>
+#include <cassert>
+
+class A
+{
+ int state_;
+ static int next_;
+public:
+ A() : state_(++next_) {}
+ int get() const {return state_;}
+
+ friend bool operator==(const A& x, int y)
+ {return x.state_ == y;}
+
+ A& operator=(int i) {state_ = i; return *this;}
+};
+
+int A::next_ = 0;
+
+int main()
+{
+ std::unique_ptr<A[]> p(new A[3]);
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3);
+ p[0] = 3;
+ p[1] = 2;
+ p[2] = 1;
+ assert(p[0] == 3);
+ assert(p[1] == 2);
+ assert(p[2] == 1);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp
new file mode 100644
index 0000000000000..1c90ba76af393
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op->()
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ int i_;
+
+ A() : i_(7) {}
+};
+
+int main()
+{
+ std::unique_ptr<A[]> p(new A);
+ assert(p->i_ == 7);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp
new file mode 100644
index 0000000000000..8721062c6d025
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr::pointer type
+
+#include <memory>
+#include <type_traits>
+
+struct Deleter
+{
+ struct pointer {};
+};
+
+int main()
+{
+ {
+ typedef std::unique_ptr<int> P;
+ static_assert((std::is_same<P::pointer, int*>::value), "");
+ }
+ {
+ typedef std::unique_ptr<int, Deleter> P;
+ static_assert((std::is_same<P::pointer, Deleter::pointer>::value), "");
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
new file mode 100644
index 0000000000000..57724ae10a70a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ std::unique_ptr<A> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
new file mode 100644
index 0000000000000..9535ed0295d46
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s1(new A);
+ A* p = s1.get();
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s1);
+ assert(A::count == 1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A, Deleter<A> > s1(new A, Deleter<A>(5));
+ A* p = s1.get();
+ std::unique_ptr<A, Deleter<A> > s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(A::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s1.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ CDeleter<A> d1(5);
+ std::unique_ptr<A, CDeleter<A>&> s1(new A, d1);
+ A* p = s1.get();
+ CDeleter<A> d2(6);
+ std::unique_ptr<A, CDeleter<A>&> s2(new A, d2);
+ s2 = std::move(s1);
+ assert(s2.get() == p);
+ assert(s1.get() == 0);
+ assert(A::count == 1);
+ assert(d1.state() == 5);
+ assert(d2.state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
new file mode 100644
index 0000000000000..5046fd8aae6b3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A> s(new A);
+ std::unique_ptr<A> s2;
+ s2 = s;
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
new file mode 100644
index 0000000000000..aa4fdb8a96b1d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
new file mode 100644
index 0000000000000..e0d7c891c80f6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
new file mode 100644
index 0000000000000..3fd2cbc42bd60
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
new file mode 100644
index 0000000000000..989f594e38b8e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
new file mode 100644
index 0000000000000..0f900603e2390
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// Can't assign from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
new file mode 100644
index 0000000000000..a448c77a66a7f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(new A);
+ assert(A::count == 2);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
new file mode 100644
index 0000000000000..f35af9f453ff0
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ std::unique_ptr<B, Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
new file mode 100644
index 0000000000000..9aea81a8b1444
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ CDeleter<B> db(5);
+ std::unique_ptr<B, CDeleter<B>&> s(new B, db);
+ A* p = s.get();
+ CDeleter<A> da(6);
+ std::unique_ptr<A, CDeleter<A>&> s2(new A, da);
+ s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s.get_deleter().state() == 5);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
new file mode 100644
index 0000000000000..dba901b2ce176
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
new file mode 100644
index 0000000000000..4694986c67730
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2;
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
new file mode 100644
index 0000000000000..220677cd6fa77
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ Deleter<B> db(5);
+ const std::unique_ptr<B, Deleter<B>&> s(new B, db);
+ A* p = s.get();
+ Deleter<A> da(6);
+ std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+ s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
new file mode 100644
index 0000000000000..56ab43c7de246
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<A[], Deleter> s;
+ std::unique_ptr<A, Deleter> s2;
+ s2 = std::move(s);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
new file mode 100644
index 0000000000000..e2d7956cda643
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 1);
+ s2 = 0;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
new file mode 100644
index 0000000000000..fb15849519938
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s2(new A);
+ assert(A::count == 1);
+ s2 = nullptr;
+ assert(A::count == 0);
+ assert(s2.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
new file mode 100644
index 0000000000000..1ce1838afbb7e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A> up(std::move(ap));
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A> up;
+ up = std::move(ap);
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
new file mode 100644
index 0000000000000..1f317c7824542
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+// : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A> up(ap);
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A> up;
+ up = ap;
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp
new file mode 100644
index 0000000000000..2dd5ea30049b8
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct Deleter
+{
+ template <class T>
+ void operator()(T*) {}
+};
+
+int main()
+{
+ {
+ B* p = new B;
+ std::auto_ptr<B> ap(p);
+ std::unique_ptr<A, Deleter> up(ap);
+ assert(up.get() == p);
+ assert(ap.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp
new file mode 100644
index 0000000000000..2ffe1be190e0b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require default Deleter ctor
+class Deleter
+{
+
+ Deleter() {}
+
+public:
+
+ Deleter(Deleter&) {}
+ Deleter& operator=(Deleter&) {}
+
+ void operator()(void*) const {}
+};
+
+int main()
+{
+ std::unique_ptr<int, Deleter> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
new file mode 100644
index 0000000000000..e63db5cb71853
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int> p;
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int, Deleter> p;
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 5);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp
new file mode 100644
index 0000000000000..690750143414b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<int, Deleter&> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
new file mode 100644
index 0000000000000..e9af7e285255b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test default unique_ptr ctor
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor shouldn't require complete type
+
+struct A;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+ std::unique_ptr<A, D> a_;
+ B() {}
+ ~B();
+
+ A* get() const {return a_.get();}
+ D& get_deleter() {return a_.get_deleter();}
+};
+
+int main()
+{
+ {
+ B<> s;
+ assert(s.get() == 0);
+ }
+ check(0);
+ {
+ B<Deleter> s;
+ assert(s.get() == 0);
+ assert(s.get_deleter().state() == 5);
+ }
+ check(0);
+}
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+ assert(A::count == i);
+}
+
+template <class D>
+B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp
new file mode 100644
index 0000000000000..78f6e73a1d55c
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require non-pointer Deleter
+
+int main()
+{
+ std::unique_ptr<int, void (*)(void*)> p;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp
new file mode 100644
index 0000000000000..68ad589b11480
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
new file mode 100644
index 0000000000000..dc16c3115376e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A, Deleter<A> > s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ {
+ CDeleter d;
+ std::unique_ptr<A, CDeleter&> s(new A, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter&> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp
new file mode 100644
index 0000000000000..897b889d67789
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
new file mode 100644
index 0000000000000..4b997df95a0b1
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete p;}
+};
+
+std::unique_ptr<A>
+source1()
+{
+ return std::unique_ptr<A>(new A);
+}
+
+void sink1(std::unique_ptr<A> p)
+{
+}
+
+std::unique_ptr<A, Deleter<A> >
+source2()
+{
+ return std::unique_ptr<A, Deleter<A> >(new A);
+}
+
+void sink2(std::unique_ptr<A, Deleter<A> > p)
+{
+}
+
+std::unique_ptr<A, CDeleter&>
+source3()
+{
+ static CDeleter d;
+ return std::unique_ptr<A, CDeleter&>(new A, d);
+}
+
+void sink3(std::unique_ptr<A, CDeleter&> p)
+{
+}
+
+int main()
+{
+ sink1(source1());
+ sink2(source2());
+ sink3(source3());
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp
new file mode 100644
index 0000000000000..7fb1a0a748114
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp
new file mode 100644
index 0000000000000..671e343fd7f5d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor. Can't copy from const lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter> s(new A);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp
new file mode 100644
index 0000000000000..ed1fe8c2bdd4b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// Can't construct from lvalue
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
new file mode 100644
index 0000000000000..b65cf564a925c
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
new file mode 100644
index 0000000000000..a1bf634b9995e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
new file mode 100644
index 0000000000000..829e7553acd96
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
new file mode 100644
index 0000000000000..7409199791b56
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
new file mode 100644
index 0000000000000..792076a952450
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2(std::move(s));
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp
new file mode 100644
index 0000000000000..981ea706eb293
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
new file mode 100644
index 0000000000000..12ab17fadcd34
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp
new file mode 100644
index 0000000000000..d055b80627f91
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ std::unique_ptr<B, Deleter<B> > s(new B);
+ std::unique_ptr<A, Deleter<A> > s2 = s;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
new file mode 100644
index 0000000000000..8077b0dacb232
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
new file mode 100644
index 0000000000000..5b9b12e0d60ba
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
new file mode 100644
index 0000000000000..4115107b85f9f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp
new file mode 100644
index 0000000000000..bef022cfc1434
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
new file mode 100644
index 0000000000000..978cb0e9024b9
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ CDeleter<B> b(5);
+ std::unique_ptr<B, CDeleter<B>&> s(new B, b);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A> > s2 = std::move(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
new file mode 100644
index 0000000000000..e14bba0763c58
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
new file mode 100644
index 0000000000000..a475c17547c92
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ const std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2(s);
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp
new file mode 100644
index 0000000000000..f0da5efb69174
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<B> s(new B);
+ A* p = s.get();
+ std::unique_ptr<A> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
new file mode 100644
index 0000000000000..bcf94a978144b
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ const std::unique_ptr<B, Deleter<B> > s(new B);
+ A* p = s.get();
+ std::unique_ptr<A, Deleter<A> > s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(s2.get_deleter().state() == 5);
+ assert(s.get_deleter().state() == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
new file mode 100644
index 0000000000000..095bec65669b3
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+// test converting move ctor. Should only require a MoveConstructible deleter, or if
+// deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+ int state_;
+
+ CDeleter(CDeleter&);
+ CDeleter& operator=(CDeleter&);
+public:
+
+ CDeleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ CDeleter<A> d;
+ const std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+ A* p = s.get();
+ std::unique_ptr<A, CDeleter<A>&> s2 = s;
+ assert(s2.get() == p);
+ assert(s.get() == 0);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ d.set_state(6);
+ assert(s2.get_deleter().state() == d.state());
+ assert(s.get_deleter().state() == d.state());
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp
new file mode 100644
index 0000000000000..a4bd2cba1cef8
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<A[], Deleter> s;
+ std::unique_ptr<A, Deleter> s2(std::move(s));
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
new file mode 100644
index 0000000000000..67a48a3e7a12f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// unique_ptr(nullptr_t);
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int> p(nullptr);
+ assert(p.get() == 0);
+ }
+ {
+ std::unique_ptr<int, Deleter> p(nullptr);
+ assert(p.get() == 0);
+ assert(p.get_deleter().state() == 5);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp
new file mode 100644
index 0000000000000..1af04b2c00338
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require default Deleter ctor
+class Deleter
+{
+
+ Deleter() {}
+
+public:
+
+ Deleter(Deleter&) {}
+ Deleter& operator=(Deleter&) {}
+
+ void operator()(void*) const {}
+};
+
+int main()
+{
+ std::unique_ptr<int, Deleter> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
new file mode 100644
index 0000000000000..e5fff774b7909
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor should only require default Deleter ctor
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A> s(p);
+ assert(s.get() == p);
+ }
+ assert(A::count == 0);
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A, Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp
new file mode 100644
index 0000000000000..9b7dd8c70f280
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+ void operator()(void*) {}
+};
+
+int main()
+{
+ std::unique_ptr<int, Deleter&> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
new file mode 100644
index 0000000000000..a226e87d64a4e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor shouldn't require complete type
+
+struct A;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+ std::unique_ptr<A, D> a_;
+ explicit B(A*);
+ ~B();
+
+ A* get() const {return a_.get();}
+ D& get_deleter() {return a_.get_deleter();}
+};
+
+A* get();
+
+int main()
+{
+ {
+ A* p = get();
+ check(1);
+ B<> s(p);
+ assert(s.get() == p);
+ }
+ check(0);
+ {
+ A* p = get();
+ check(1);
+ B<Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ check(0);
+}
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+A* get() {return new A;}
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+ assert(A::count == i);
+}
+
+template <class D>
+B<D>::B(A* a) : a_(a) {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp
new file mode 100644
index 0000000000000..a917d87eeeded
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require non-pointer Deleter
+
+int main()
+{
+ std::unique_ptr<int, void (*)(void*)> p(new int);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
new file mode 100644
index 0000000000000..42fc09453914a
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor should work with derived pointers
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A> s(p);
+ assert(s.get() == p);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A, Deleter> s(p);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
new file mode 100644
index 0000000000000..130f91d6216f5
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+ int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+ Deleter& operator=(Deleter&& r)
+ {
+ state_ = r.state_;
+ r.state_ = 0;
+ return *this;
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+ Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+ Deleter& operator=(std::__rv<Deleter> r)
+ {
+ state_ = r->state_;
+ r->state_ = 0;
+ return *this;
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+ Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U>&& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {d.set_state(0);}
+
+private:
+ template <class U>
+ Deleter(const Deleter<U>& d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ template <class U>
+ Deleter(Deleter<U> d,
+ typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+ : state_(d.state()) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
new file mode 100644
index 0000000000000..421bec55f99c6
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, d) requires CopyConstructible deleter
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ Deleter d;
+ std::unique_ptr<A, Deleter> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
new file mode 100644
index 0000000000000..bce79dbb1a978
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, D&>(pointer, d) does not requires CopyConstructible deleter
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ Deleter d;
+ std::unique_ptr<A, Deleter&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ d.set_state(6);
+ assert(s.get_deleter().state() == 6);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
new file mode 100644
index 0000000000000..7cacd1fda9f39
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, const D&>(pointer, D()) should not compile
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) const {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ std::unique_ptr<A, const Deleter&> s(p, Deleter());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
new file mode 100644
index 0000000000000..a7750fcb9f0fd
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, const D&>(pointer, d) does not requires CopyConstructible deleter
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+ int state_;
+
+ Deleter(const Deleter&);
+ Deleter& operator=(const Deleter&);
+public:
+
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+ void set_state(int s) {state_ = s;}
+
+ void operator()(A* p) const {delete p;}
+};
+
+int main()
+{
+ {
+ A* p = new A;
+ assert(A::count == 1);
+ Deleter d;
+ std::unique_ptr<A, const Deleter&> s(p, d);
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
new file mode 100644
index 0000000000000..1a83258e1e415
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter) should work with derived pointers
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+ int state_;
+
+public:
+ Deleter() : state_(5) {}
+
+ int state() const {return state_;}
+
+ void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+ {
+ B* p = new B;
+ assert(A::count == 1);
+ assert(B::count == 1);
+ std::unique_ptr<A, Deleter> s(p, Deleter());
+ assert(s.get() == p);
+ assert(s.get_deleter().state() == 5);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
new file mode 100644
index 0000000000000..ed68052cd3bba
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter) should work with function pointers
+// unique_ptr<void> should work
+
+bool my_free_called = false;
+
+void my_free(void*)
+{
+ my_free_called = true;
+}
+
+int main()
+{
+ {
+ int i = 0;
+ std::unique_ptr<void, void (*)(void*)> s(&i, my_free);
+ assert(s.get() == &i);
+ assert(s.get_deleter() == my_free);
+ assert(!my_free_called);
+ }
+ assert(my_free_called);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp
new file mode 100644
index 0000000000000..064f38c5f167f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// The deleter is not called if get() == 0
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+ int state_;
+
+ Deleter(Deleter&);
+ Deleter& operator=(Deleter&);
+
+public:
+ Deleter() : state_(0) {}
+
+ int state() const {return state_;}
+
+ void operator()(void*) {++state_;}
+};
+
+int main()
+{
+ Deleter d;
+ assert(d.state() == 0);
+ {
+ std::unique_ptr<int, Deleter&> p(0, d);
+ assert(p.get() == 0);
+ assert(&p.get_deleter() == &d);
+ }
+ assert(d.state() == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp
new file mode 100644
index 0000000000000..dadd4ecbe5901
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test release
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int> p(new int(3));
+ int* i = p.get();
+ int* j = p.release();
+ assert(p.get() == 0);
+ assert(i == j);
+ delete j;
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp
new file mode 100644
index 0000000000000..2cf7f8b775683
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> p(new A);
+ assert(A::count == 1);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset();
+ assert(A::count == 0);
+ assert(p.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> p(new A);
+ assert(A::count == 1);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset(new A);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp
new file mode 100644
index 0000000000000..2de7787b267e4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> p(new A);
+ assert(A::count == 1);
+ assert(B::count == 0);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+ {
+ std::unique_ptr<A> p(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ A* i = p.get();
+ assert(i != nullptr);
+ p.reset(new B);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp
new file mode 100644
index 0000000000000..58b05efa25f61
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset against resetting self
+
+#include <memory>
+
+struct A
+{
+ std::unique_ptr<A> ptr_;
+
+ A() : ptr_(this) {}
+ void reset() {ptr_.reset();}
+};
+
+int main()
+{
+ (new A)->reset();
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp
new file mode 100644
index 0000000000000..d0a03be803269
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+ int state_;
+ static int count;
+ explicit A(int i) : state_(i) {++count;}
+ A(const A& a) : state_(a.state_) {++count;}
+ A& operator=(const A& a) {state_ = a.state_; return *this;}
+ ~A() {--count;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* p1 = new A(1);
+ std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1));
+ A* p2 = new A(2);
+ std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2));
+ assert(s1.get() == p1);
+ assert(*s1 == A(1));
+ assert(s1.get_deleter().state() == 1);
+ assert(s2.get() == p2);
+ assert(*s2 == A(2));
+ assert(s2.get_deleter().state() == 2);
+ s1.swap(s2);
+ assert(s1.get() == p2);
+ assert(*s1 == A(2));
+ assert(s1.get_deleter().state() == 2);
+ assert(s2.get() == p1);
+ assert(*s2 == A(1));
+ assert(s2.get_deleter().state() == 1);
+ assert(A::count == 2);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
new file mode 100644
index 0000000000000..9d0cfcaaf353d
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::unique_ptr<int> p(new int(3));
+ assert(*p == 3);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
new file mode 100644
index 0000000000000..d5c7445b0d86f
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ std::unique_ptr<int> p(new int(3));
+ if (p)
+ ;
+ else
+ assert(false);
+ if (!p)
+ assert(false);
+ }
+ {
+ std::unique_ptr<int> p;
+ if (!p)
+ ;
+ else
+ assert(false);
+ if (p)
+ assert(false);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
new file mode 100644
index 0000000000000..24fa6beb42733
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// test get
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* p = new int;
+ std::unique_ptr<int> s(p);
+ assert(s.get() == p);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
new file mode 100644
index 0000000000000..5ed8a22b14c45
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// test get_deleter()
+
+#include <memory>
+#include <cassert>
+
+struct Deleter
+{
+ void operator()(void*) {}
+
+ int test() {return 5;}
+ int test() const {return 6;}
+};
+
+int main()
+{
+ {
+ std::unique_ptr<int, Deleter> p;
+ assert(p.get_deleter().test() == 5);
+ }
+ {
+ const std::unique_ptr<int, Deleter> p;
+ assert(p.get_deleter().test() == 6);
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
new file mode 100644
index 0000000000000..21e829cbc4442
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// test op[](size_t)
+
+#include <memory>
+#include <cassert>
+
+class A
+{
+ int state_;
+ static int next_;
+public:
+ A() : state_(++next_) {}
+ int get() const {return state_;}
+
+ friend bool operator==(const A& x, int y)
+ {return x.state_ == y;}
+
+ A& operator=(int i) {state_ = i; return *this;}
+};
+
+int A::next_ = 0;
+
+int main()
+{
+ std::unique_ptr<A> p(new A[3]);
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3);
+ p[0] = 3;
+ p[1] = 2;
+ p[2] = 1;
+ assert(p[0] == 3);
+ assert(p[1] == 2);
+ assert(p[2] == 1);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
new file mode 100644
index 0000000000000..47de8f66ed2e4
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op->()
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ int i_;
+
+ A() : i_(7) {}
+};
+
+int main()
+{
+ std::unique_ptr<A> p(new A);
+ assert(p->i_ == 7);
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
new file mode 100644
index 0000000000000..22ae217a61d64
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template <class T, class D>
+// bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator<(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator<(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator<=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator<=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator>(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator>(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+// bool operator>=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+// bool operator>=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+ const std::unique_ptr<int> p1(new int(1));
+ assert(!(p1 == nullptr));
+ assert(!(nullptr == p1));
+ assert(!(p1 < nullptr));
+ assert( (nullptr < p1));
+ assert(!(p1 <= nullptr));
+ assert( (nullptr <= p1));
+ assert( (p1 > nullptr));
+ assert(!(nullptr > p1));
+ assert( (p1 >= nullptr));
+ assert(!(nullptr >= p1));
+
+ const std::unique_ptr<int> p2;
+ assert( (p2 == nullptr));
+ assert( (nullptr == p2));
+ assert(!(p2 < nullptr));
+ assert(!(nullptr < p2));
+ assert( (p2 <= nullptr));
+ assert( (nullptr <= p2));
+ assert(!(p2 > nullptr));
+ assert(!(nullptr > p2));
+ assert( (p2 >= nullptr));
+ assert( (nullptr >= p2));
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp
new file mode 100644
index 0000000000000..37886548e7212
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter<A> > p1(new A);
+ const std::unique_ptr<A, Deleter<A> > p2(new A);
+ assert(!(p1 == p2));
+ assert(p1 != p2);
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1(new A);
+ const std::unique_ptr<B, Deleter<B> > p2(new B);
+ assert(!(p1 == p2));
+ assert(p1 != p2);
+ }
+ {
+ const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+ const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]);
+ assert(!(p1 == p2));
+ assert(p1 != p2);
+ }
+ {
+ const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+ const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]);
+ assert(!(p1 == p2));
+ assert(p1 != p2);
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1;
+ const std::unique_ptr<A, Deleter<A> > p2;
+ assert(p1 == p2);
+ assert(!(p1 != p2));
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1;
+ const std::unique_ptr<B, Deleter<B> > p2;
+ assert(p1 == p2);
+ assert(!(p1 != p2));
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp
new file mode 100644
index 0000000000000..80653cf707c3e
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator< (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator> (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+// bool
+// operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ static int count;
+ A() {++count;}
+ A(const A&) {++count;}
+ virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+ : public A
+{
+ static int count;
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+ {
+ const std::unique_ptr<A, Deleter<A> > p1(new A);
+ const std::unique_ptr<A, Deleter<A> > p2(new A);
+ assert((p1 < p2) == !(p1 > p2));
+ assert((p1 < p2) == (p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1(new A);
+ const std::unique_ptr<B, Deleter<B> > p2(new B);
+ assert((p1 < p2) == !(p1 > p2));
+ assert((p1 < p2) == (p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+ const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]);
+ assert((p1 < p2) == !(p1 > p2));
+ assert((p1 < p2) == (p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+ const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]);
+ assert((p1 < p2) == !(p1 > p2));
+ assert((p1 < p2) == (p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1;
+ const std::unique_ptr<A, Deleter<A> > p2;
+ assert((p1 < p2) == (p1 > p2));
+ assert((p1 < p2) == !(p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+ {
+ const std::unique_ptr<A, Deleter<A> > p1;
+ const std::unique_ptr<B, Deleter<B> > p2;
+ assert((p1 < p2) == (p1 > p2));
+ assert((p1 < p2) == !(p1 <= p2));
+ assert((p1 < p2) == !(p1 >= p2));
+ }
+}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
new file mode 100644
index 0000000000000..44b746fbcfd86
--- /dev/null
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// unique_ptr
+
+// Test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+ int state_;
+ static int count;
+ A() : state_(0) {++count;}
+ explicit A(int i) : state_(i) {++count;}
+ A(const A& a) : state_(a.state_) {++count;}
+ A& operator=(const A& a) {state_ = a.state_; return *this;}
+ ~A() {--count;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* p1 = new A(1);
+ std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1));
+ A* p2 = new A(2);
+ std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2));
+ assert(s1.get() == p1);
+ assert(*s1 == A(1));
+ assert(s1.get_deleter().state() == 1);
+ assert(s2.get() == p2);
+ assert(*s2 == A(2));
+ assert(s2.get_deleter().state() == 2);
+ swap(s1, s2);
+ assert(s1.get() == p2);
+ assert(*s1 == A(2));
+ assert(s1.get_deleter().state() == 2);
+ assert(s2.get() == p1);
+ assert(*s2 == A(1));
+ assert(s2.get_deleter().state() == 1);
+ assert(A::count == 2);
+ }
+ assert(A::count == 0);
+ {
+ A* p1 = new A[3];
+ std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1));
+ A* p2 = new A[3];
+ std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2));
+ assert(s1.get() == p1);
+ assert(s1.get_deleter().state() == 1);
+ assert(s2.get() == p2);
+ assert(s2.get_deleter().state() == 2);
+ swap(s1, s2);
+ assert(s1.get() == p2);
+ assert(s1.get_deleter().state() == 2);
+ assert(s2.get() == p1);
+ assert(s2.get_deleter().state() == 1);
+ assert(A::count == 6);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp b/test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp
new file mode 100644
index 0000000000000..bbf4be20f8fe7
--- /dev/null
+++ b/test/std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// void declare_no_pointers(char* p, size_t n);
+// void undeclare_no_pointers(char* p, size_t n);
+
+#include <memory>
+
+int main()
+{
+ char* p = new char[10];
+ std::declare_no_pointers(p, 10);
+ std::undeclare_no_pointers(p, 10);
+ delete [] p;
+}
diff --git a/test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp b/test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
new file mode 100644
index 0000000000000..3f0bcead9bef1
--- /dev/null
+++ b/test/std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void declare_reachable(void* p);
+// template <class T> T* undeclare_reachable(T* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* p = new int;
+ std::declare_reachable(p);
+ assert(std::undeclare_reachable(p) == p);
+ delete p;
+}
diff --git a/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp b/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
new file mode 100644
index 0000000000000..1f27b45e8ab8e
--- /dev/null
+++ b/test/std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// pointer_safety get_pointer_safety();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::pointer_safety r = std::get_pointer_safety();
+ assert(r == std::pointer_safety::relaxed ||
+ r == std::pointer_safety::preferred ||
+ r == std::pointer_safety::strict);
+}
diff --git a/test/std/utilities/memory/util.smartptr/nothing_to_do.pass.cpp b/test/std/utilities/memory/util.smartptr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/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/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
new file mode 100644
index 0000000000000..77af13fa90d18
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.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.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class T>
+// class enable_shared_from_this
+// {
+// protected:
+// enable_shared_from_this();
+// enable_shared_from_this(enable_shared_from_this const&);
+// enable_shared_from_this& operator=(enable_shared_from_this const&);
+// ~enable_shared_from_this();
+// public:
+// shared_ptr<T> shared_from_this();
+// shared_ptr<T const> shared_from_this() const;
+// };
+
+#include <memory>
+#include <cassert>
+
+struct T
+ : public std::enable_shared_from_this<T>
+{
+};
+
+struct Y : T {};
+
+struct Z : Y {};
+
+int main()
+{
+ { // https://llvm.org/bugs/show_bug.cgi?id=18843
+ std::shared_ptr<T const> t1(new T);
+ std::shared_ptr<T const> t2(std::make_shared<T>());
+ }
+ {
+ std::shared_ptr<Y> p(new Z);
+ std::shared_ptr<T> q = p->shared_from_this();
+ assert(p == q);
+ assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
+ }
+ {
+ std::shared_ptr<Y> p = std::make_shared<Z>();
+ std::shared_ptr<T> q = p->shared_from_this();
+ assert(p == q);
+ assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp
new file mode 100644
index 0000000000000..990cb58722b1c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct hash<shared_ptr<T>>
+// {
+// typedef shared_ptr<T> argument_type;
+// typedef size_t result_type;
+// size_t operator()(const shared_ptr<T>& p) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* ptr = new int;
+ std::shared_ptr<int> p(ptr);
+ std::hash<std::shared_ptr<int> > f;
+ std::size_t h = f(p);
+ assert(h == std::hash<int*>()(ptr));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
new file mode 100644
index 0000000000000..5cd4ab1f83d0e
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T, class D>
+// struct hash<unique_ptr<T, D>>
+// {
+// typedef unique_ptr<T, D> argument_type;
+// typedef size_t result_type;
+// size_t operator()(const unique_ptr<T, D>& p) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ int* ptr = new int;
+ std::unique_ptr<int> p(ptr);
+ std::hash<std::unique_ptr<int> > f;
+ std::size_t h = f(p);
+ assert(h == std::hash<int*>()(ptr));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp
new file mode 100644
index 0000000000000..2d586e9c7fdd1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.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-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_strong(shared_ptr<T>* p, shared_ptr<T>* v,
+// shared_ptr<T> w);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v(new int(3));
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_strong(&p, &v, w);
+ assert(b == false);
+ assert(*p == 4);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v = p;
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_strong(&p, &v, w);
+ assert(b == true);
+ assert(*p == 2);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp
new file mode 100644
index 0000000000000..34da04cc18108
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+// shared_ptr<T> w, memory_order success,
+// memory_order failure);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v(new int(3));
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_strong_explicit(&p, &v, w,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst);
+ assert(b == false);
+ assert(*p == 4);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v = p;
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_strong_explicit(&p, &v, w,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst);
+ assert(b == true);
+ assert(*p == 2);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp
new file mode 100644
index 0000000000000..50b96e551fd3b
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.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-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v,
+// shared_ptr<T> w);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v(new int(3));
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_weak(&p, &v, w);
+ assert(b == false);
+ assert(*p == 4);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v = p;
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_weak(&p, &v, w);
+ assert(b == true);
+ assert(*p == 2);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp
new file mode 100644
index 0000000000000..d304319d251de
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.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.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+// shared_ptr<T> w, memory_order success,
+// memory_order failure);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v(new int(3));
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_weak_explicit(&p, &v, w,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst);
+ assert(b == false);
+ assert(*p == 4);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> v = p;
+ std::shared_ptr<int> w(new int(2));
+ bool b = std::atomic_compare_exchange_weak_explicit(&p, &v, w,
+ std::memory_order_seq_cst,
+ std::memory_order_seq_cst);
+ assert(b == true);
+ assert(*p == 2);
+ assert(*v == 4);
+ assert(*w == 2);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp
new file mode 100644
index 0000000000000..3b44c8ba9b330
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> r(new int(3));
+ r = std::atomic_exchange(&p, r);
+ assert(*p == 3);
+ assert(*r == 4);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp
new file mode 100644
index 0000000000000..598a1b8da175c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(4));
+ std::shared_ptr<int> r(new int(3));
+ r = std::atomic_exchange_explicit(&p, r, std::memory_order_seq_cst);
+ assert(*p == 3);
+ assert(*r == 4);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp
new file mode 100644
index 0000000000000..e3ac84a4fa507
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.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
+
+// <memory>
+
+// shared_ptr
+
+// template<class T>
+// bool
+// atomic_is_lock_free(const shared_ptr<T>* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ const std::shared_ptr<int> p(new int(3));
+ assert(std::atomic_is_lock_free(&p) == false);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp
new file mode 100644
index 0000000000000..d4a39c878ac7a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_load(const shared_ptr<T>* p)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p(new int(3));
+ std::shared_ptr<int> q = std::atomic_load(&p);
+ assert(*q == *p);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp
new file mode 100644
index 0000000000000..af11dc8bc2c9c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_load_explicit(const shared_ptr<T>* p, memory_order mo)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ const std::shared_ptr<int> p(new int(3));
+ std::shared_ptr<int> q = std::atomic_load_explicit(&p, std::memory_order_relaxed);
+ assert(*q == *p);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp
new file mode 100644
index 0000000000000..7a85a9934ef0a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// void
+// atomic_store(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p;
+ std::shared_ptr<int> r(new int(3));
+ std::atomic_store(&p, r);
+ assert(*p == *r);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp
new file mode 100644
index 0000000000000..c81266c55fa47
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+//
+// This test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
+// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// void
+// atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+ {
+ std::shared_ptr<int> p;
+ std::shared_ptr<int> r(new int(3));
+ std::atomic_store_explicit(&p, r, std::memory_order_seq_cst);
+ assert(*p == *r);
+ }
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h
new file mode 100644
index 0000000000000..0263061b3a84a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// Example move-only deleter
+
+#ifndef DELETER_H
+#define DELETER_H
+
+#include <type_traits>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define DELETE_FUNCTION = delete
+#else
+#define DELETE_FUNCTION { assert(false); }
+#endif
+
+struct test_deleter_base
+{
+ static int count;
+ static int dealloc_count;
+};
+
+int test_deleter_base::count = 0;
+int test_deleter_base::dealloc_count = 0;
+
+template <class T>
+class test_deleter
+ : public test_deleter_base
+{
+ int state_;
+
+public:
+
+ test_deleter() : state_(0) {++count;}
+ explicit test_deleter(int s) : state_(s) {++count;}
+ test_deleter(const test_deleter& d)
+ : state_(d.state_) {++count;}
+ ~test_deleter() {assert(state_ >= 0); --count; state_ = -1;}
+
+ int state() const {return state_;}
+ void set_state(int i) {state_ = i;}
+
+ void operator()(T* p) {assert(state_ >= 0); ++dealloc_count; delete p;}
+
+ test_deleter* operator&() const DELETE_FUNCTION;
+};
+
+template <class T>
+void
+swap(test_deleter<T>& x, test_deleter<T>& y)
+{
+ test_deleter<T> t(std::move(x));
+ x = std::move(y);
+ y = std::move(t);
+}
+
+#endif // DELETER_H
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp
new file mode 100644
index 0000000000000..8175312334f66
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class shared_ptr
+// {
+// public:
+// typedef T element_type;
+// ...
+// };
+
+#include <memory>
+
+struct A; // purposefully incomplete
+
+int main()
+{
+ static_assert((std::is_same<std::shared_ptr<A>::element_type, A>::value), "");
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
new file mode 100644
index 0000000000000..a6c62496fd62f
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class D, class T> D* get_deleter(const shared_ptr<T>& p);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ }
+ test_deleter<A>::dealloc_count = 0;
+ {
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ }
+ test_deleter<A>::dealloc_count = 0;
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+ std::default_delete<A>* d = std::get_deleter<std::default_delete<A> >(p);
+ assert(d == 0);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
new file mode 100644
index 0000000000000..21cdf4a13e476
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::auto_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp
new file mode 100644
index 0000000000000..5d27a8865f08c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// shared_ptr& operator=(const shared_ptr& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB(new A);
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB(new A);
+ pB = pA;
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB;
+ pB = pA;
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000000000..abd3d378eb716
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = pA;
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ const std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = pA;
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
new file mode 100644
index 0000000000000..93956bcae6634
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
new file mode 100644
index 0000000000000..4194890dda2d8
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// shared_ptr& operator=(shared_ptr&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB(new A);
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB(new A);
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<A> pB;
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+#endif // _LIBCXX_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
new file mode 100644
index 0000000000000..30e0fce21e04c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::unique_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB(new B);
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+// assert(pB.use_count() == 1); // no longer true due to LWG 2415
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> pA(new A);
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> pA;
+ A* ptrA = pA.get();
+ {
+ std::shared_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+// assert(pB.use_count() == 1); // no longer true due to LWG 2415
+ assert(pA.get() == 0);
+ assert(pB.get() == ptrA);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp
new file mode 100644
index 0000000000000..7d771d03c71f5
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<const A> pA(new A);
+ std::shared_ptr<A> pB = std::const_pointer_cast<A>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<const A> pA;
+ std::shared_ptr<A> pB = std::const_pointer_cast<A>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp
new file mode 100644
index 0000000000000..4f88a5c4351a7
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<B> pB(new A);
+ std::shared_ptr<A> pA = std::dynamic_pointer_cast<A>(pB);
+ assert(pA.get() == pB.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<B> pB(new B);
+ std::shared_ptr<A> pA = std::dynamic_pointer_cast<A>(pB);
+ assert(pA.get() == 0);
+ assert(pA.use_count() == 0);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp
new file mode 100644
index 0000000000000..98fa13801a8c7
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> pA(new A);
+ std::shared_ptr<B> pB = std::static_pointer_cast<B>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<B> pA(new A);
+ std::shared_ptr<A> pB = std::static_pointer_cast<A>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<A> pA;
+ std::shared_ptr<B> pB = std::static_pointer_cast<B>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+ {
+ const std::shared_ptr<B> pA;
+ std::shared_ptr<A> pB = std::static_pointer_cast<A>(pA);
+ assert(pB.get() == pA.get());
+ assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
new file mode 100644
index 0000000000000..f40cbc3d0324a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template <class T>
+// bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+// bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+// bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int(1));
+ assert(!(p1 == nullptr));
+ assert(!(nullptr == p1));
+ assert(!(p1 < nullptr));
+ assert( (nullptr < p1));
+ assert(!(p1 <= nullptr));
+ assert( (nullptr <= p1));
+ assert( (p1 > nullptr));
+ assert(!(nullptr > p1));
+ assert( (p1 >= nullptr));
+ assert(!(nullptr >= p1));
+
+ const std::shared_ptr<int> p2;
+ assert( (p2 == nullptr));
+ assert( (nullptr == p2));
+ assert(!(p2 < nullptr));
+ assert(!(nullptr < p2));
+ assert( (p2 <= nullptr));
+ assert( (nullptr <= p2));
+ assert(!(p2 > nullptr));
+ assert(!(nullptr > p2));
+ assert( (p2 >= nullptr));
+ assert( (nullptr >= p2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp
new file mode 100644
index 0000000000000..c4cd1693f4966
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b);
+// template<class T, class U> bool operator!=(const shared_ptr<T>& a, const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+ int* ptr1(new int);
+ int* ptr2(new int);
+ const std::shared_ptr<int> p1(ptr1);
+ const std::shared_ptr<int> p2(ptr2);
+ const std::shared_ptr<int> p3(ptr2, do_nothing);
+ assert(p1 != p2);
+ assert(p2 == p3);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp
new file mode 100644
index 0000000000000..5a90a9a325fa2
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+ int* ptr1(new int);
+ int* ptr2(new int);
+ const std::shared_ptr<int> p1(ptr1);
+ const std::shared_ptr<int> p2(ptr2);
+ const std::shared_ptr<int> p3(ptr2, do_nothing);
+ assert((p1 < p2) == (ptr1 < ptr2));
+ assert(!(p2 < p3) && !(p3 < p2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
new file mode 100644
index 0000000000000..b2e61faff5ed9
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template<class Y> explicit shared_ptr(auto_ptr<Y>&& r);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::auto_ptr<A> ptr(new A);
+ A* raw_ptr = ptr.get();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::shared_ptr<B> p(std::move(ptr));
+#else
+ std::shared_ptr<B> p(ptr);
+#endif
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == raw_ptr);
+ assert(ptr.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::auto_ptr<A> ptr(new A);
+ A* raw_ptr = ptr.get();
+ throw_next = true;
+ try
+ {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::shared_ptr<B> p(std::move(ptr));
+#else
+ std::shared_ptr<B> p(ptr);
+#endif
+ assert(false);
+ }
+ catch (...)
+ {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(ptr.get() == raw_ptr);
+#else
+ // Without rvalue references, ptr got copied into
+ // the shared_ptr destructor and the copy was
+ // destroyed during unwinding.
+ assert(A::count == 0);
+ assert(B::count == 0);
+#endif
+ }
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp
new file mode 100644
index 0000000000000..9af5d7ea86191
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::shared_ptr<int> p;
+ assert(p.use_count() == 0);
+ assert(p.get() == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp
new file mode 100644
index 0000000000000..3a9b3a9ca1dee
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr(nullptr_t)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ std::shared_ptr<int> p(nullptr);
+ assert(p.use_count() == 0);
+ assert(p.get() == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
new file mode 100644
index 0000000000000..7d4dc38d4b9a0
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class D> shared_ptr(nullptr_t, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+ assert(A::count == 0);
+ assert(p.use_count() == 1);
+ assert(p.get() == 0);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
new file mode 100644
index 0000000000000..b67f31ee45a85
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5));
+ assert(A::count == 0);
+ assert(p.use_count() == 1);
+ assert(p.get() == 0);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ assert(test_allocator<A>::count == 1);
+ assert(test_allocator<A>::alloc_count == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ test_deleter<A>::dealloc_count = 0;
+ // Test an allocator with a minimal interface
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(1), bare_allocator<void>());
+ assert(A::count == 0);
+ assert(p.use_count() == 1);
+ assert(p.get() == 0);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count ==1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ test_deleter<A>::dealloc_count = 0;
+#if __cplusplus >= 201103L
+ // Test an allocator that returns class-type pointers
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(1), min_allocator<void>());
+ assert(A::count == 0);
+ assert(p.use_count() == 1);
+ assert(p.get() == 0);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count ==1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
new file mode 100644
index 0000000000000..ab2c73e0c5f1a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ try
+ {
+ test_allocator<A>::throw_after = 0;
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5));
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
new file mode 100644
index 0000000000000..97d3f69fb5c4b
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class D> shared_ptr(nullptr_t, D d);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <cassert>
+#include <new>
+#include <cstdlib>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+int main()
+{
+ throw_next = true;
+ try
+ {
+ std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
new file mode 100644
index 0000000000000..c9cffa1fe25e1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template<class Y> explicit shared_ptr(Y* p);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr);
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr = new A;
+ std::shared_ptr<void> p(ptr);
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
new file mode 100644
index 0000000000000..43eedee176c2c
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D> shared_ptr(Y* p, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
new file mode 100644
index 0000000000000..1a9c09cdb78ce
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+
+int main()
+{
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3), test_allocator<A>(5));
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ assert(test_allocator<A>::count == 1);
+ assert(test_allocator<A>::alloc_count == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ test_deleter<A>::dealloc_count = 0;
+ // Test an allocator with a minimal interface
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3), bare_allocator<void>());
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ test_deleter<A>::dealloc_count = 0;
+#if __cplusplus >= 201103L
+ // Test an allocator that returns class-type pointers
+ {
+ A* ptr = new A;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3), min_allocator<void>());
+ assert(A::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
new file mode 100644
index 0000000000000..4220993a5fd11
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ A* ptr = new A;
+ try
+ {
+ test_allocator<A>::throw_after = 0;
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3), test_allocator<A>(5));
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
new file mode 100644
index 0000000000000..ead081645671b
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D> shared_ptr(Y* p, D d);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <cassert>
+#include <new>
+#include <cstdlib>
+#include "../test_deleter.h"
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+int main()
+{
+ A* ptr = new A;
+ throw_next = true;
+ try
+ {
+ std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
new file mode 100644
index 0000000000000..041fe9a7853d7
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y> explicit shared_ptr(Y* p);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+int main()
+{
+ {
+ A* ptr = new A;
+ throw_next = true;
+ assert(A::count == 1);
+ try
+ {
+ std::shared_ptr<A> p(ptr);
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(A::count == 0);
+ }
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp
new file mode 100644
index 0000000000000..e1dcdfc8165fe
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr(const shared_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ {
+ std::shared_ptr<A> pA2(pA);
+ assert(A::count == 1);
+ assert(pA.use_count() == 2);
+ assert(pA2.use_count() == 2);
+ assert(pA2.get() == pA.get());
+ }
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA2(pA);
+ assert(A::count == 0);
+ assert(pA.use_count() == 0);
+ assert(pA2.use_count() == 0);
+ assert(pA2.get() == pA.get());
+ }
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000000000..8b5ffdc1475b0
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+ static_assert(( std::is_convertible<std::shared_ptr<A>, std::shared_ptr<B> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<B>, std::shared_ptr<A> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<A>, std::shared_ptr<C> >::value), "");
+ {
+ const std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ {
+ std::shared_ptr<B> pB(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+ assert(pA.get() == pB.get());
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
new file mode 100644
index 0000000000000..f041d9451a6d8
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(shared_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+ static_assert(( std::is_convertible<std::shared_ptr<A>, std::shared_ptr<B> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<B>, std::shared_ptr<A> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<A>, std::shared_ptr<C> >::value), "");
+ {
+ std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ {
+ B* p = pA.get();
+ std::shared_ptr<B> pB(std::move(pA));
+ assert(B::count == 1);
+ assert(A::count == 1);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pB.use_count() == 2);
+ assert(pA.use_count() == 2);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(p == pB.get());
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ assert(pA.get() == pB.get());
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp
new file mode 100644
index 0000000000000..fb5262f3b0efc
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ {
+ B b;
+ std::shared_ptr<B> pB(pA, &b);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(pA.use_count() == 2);
+ assert(pB.use_count() == 2);
+ assert(pB.get() == &b);
+ }
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ assert(B::count == 0);
+ }
+ assert(A::count == 0);
+ assert(B::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
new file mode 100644
index 0000000000000..b89178e201cfc
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// shared_ptr(shared_ptr&& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ {
+ A* p = pA.get();
+ std::shared_ptr<A> pA2(std::move(pA));
+ assert(A::count == 1);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 0);
+ assert(pA2.use_count() == 1);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 2);
+ assert(pA2.use_count() == 2);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA2.get() == p);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA2(std::move(pA));
+ assert(A::count == 0);
+ assert(pA.use_count() == 0);
+ assert(pA2.use_count() == 0);
+ assert(pA2.get() == pA.get());
+ }
+ assert(pA.use_count() == 0);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
new file mode 100644
index 0000000000000..5e09d9a7934c1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Y, class D> explicit shared_ptr(unique_ptr<Y, D>&&r);
+
+// UNSUPPORTED: sanitizer-new-delete
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next)
+ throw std::bad_alloc();
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ std::free(p);
+}
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+void fn ( const std::shared_ptr<int> &) {}
+void fn ( const std::shared_ptr<B> &) { assert (false); }
+
+template <typename T>
+void assert_deleter ( T * ) { assert(false); }
+
+int main()
+{
+ {
+ std::unique_ptr<A> ptr(new A);
+ A* raw_ptr = ptr.get();
+ std::shared_ptr<B> p(std::move(ptr));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == raw_ptr);
+ assert(ptr.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::unique_ptr<A> ptr(new A);
+ A* raw_ptr = ptr.get();
+ throw_next = true;
+ try
+ {
+ std::shared_ptr<B> p(std::move(ptr));
+ assert(false);
+ }
+ catch (...)
+ {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(ptr.get() == raw_ptr);
+#else
+ assert(A::count == 0);
+ assert(B::count == 0);
+ assert(ptr.get() == 0);
+#endif
+ }
+ }
+ assert(A::count == 0);
+
+ // LWG 2399
+ {
+ throw_next = false;
+ fn(std::unique_ptr<int>(new int));
+ }
+
+#if __cplusplus >= 201402L
+ // LWG 2415
+ {
+ std::unique_ptr<int, void (*)(int*)> p(nullptr, assert_deleter<int>);
+ std::shared_ptr<int> p2(std::move(p)); // should not call deleter when going out of scope
+ }
+#endif
+
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
new file mode 100644
index 0000000000000..a9d8aff145a70
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::weak_ptr<A> wp;
+ try
+ {
+ std::shared_ptr<A> sp(wp);
+ assert(false);
+ }
+ catch (std::bad_weak_ptr&)
+ {
+ }
+ assert(A::count == 0);
+ }
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ std::shared_ptr<A> sp(wp);
+ assert(sp.use_count() == 2);
+ assert(sp.get() == sp0.get());
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ sp0.reset();
+ try
+ {
+ std::shared_ptr<A> sp(wp);
+ assert(false);
+ }
+ catch (std::bad_weak_ptr&)
+ {
+ }
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
new file mode 100644
index 0000000000000..aa77dab51515f
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class T, class A, class... Args>
+// shared_ptr<T> allocate_shared(const A& a, Args&&... args);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int new_count = 0;
+
+struct A
+{
+ static int count;
+
+ A(int i, char c) : int_(i), char_(c) {++count;}
+ A(const A& a)
+ : int_(a.int_), char_(a.char_)
+ {++count;}
+ ~A() {--count;}
+
+ int get_int() const {return int_;}
+ char get_char() const {return char_;}
+private:
+ int int_;
+ char char_;
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ int i = 67;
+ char c = 'e';
+ std::shared_ptr<A> p = std::allocate_shared<A>(test_allocator<A>(54), i, c);
+ assert(test_allocator<A>::alloc_count == 1);
+ assert(A::count == 1);
+ assert(p->get_int() == 67);
+ assert(p->get_char() == 'e');
+ }
+ assert(A::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+#if __cplusplus >= 201103L
+ {
+ int i = 67;
+ char c = 'e';
+ std::shared_ptr<A> p = std::allocate_shared<A>(min_allocator<void>(), i, c);
+ assert(A::count == 1);
+ assert(p->get_int() == 67);
+ assert(p->get_char() == 'e');
+ }
+ assert(A::count == 0);
+ {
+ int i = 68;
+ char c = 'f';
+ std::shared_ptr<A> p = std::allocate_shared<A>(bare_allocator<void>(), i, c);
+ assert(A::count == 1);
+ assert(p->get_int() == 68);
+ assert(p->get_char() == 'f');
+ }
+ assert(A::count == 0);
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp
new file mode 100644
index 0000000000000..8dcd50e494110
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class A, class... Args>
+// shared_ptr<T> allocate_shared(const A& a, Args&&... args);
+
+#define _LIBCPP_HAS_NO_VARIADICS
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+struct Zero
+{
+ static int count;
+ Zero() {++count;}
+ Zero(Zero const &) {++count;}
+ ~Zero() {--count;}
+};
+
+int Zero::count = 0;
+
+struct One
+{
+ static int count;
+ int value;
+ explicit One(int v) : value(v) {++count;}
+ One(One const & o) : value(o.value) {++count;}
+ ~One() {--count;}
+};
+
+int One::count = 0;
+
+
+struct Two
+{
+ static int count;
+ int value;
+ Two(int v, int) : value(v) {++count;}
+ Two(Two const & o) : value(o.value) {++count;}
+ ~Two() {--count;}
+};
+
+int Two::count = 0;
+
+struct Three
+{
+ static int count;
+ int value;
+ Three(int v, int, int) : value(v) {++count;}
+ Three(Three const & o) : value(o.value) {++count;}
+ ~Three() {--count;}
+};
+
+int Three::count = 0;
+
+template <class Alloc>
+void test()
+{
+ int const bad = -1;
+ {
+ std::shared_ptr<Zero> p = std::allocate_shared<Zero>(Alloc());
+ assert(Zero::count == 1);
+ }
+ assert(Zero::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<One> p = std::allocate_shared<One>(Alloc(), i);
+ assert(One::count == 1);
+ assert(p->value == i);
+ }
+ assert(One::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<Two> p = std::allocate_shared<Two>(Alloc(), i, bad);
+ assert(Two::count == 1);
+ assert(p->value == i);
+ }
+ assert(Two::count == 0);
+ {
+ int const i = 42;
+ std::shared_ptr<Three> p = std::allocate_shared<Three>(Alloc(), i, bad, bad);
+ assert(Three::count == 1);
+ assert(p->value == i);
+ }
+ assert(Three::count == 0);
+}
+
+int main()
+{
+ {
+ int i = 67;
+ int const bad = -1;
+ std::shared_ptr<Two> p = std::allocate_shared<Two>(test_allocator<Two>(54), i, bad);
+ assert(test_allocator<Two>::alloc_count == 1);
+ assert(Two::count == 1);
+ assert(p->value == 67);
+ }
+ assert(Two::count == 0);
+ assert(test_allocator<Two>::alloc_count == 0);
+
+ test<bare_allocator<void> >();
+#if __cplusplus >= 201103L
+ test<min_allocator<void> >();
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
new file mode 100644
index 0000000000000..8cb972b0c1a14
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
+
+#include <memory>
+#include <cassert>
+
+#include "count_new.hpp"
+
+struct A
+{
+ static int count;
+
+ A(int i, char c) : int_(i), char_(c) {++count;}
+ A(const A& a)
+ : int_(a.int_), char_(a.char_)
+ {++count;}
+ ~A() {--count;}
+
+ int get_int() const {return int_;}
+ char get_char() const {return char_;}
+private:
+ int int_;
+ char char_;
+};
+
+int A::count = 0;
+
+
+struct Foo
+{
+ Foo() = default;
+ virtual ~Foo() = default;
+};
+
+
+int main()
+{
+ int nc = globalMemCounter.outstanding_new;
+ {
+ int i = 67;
+ char c = 'e';
+ std::shared_ptr<A> p = std::make_shared<A>(i, c);
+ assert(globalMemCounter.checkOutstandingNewEq(nc+1));
+ assert(A::count == 1);
+ assert(p->get_int() == 67);
+ assert(p->get_char() == 'e');
+ }
+
+ { // https://llvm.org/bugs/show_bug.cgi?id=24137
+ std::shared_ptr<Foo> p1 = std::make_shared<Foo>();
+ assert(p1.get());
+ std::shared_ptr<const Foo> p2 = std::make_shared<const Foo>();
+ assert(p2.get());
+ }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ nc = globalMemCounter.outstanding_new;
+ {
+ char c = 'e';
+ std::shared_ptr<A> p = std::make_shared<A>(67, c);
+ assert(globalMemCounter.checkOutstandingNewEq(nc+1));
+ assert(A::count == 1);
+ assert(p->get_int() == 67);
+ assert(p->get_char() == 'e');
+ }
+#endif
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.pass.cpp
new file mode 100644
index 0000000000000..1045f9347b381
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.volatile.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
+
+#include <memory>
+#include <cassert>
+
+template <typename T>
+void test(const T &t0)
+{
+ {
+ T t1 = t0;
+ std::shared_ptr<T> p0 = std::make_shared<T>(t0);
+ std::shared_ptr<T> p1 = std::make_shared<T>(t1);
+ assert(*p0 == t0);
+ assert(*p1 == t1);
+ }
+
+ {
+ const T t1 = t0;
+ std::shared_ptr<const T> p0 = std::make_shared<const T>(t0);
+ std::shared_ptr<const T> p1 = std::make_shared<const T>(t1);
+ assert(*p0 == t0);
+ assert(*p1 == t1);
+ }
+
+ {
+ volatile T t1 = t0;
+ std::shared_ptr<volatile T> p0 = std::make_shared<volatile T>(t0);
+ std::shared_ptr<volatile T> p1 = std::make_shared<volatile T>(t1);
+ assert(*p0 == t0);
+ assert(*p1 == t1);
+ }
+
+ {
+ const volatile T t1 = t0;
+ std::shared_ptr<const volatile T> p0 = std::make_shared<const volatile T>(t0);
+ std::shared_ptr<const volatile T> p1 = std::make_shared<const volatile T>(t1);
+ assert(*p0 == t0);
+ assert(*p1 == t1);
+ }
+
+}
+
+int main()
+{
+ test<bool>(true);
+ test<int>(3);
+ test<double>(5.0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.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/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp
new file mode 100644
index 0000000000000..b627ac1ccbc93
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class CharT, class Traits, class Y>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os, shared_ptr<Y> const& p);
+
+#include <memory>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::shared_ptr<int> p(new int(3));
+ std::ostringstream os;
+ assert(os.str().empty());
+ os << p;
+ assert(!os.str().empty());
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp
new file mode 100644
index 0000000000000..7bffc06993fac
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// void reset();
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<B> p(new B);
+ p.reset();
+ assert(A::count == 0);
+ assert(B::count == 0);
+ assert(p.use_count() == 0);
+ assert(p.get() == 0);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<B> p;
+ p.reset();
+ assert(A::count == 0);
+ assert(B::count == 0);
+ assert(p.use_count() == 0);
+ assert(p.get() == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp
new file mode 100644
index 0000000000000..85a64d0f1b0ba
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> void reset(Y* p);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<B> p(new B);
+ A* ptr = new A;
+ p.reset(ptr);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<B> p;
+ A* ptr = new A;
+ p.reset(ptr);
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
new file mode 100644
index 0000000000000..33965dfeb33c0
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class Y, class D> void reset(Y* p, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<B> p(new B);
+ A* ptr = new A;
+ p.reset(ptr, test_deleter<A>(3));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ {
+ std::shared_ptr<B> p;
+ A* ptr = new A;
+ p.reset(ptr, test_deleter<A>(3));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(d);
+ assert(d->state() == 3);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 2);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
new file mode 100644
index 0000000000000..09070e2c059b0
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class Y, class D, class A> void reset(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<B> p(new B);
+ A* ptr = new A;
+ p.reset(ptr, test_deleter<A>(3), test_allocator<A>(4));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 0);
+ assert(d);
+ assert(d->state() == 3);
+ assert(test_allocator<A>::count == 1);
+ assert(test_allocator<A>::alloc_count == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+ {
+ std::shared_ptr<B> p;
+ A* ptr = new A;
+ p.reset(ptr, test_deleter<A>(3), test_allocator<A>(4));
+ assert(A::count == 1);
+ assert(B::count == 1);
+ assert(p.use_count() == 1);
+ assert(p.get() == ptr);
+ test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+ assert(test_deleter<A>::count == 1);
+ assert(test_deleter<A>::dealloc_count == 1);
+ assert(d);
+ assert(d->state() == 3);
+ assert(test_allocator<A>::count == 1);
+ assert(test_allocator<A>::alloc_count == 1);
+ }
+ assert(A::count == 0);
+ assert(test_deleter<A>::count == 0);
+ assert(test_deleter<A>::dealloc_count == 2);
+ assert(test_allocator<A>::count == 0);
+ assert(test_allocator<A>::alloc_count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp
new file mode 100644
index 0000000000000..6d28a5043ca0d
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// void swap(shared_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr1 = new A;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1(ptr1);
+ {
+ std::shared_ptr<A> p2(ptr2);
+ p1.swap(p2);
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 1);
+ assert(p2.get() == ptr1);
+ assert(A::count == 2);
+ }
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = new A;
+ A* ptr2 = 0;
+ std::shared_ptr<A> p1(ptr1);
+ {
+ std::shared_ptr<A> p2;
+ p1.swap(p2);
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 1);
+ assert(p2.get() == ptr1);
+ assert(A::count == 1);
+ }
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = 0;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1;
+ {
+ std::shared_ptr<A> p2(ptr2);
+ p1.swap(p2);
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 0);
+ assert(p2.get() == ptr1);
+ assert(A::count == 1);
+ }
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = 0;
+ A* ptr2 = 0;
+ std::shared_ptr<A> p1;
+ {
+ std::shared_ptr<A> p2;
+ p1.swap(p2);
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 0);
+ assert(p2.get() == ptr1);
+ assert(A::count == 0);
+ }
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp
new file mode 100644
index 0000000000000..00281687521fd
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// T* operator->() const;
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<std::pair<int, int> > p(new std::pair<int, int>(3, 4));
+ assert(p->first == 3);
+ assert(p->second == 4);
+ p->first = 5;
+ p->second = 6;
+ assert(p->first == 5);
+ assert(p->second == 6);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp
new file mode 100644
index 0000000000000..378cd0514ca25
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// T& operator*() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p(new int(32));
+ assert(*p == 32);
+ *p = 3;
+ assert(*p == 3);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp
new file mode 100644
index 0000000000000..1b79d497005a5
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// explicit operator bool() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ const std::shared_ptr<int> p(new int(32));
+ assert(p);
+ }
+ {
+ const std::shared_ptr<int> p;
+ assert(!p);
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp
new file mode 100644
index 0000000000000..3acd2f8c6f2d4
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class U> bool owner_before(shared_ptr<U> const& b) const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ assert(!p1.owner_before(p2));
+ assert(!p2.owner_before(p1));
+ assert(p1.owner_before(p3) || p3.owner_before(p1));
+ assert(p3.owner_before(p1) == p3.owner_before(p2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp
new file mode 100644
index 0000000000000..33447ba7da00f
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class U> bool owner_before(weak_ptr<U> const& b) const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+ const std::weak_ptr<int> w3(p3);
+ assert(!p1.owner_before(w2));
+ assert(!p2.owner_before(w1));
+ assert(p1.owner_before(w3) || p3.owner_before(w1));
+ assert(p3.owner_before(w1) == p3.owner_before(w2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp
new file mode 100644
index 0000000000000..50ff692f9d421
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// bool unique() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p(new int(32));
+ assert(p.unique());
+ {
+ std::shared_ptr<int> p2 = p;
+ assert(!p.unique());
+ }
+ assert(p.unique());
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp
new file mode 100644
index 0000000000000..b40e4705acfe3
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// shared_ptr
+
+// template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr1 = new A;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1(ptr1);
+ {
+ std::shared_ptr<A> p2(ptr2);
+ swap(p1, p2);
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 1);
+ assert(p2.get() == ptr1);
+ assert(A::count == 2);
+ }
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = new A;
+ A* ptr2 = 0;
+ std::shared_ptr<A> p1(ptr1);
+ {
+ std::shared_ptr<A> p2;
+ swap(p1, p2);
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 1);
+ assert(p2.get() == ptr1);
+ assert(A::count == 1);
+ }
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = 0;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1;
+ {
+ std::shared_ptr<A> p2(ptr2);
+ swap(p1, p2);
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 0);
+ assert(p2.get() == ptr1);
+ assert(A::count == 1);
+ }
+ assert(p1.use_count() == 1);
+ assert(p1.get() == ptr2);
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ A* ptr1 = 0;
+ A* ptr2 = 0;
+ std::shared_ptr<A> p1;
+ {
+ std::shared_ptr<A> p2;
+ swap(p1, p2);
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(p2.use_count() == 0);
+ assert(p2.get() == ptr1);
+ assert(A::count == 0);
+ }
+ assert(p1.use_count() == 0);
+ assert(p1.get() == ptr2);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp
new file mode 100644
index 0000000000000..45748d7db6fbf
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class weak_ptr
+// {
+// public:
+// typedef T element_type;
+// ...
+// };
+
+#include <memory>
+
+struct A; // purposefully incomplete
+
+int main()
+{
+ static_assert((std::is_same<std::weak_ptr<A>::element_type, A>::value), "");
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
new file mode 100644
index 0000000000000..d091ae99fc272
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class T> struct owner_less;
+//
+// template <class T>
+// struct owner_less<shared_ptr<T> >
+// : binary_function<shared_ptr<T>, shared_ptr<T>, bool>
+// {
+// typedef bool result_type;
+// bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const;
+// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
+// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
+// };
+//
+// template <class T>
+// struct owner_less<weak_ptr<T> >
+// : binary_function<weak_ptr<T>, weak_ptr<T>, bool>
+// {
+// typedef bool result_type;
+// bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const;
+// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
+// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+ const std::weak_ptr<int> w3(p3);
+
+ {
+ typedef std::owner_less<std::shared_ptr<int> > CS;
+ CS cs;
+
+ static_assert((std::is_same<std::shared_ptr<int>, CS::first_argument_type>::value), "" );
+ static_assert((std::is_same<std::shared_ptr<int>, CS::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, CS::result_type>::value), "" );
+
+ assert(!cs(p1, p2));
+ assert(!cs(p2, p1));
+ assert(cs(p1 ,p3) || cs(p3, p1));
+ assert(cs(p3, p1) == cs(p3, p2));
+
+ assert(!cs(p1, w2));
+ assert(!cs(p2, w1));
+ assert(cs(p1, w3) || cs(p3, w1));
+ assert(cs(p3, w1) == cs(p3, w2));
+ }
+ {
+ typedef std::owner_less<std::weak_ptr<int> > CS;
+ CS cs;
+
+ static_assert((std::is_same<std::weak_ptr<int>, CS::first_argument_type>::value), "" );
+ static_assert((std::is_same<std::weak_ptr<int>, CS::second_argument_type>::value), "" );
+ static_assert((std::is_same<bool, CS::result_type>::value), "" );
+
+ assert(!cs(w1, w2));
+ assert(!cs(w2, w1));
+ assert(cs(w1, w3) || cs(w3, w1));
+ assert(cs(w3, w1) == cs(w3, w2));
+
+ assert(!cs(w1, p2));
+ assert(!cs(w2, p1));
+ assert(cs(w1, p3) || cs(w3, p1));
+ assert(cs(w3, p1) == cs(w3, p2));
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000000000..6b32079c71b4b
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> pA(new A);
+ {
+ std::weak_ptr<B> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp
new file mode 100644
index 0000000000000..e5713f375215d
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// weak_ptr& operator=(const weak_ptr& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> ps(new A);
+ const std::weak_ptr<A> pA(ps);
+ {
+ std::weak_ptr<A> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+
+ {
+ const std::shared_ptr<A> ps(new A);
+ std::weak_ptr<A> pA(ps);
+ {
+ std::weak_ptr<A> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ }
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp
new file mode 100644
index 0000000000000..5a03d926f7d66
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// template<class Y> weak_ptr& operator=(const weak_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ const std::shared_ptr<A> ps(new A);
+ const std::weak_ptr<A> pA(ps);
+ {
+ std::weak_ptr<B> pB;
+ pB = pA;
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+
+ {
+ const std::shared_ptr<A> ps(new A);
+ std::weak_ptr<A> pA(ps);
+ {
+ std::weak_ptr<B> pB;
+ pB = std::move(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ }
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp
new file mode 100644
index 0000000000000..28358db6a446f
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class weak_ptr
+
+// weak_ptr();
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+ std::weak_ptr<A> p;
+ assert(p.use_count() == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000000000..d70adb940eb27
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// template<class Y> weak_ptr(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+ static_assert(( std::is_convertible<std::shared_ptr<A>, std::weak_ptr<B> >::value), "");
+ static_assert((!std::is_convertible<std::weak_ptr<B>, std::shared_ptr<A> >::value), "");
+ static_assert((!std::is_convertible<std::shared_ptr<A>, std::weak_ptr<C> >::value), "");
+ {
+ const std::shared_ptr<A> pA(new A);
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ {
+ std::weak_ptr<B> pB(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
new file mode 100644
index 0000000000000..75bf3df90aa36
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// weak_ptr(const weak_ptr& r);
+// weak_ptr(weak_ptr &&r)
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+template <class T>
+std::weak_ptr<T> source (std::shared_ptr<T> p) { return std::weak_ptr<T>(p); }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+template <class T>
+void sink (std::weak_ptr<T> &&) {}
+#endif
+
+int main()
+{
+ {
+ const std::shared_ptr<A> ps(new A);
+ const std::weak_ptr<A> pA(ps);
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ {
+ std::weak_ptr<A> pB(pA);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ assert(pB.use_count() == 1);
+ assert(pA.use_count() == 1);
+ }
+ assert(pA.use_count() == 1);
+ assert(B::count == 1);
+ assert(A::count == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<A> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::shared_ptr<A> ps(new A);
+ std::weak_ptr<A> pA = source(ps);
+ assert(pA.use_count() == 1);
+ assert(A::count == 1);
+ sink(std::move(pA)); // kill off the weak pointer
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+#endif
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp
new file mode 100644
index 0000000000000..51a8fa5ae81f1
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// template<class Y> weak_ptr(const weak_ptr<Y>& r);
+// template<class Y> weak_ptr(weak_ptr<Y> &&r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+ static int count;
+
+ B() {++count;}
+ B(const B&) {++count;}
+ virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+ : public B
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+ static int count;
+
+ C() {++count;}
+ C(const C&) {++count;}
+ virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+template <class T>
+std::weak_ptr<T> source (std::shared_ptr<T> p) { return std::weak_ptr<T>(p); }
+
+int main()
+{
+ static_assert(( std::is_convertible<std::weak_ptr<A>, std::weak_ptr<B> >::value), "");
+ static_assert((!std::is_convertible<std::weak_ptr<B>, std::weak_ptr<A> >::value), "");
+ static_assert((!std::is_convertible<std::weak_ptr<A>, std::weak_ptr<C> >::value), "");
+ {
+ const std::weak_ptr<A> pA(std::shared_ptr<A>(new A));
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<A> pA;
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ {
+ std::weak_ptr<B> pB(pA);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ assert(pB.use_count() == 0);
+ assert(pA.use_count() == 0);
+ }
+ assert(pA.use_count() == 0);
+ assert(B::count == 0);
+ assert(A::count == 0);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+
+ {
+ std::shared_ptr<A> ps(new A);
+ std::weak_ptr<A> pA = source(ps);
+ std::weak_ptr<B> pB(std::move(pA));
+ assert(pB.use_count() == 1);
+ }
+ assert(B::count == 0);
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.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/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp
new file mode 100644
index 0000000000000..fa496d4bda592
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// void swap(weak_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::shared_ptr<A> p1(new A);
+ std::weak_ptr<A> w1(p1);
+ assert(w1.use_count() == 1);
+ w1.reset();
+ assert(w1.use_count() == 0);
+ assert(p1.use_count() == 1);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp
new file mode 100644
index 0000000000000..4001efb737e42
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// void swap(weak_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr1 = new A;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1(ptr1);
+ std::weak_ptr<A> w1(p1);
+ {
+ std::shared_ptr<A> p2(ptr2);
+ std::weak_ptr<A> w2(p2);
+ w1.swap(w2);
+ assert(w1.use_count() == 1);
+ assert(w1.lock().get() == ptr2);
+ assert(w2.use_count() == 1);
+ assert(w2.lock().get() == ptr1);
+ assert(A::count == 2);
+ }
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp
new file mode 100644
index 0000000000000..d61ac51afc620
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// bool expired() const;
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::weak_ptr<A> wp;
+ assert(wp.use_count() == 0);
+ assert(wp.expired() == (wp.use_count() == 0));
+ }
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ assert(wp.use_count() == 1);
+ assert(wp.expired() == (wp.use_count() == 0));
+ sp0.reset();
+ assert(wp.use_count() == 0);
+ assert(wp.expired() == (wp.use_count() == 0));
+ }
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp
new file mode 100644
index 0000000000000..956884b5c5c44
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// shared_ptr<T> lock() const;
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ std::weak_ptr<A> wp;
+ std::shared_ptr<A> sp = wp.lock();
+ assert(sp.use_count() == 0);
+ assert(sp.get() == 0);
+ assert(A::count == 0);
+ }
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ std::shared_ptr<A> sp = wp.lock();
+ assert(sp.use_count() == 2);
+ assert(sp.get() == sp0.get());
+ assert(A::count == 1);
+ }
+ assert(A::count == 0);
+ {
+ std::shared_ptr<A> sp0(new A);
+ std::weak_ptr<A> wp(sp0);
+ sp0.reset();
+ std::shared_ptr<A> sp = wp.lock();
+ assert(sp.use_count() == 0);
+ assert(sp.get() == 0);
+ assert(A::count == 0);
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp
new file mode 100644
index 0000000000000..ccffc2a66fb57
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T> class weak_ptr;
+//
+// not less than comparable
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+
+ bool b = w1 < w2;
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp
new file mode 100644
index 0000000000000..4aa49cfe8a24d
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class U> bool owner_before(const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+ const std::weak_ptr<int> w3(p3);
+ assert(!w1.owner_before(p2));
+ assert(!w2.owner_before(p1));
+ assert(w1.owner_before(p3) || w3.owner_before(p1));
+ assert(w3.owner_before(p1) == w3.owner_before(p2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp
new file mode 100644
index 0000000000000..9fe2b6e390350
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class U> bool owner_before(const weak_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ const std::shared_ptr<int> p1(new int);
+ const std::shared_ptr<int> p2 = p1;
+ const std::shared_ptr<int> p3(new int);
+ const std::weak_ptr<int> w1(p1);
+ const std::weak_ptr<int> w2(p2);
+ const std::weak_ptr<int> w3(p3);
+ assert(!w1.owner_before(w2));
+ assert(!w2.owner_before(w1));
+ assert(w1.owner_before(w3) || w3.owner_before(w1));
+ assert(w3.owner_before(w1) == w3.owner_before(w2));
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp
new file mode 100644
index 0000000000000..e13d5aeaf6367
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// weak_ptr
+
+// template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b)
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+ static int count;
+
+ A() {++count;}
+ A(const A&) {++count;}
+ ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+ {
+ A* ptr1 = new A;
+ A* ptr2 = new A;
+ std::shared_ptr<A> p1(ptr1);
+ std::weak_ptr<A> w1(p1);
+ {
+ std::shared_ptr<A> p2(ptr2);
+ std::weak_ptr<A> w2(p2);
+ swap(w1, w2);
+ assert(w1.use_count() == 1);
+ assert(w1.lock().get() == ptr2);
+ assert(w2.use_count() == 1);
+ assert(w2.lock().get() == ptr1);
+ assert(A::count == 2);
+ }
+ }
+ assert(A::count == 0);
+}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp
new file mode 100644
index 0000000000000..cb895cd2bbf30
--- /dev/null
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// class bad_weak_ptr
+// : public std::exception
+// {
+// public:
+// bad_weak_ptr();
+// };
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+#include <cstring>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_weak_ptr>::value), "");
+ std::bad_weak_ptr e;
+ std::bad_weak_ptr e2 = e;
+ e2 = e;
+ assert(std::strcmp(e.what(), "bad_weak_ptr") == 0);
+}
diff --git a/test/std/utilities/memory/version.pass.cpp b/test/std/utilities/memory/version.pass.cpp
new file mode 100644
index 0000000000000..790c08a3bd2d9
--- /dev/null
+++ b/test/std/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()
+{
+}