From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../requirements/explicit_instantiation.cc | 31 +++ .../20_util/add_lvalue_reference/value.cc | 49 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../20_util/add_rvalue_reference/value.cc | 47 +++++ libstdc++-v3/testsuite/20_util/addressof/1.cc | 51 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../requirements/explicit_instantiation.cc | 32 +++ .../testsuite/20_util/aligned_storage/value.cc | 67 +++++++ libstdc++-v3/testsuite/20_util/allocator/1.cc | 65 ++++++ libstdc++-v3/testsuite/20_util/allocator/10378.cc | 45 +++++ libstdc++-v3/testsuite/20_util/allocator/14176.cc | 36 ++++ libstdc++-v3/testsuite/20_util/allocator/33807.cc | 32 +++ libstdc++-v3/testsuite/20_util/allocator/51626.cc | 66 +++++++ libstdc++-v3/testsuite/20_util/allocator/8230.cc | 53 +++++ .../requirements/explicit_instantiation/1.cc | 25 +++ libstdc++-v3/testsuite/20_util/auto_ptr/1.cc | 94 +++++++++ libstdc++-v3/testsuite/20_util/auto_ptr/2.cc | 84 ++++++++ libstdc++-v3/testsuite/20_util/auto_ptr/3.cc | 86 ++++++++ libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc | 44 +++++ libstdc++-v3/testsuite/20_util/auto_ptr/4.cc | 82 ++++++++ libstdc++-v3/testsuite/20_util/auto_ptr/5.cc | 86 ++++++++ libstdc++-v3/testsuite/20_util/auto_ptr/6.cc | 90 +++++++++ libstdc++-v3/testsuite/20_util/auto_ptr/7.cc | 90 +++++++++ .../testsuite/20_util/auto_ptr/assign_neg.cc | 52 +++++ .../requirements/explicit_instantiation/1.cc | 25 +++ .../bad_function_call/cons_virtual_derivation.cc | 29 +++ libstdc++-v3/testsuite/20_util/bind/35569.cc | 32 +++ libstdc++-v3/testsuite/20_util/bind/38889.cc | 31 +++ libstdc++-v3/testsuite/20_util/bind/42593.cc | 31 +++ libstdc++-v3/testsuite/20_util/bind/45924.cc | 45 +++++ libstdc++-v3/testsuite/20_util/bind/49058_1.cc | 34 ++++ libstdc++-v3/testsuite/20_util/bind/49058_2.cc | 28 +++ libstdc++-v3/testsuite/20_util/bind/all_bound.cc | 39 ++++ libstdc++-v3/testsuite/20_util/bind/conv_result.cc | 49 +++++ libstdc++-v3/testsuite/20_util/bind/cv_quals.cc | 119 +++++++++++ libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc | 49 +++++ libstdc++-v3/testsuite/20_util/bind/move.cc | 58 ++++++ libstdc++-v3/testsuite/20_util/bind/nested.cc | 42 ++++ .../testsuite/20_util/bind/placeholders.cc | 40 ++++ libstdc++-v3/testsuite/20_util/bind/ref.cc | 55 ++++++ libstdc++-v3/testsuite/20_util/bind/ref2.cc | 63 ++++++ libstdc++-v3/testsuite/20_util/bind/ref_neg.cc | 59 ++++++ .../requirements/explicit_instantiation.cc | 41 ++++ .../20_util/common_type/requirements/typedefs-1.cc | 117 +++++++++++ .../20_util/common_type/requirements/typedefs-2.cc | 72 +++++++ .../requirements/explicit_instantiation.cc | 32 +++ .../20_util/conditional/requirements/typedefs.cc | 41 ++++ .../decay/requirements/explicit_instantiation.cc | 32 +++ .../20_util/decay/requirements/typedefs.cc | 52 +++++ .../testsuite/20_util/declval/requirements/1.cc | 49 +++++ .../20_util/declval/requirements/1_neg.cc | 29 +++ .../testsuite/20_util/default_delete/48631_neg.cc | 30 +++ .../20_util/default_delete/cons/constexpr.cc | 29 +++ .../testsuite/20_util/duration/arithmetic/1.cc | 93 +++++++++ .../testsuite/20_util/duration/arithmetic/2.cc | 61 ++++++ .../20_util/duration/arithmetic/dr934-1.cc | 48 +++++ .../20_util/duration/arithmetic/dr934-2.cc | 54 +++++ .../20_util/duration/comparison_operators/1.cc | 55 ++++++ .../duration/comparison_operators/constexpr.cc | 29 +++ libstdc++-v3/testsuite/20_util/duration/cons/1.cc | 134 +++++++++++++ .../testsuite/20_util/duration/cons/1_neg.cc | 41 ++++ libstdc++-v3/testsuite/20_util/duration/cons/2.cc | 119 +++++++++++ .../testsuite/20_util/duration/cons/constexpr.cc | 34 ++++ .../testsuite/20_util/duration/cons/dr974_neg.cc | 33 ++++ .../duration/requirements/constexpr_functions.cc | 64 ++++++ .../explicit_instantiation.cc | 26 +++ .../20_util/duration/requirements/typedefs_neg1.cc | 35 ++++ .../20_util/duration/requirements/typedefs_neg2.cc | 37 ++++ .../20_util/duration/requirements/typedefs_neg3.cc | 37 ++++ .../testsuite/20_util/duration_cast/constexpr.cc | 37 ++++ .../requirements/explicit_instantiation.cc | 32 +++ .../20_util/enable_if/requirements/typedefs.cc | 32 +++ .../20_util/enable_if/requirements/typedefs_neg.cc | 35 ++++ .../enable_shared_from_this/cons/constexpr.cc | 36 ++++ .../requirements/explicit_instantiation.cc | 23 +++ libstdc++-v3/testsuite/20_util/forward/1.cc | 43 ++++ libstdc++-v3/testsuite/20_util/forward/1_neg.cc | 44 +++++ libstdc++-v3/testsuite/20_util/forward/a.cc | 77 ++++++++ libstdc++-v3/testsuite/20_util/forward/b.cc | 77 ++++++++ libstdc++-v3/testsuite/20_util/forward/c_neg.cc | 78 ++++++++ libstdc++-v3/testsuite/20_util/forward/d.cc | 78 ++++++++ libstdc++-v3/testsuite/20_util/forward/e.cc | 54 +++++ libstdc++-v3/testsuite/20_util/forward/f_neg.cc | 90 +++++++++ .../forward/requirements/explicit_instantiation.cc | 32 +++ libstdc++-v3/testsuite/20_util/function/1.cc | 94 +++++++++ libstdc++-v3/testsuite/20_util/function/2.cc | 78 ++++++++ libstdc++-v3/testsuite/20_util/function/3.cc | 78 ++++++++ libstdc++-v3/testsuite/20_util/function/4.cc | 82 ++++++++ libstdc++-v3/testsuite/20_util/function/43397.cc | 78 ++++++++ libstdc++-v3/testsuite/20_util/function/48541.cc | 40 ++++ libstdc++-v3/testsuite/20_util/function/5.cc | 107 ++++++++++ libstdc++-v3/testsuite/20_util/function/6.cc | 82 ++++++++ libstdc++-v3/testsuite/20_util/function/7.cc | 82 ++++++++ libstdc++-v3/testsuite/20_util/function/8.cc | 148 ++++++++++++++ libstdc++-v3/testsuite/20_util/function/9.cc | 55 ++++++ .../testsuite/20_util/function/assign/move.cc | 50 +++++ .../20_util/function/assign/move_target.cc | 47 +++++ .../testsuite/20_util/function/cmp/cmp_neg.cc | 32 +++ .../testsuite/20_util/function/cons/move.cc | 48 +++++ .../testsuite/20_util/function/cons/move_target.cc | 46 +++++ .../testsuite/20_util/function/invoke/move_only.cc | 61 ++++++ .../20_util/function/null_pointer_comparisons.cc | 44 +++++ .../requirements/explicit_instantiation.cc | 26 +++ .../20_util/function_objects/binders/1.cc | 103 ++++++++++ .../20_util/function_objects/binders/3113.cc | 49 +++++ .../20_util/function_objects/comparisons.cc | 52 +++++ .../testsuite/20_util/function_objects/dr660.cc | 41 ++++ .../requirements/explicit_instantiation.cc | 30 +++ .../requirements/typedefs.cc | 36 ++++ .../20_util/has_nothrow_copy_assign/value.cc | 57 ++++++ .../requirements/explicit_instantiation.cc | 31 +++ .../requirements/typedefs.cc | 36 ++++ .../20_util/has_nothrow_copy_constructor/value.cc | 56 ++++++ .../requirements/explicit_instantiation.cc | 31 +++ .../requirements/typedefs.cc | 36 ++++ .../has_nothrow_default_constructor/value.cc | 61 ++++++ .../requirements/explicit_instantiation.cc | 30 +++ .../requirements/typedefs.cc | 36 ++++ .../20_util/has_trivial_copy_assign/value.cc | 57 ++++++ .../requirements/explicit_instantiation.cc | 31 +++ .../requirements/typedefs.cc | 36 ++++ .../20_util/has_trivial_copy_constructor/value.cc | 58 ++++++ .../requirements/explicit_instantiation.cc | 31 +++ .../requirements/typedefs.cc | 36 ++++ .../has_trivial_default_constructor/value.cc | 61 ++++++ .../testsuite/20_util/hash/chi2_quality.cc | 218 +++++++++++++++++++++ .../testsuite/20_util/hash/operators/size_t.cc | 54 +++++ libstdc++-v3/testsuite/20_util/hash/quality.cc | 172 ++++++++++++++++ .../hash/requirements/explicit_instantiation.cc | 49 +++++ .../20_util/headers/cstdlib/functions_std.cc | 28 +++ .../20_util/headers/cstring/functions_std.cc | 29 +++ .../testsuite/20_util/headers/cstring/macros.cc | 27 +++ .../testsuite/20_util/headers/cstring/types_std.cc | 25 +++ .../20_util/headers/ctime/functions_std.cc | 33 ++++ .../testsuite/20_util/headers/ctime/macros.cc | 27 +++ .../testsuite/20_util/headers/ctime/types_std.cc | 29 +++ .../20_util/headers/functional/synopsis.cc | 100 ++++++++++ .../20_util/headers/functional/types_std_c++0x.cc | 26 +++ .../functional/using_namespace_std_placeholders.cc | 26 +++ .../testsuite/20_util/headers/memory/synopsis.cc | 53 +++++ .../20_util/headers/memory/types_std_c++0x.cc | 26 +++ .../20_util/headers/type_traits/std_c++0x_neg.cc | 26 +++ .../20_util/headers/type_traits/types_std_c++0x.cc | 27 +++ .../headers/type_traits/types_std_c++0x_neg.cc | 36 ++++ .../testsuite/20_util/headers/utility/synopsis.cc | 45 +++++ .../headers/utility/using_namespace_std_rel_ops.cc | 25 +++ .../requirements/explicit_instantiation.cc | 31 +++ .../is_constructible/requirements/typedefs.cc | 36 ++++ .../testsuite/20_util/is_constructible/value.cc | 45 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../is_convertible/requirements/typedefs.cc | 36 ++++ .../testsuite/20_util/is_convertible/value.cc | 106 ++++++++++ .../requirements/explicit_instantiation.cc | 31 +++ .../requirements/typedefs.cc | 36 ++++ .../20_util/is_explicitly_convertible/value.cc | 45 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../20_util/is_integral/requirements/typedefs.cc | 36 ++++ .../testsuite/20_util/is_integral/value.cc | 62 ++++++ .../requirements/explicit_instantiation.cc | 30 +++ .../is_literal_type/requirements/typedefs.cc | 36 ++++ .../testsuite/20_util/is_literal_type/value.cc | 54 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../is_lvalue_reference/requirements/typedefs.cc | 36 ++++ .../testsuite/20_util/is_lvalue_reference/value.cc | 44 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../requirements/typedefs.cc | 36 ++++ .../20_util/is_nothrow_constructible/value.cc | 78 ++++++++ .../is_pod/requirements/explicit_instantiation.cc | 30 +++ .../20_util/is_pod/requirements/typedefs.cc | 36 ++++ libstdc++-v3/testsuite/20_util/is_pod/value.cc | 58 ++++++ .../requirements/explicit_instantiation.cc | 31 +++ .../20_util/is_reference/requirements/typedefs.cc | 36 ++++ .../testsuite/20_util/is_reference/value.cc | 46 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../is_rvalue_reference/requirements/typedefs.cc | 36 ++++ .../testsuite/20_util/is_rvalue_reference/value.cc | 44 +++++ .../requirements/explicit_instantiation.cc | 29 +++ .../20_util/is_scalar/requirements/typedefs.cc | 36 ++++ libstdc++-v3/testsuite/20_util/is_scalar/value.cc | 48 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../20_util/is_signed/requirements/typedefs.cc | 36 ++++ libstdc++-v3/testsuite/20_util/is_signed/value.cc | 60 ++++++ .../requiremenents/explicit_instantiation.cc | 30 +++ .../is_standard_layout/requiremenents/typedefs.cc | 36 ++++ .../testsuite/20_util/is_standard_layout/value.cc | 42 ++++ .../requirements/explicit_instantiation.cc | 30 +++ .../20_util/is_trivial/requirements/typedefs.cc | 36 ++++ libstdc++-v3/testsuite/20_util/is_trivial/value.cc | 42 ++++ .../requirements/explicit_instantiation.cc | 31 +++ .../20_util/is_unsigned/requirements/typedefs.cc | 36 ++++ .../testsuite/20_util/is_unsigned/value.cc | 60 ++++++ .../requirements/explicit_instantiation.cc | 31 +++ .../20_util/make_signed/requirements/typedefs-1.cc | 65 ++++++ .../20_util/make_signed/requirements/typedefs-2.cc | 64 ++++++ .../make_signed/requirements/typedefs_neg.cc | 52 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../make_unsigned/requirements/typedefs-1.cc | 66 +++++++ .../make_unsigned/requirements/typedefs-2.cc | 64 ++++++ .../make_unsigned/requirements/typedefs_neg.cc | 52 +++++ .../20_util/monotonic_clock/constexpr_data.cc | 52 +++++ libstdc++-v3/testsuite/20_util/move/1.cc | 45 +++++ .../move/requirements/explicit_instantiation.cc | 32 +++ libstdc++-v3/testsuite/20_util/owner_less/cmp.cc | 135 +++++++++++++ libstdc++-v3/testsuite/20_util/pair/1.cc | 78 ++++++++ libstdc++-v3/testsuite/20_util/pair/2.cc | 59 ++++++ libstdc++-v3/testsuite/20_util/pair/3.cc | 78 ++++++++ libstdc++-v3/testsuite/20_util/pair/4.cc | 66 +++++++ libstdc++-v3/testsuite/20_util/pair/40925.cc | 67 +++++++ libstdc++-v3/testsuite/20_util/pair/44487.cc | 51 +++++ .../20_util/pair/comparison_operators/constexpr.cc | 29 +++ .../testsuite/20_util/pair/cons/constexpr.cc | 39 ++++ libstdc++-v3/testsuite/20_util/pair/moveable.cc | 63 ++++++ libstdc++-v3/testsuite/20_util/pair/piecewise.cc | 98 +++++++++ .../testsuite/20_util/pair/requirements/dr801.cc | 52 +++++ .../pair/requirements/explicit_instantiation/1.cc | 25 +++ libstdc++-v3/testsuite/20_util/pair/swap.cc | 50 +++++ .../testsuite/20_util/ratio/comparisons/comp1.cc | 86 ++++++++ .../testsuite/20_util/ratio/comparisons/comp2.cc | 60 ++++++ .../testsuite/20_util/ratio/comparisons/comp3.cc | 75 +++++++ libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc | 51 +++++ .../20_util/ratio/cons/cons_overflow_neg.cc | 54 +++++ .../testsuite/20_util/ratio/operations/45866.cc | 67 +++++++ .../testsuite/20_util/ratio/operations/47913.cc | 42 ++++ .../testsuite/20_util/ratio/operations/ops1.cc | 74 +++++++ .../testsuite/20_util/ratio/operations/ops2.cc | 72 +++++++ .../testsuite/20_util/ratio/operations/ops3.cc | 71 +++++++ .../20_util/ratio/operations/ops_overflow_neg.cc | 47 +++++ .../20_util/ratio/requirements/constexpr_data.cc | 60 ++++++ .../requirements/base_classes.cc | 36 ++++ .../requirements/explicit_instantiation/1.cc | 25 +++ .../raw_storage_iterator/requirements/typedefs.cc | 37 ++++ .../testsuite/20_util/reference_wrapper/24803.cc | 80 ++++++++ .../testsuite/20_util/reference_wrapper/41792.cc | 34 ++++ .../20_util/reference_wrapper/invoke-2.cc | 46 +++++ .../testsuite/20_util/reference_wrapper/invoke.cc | 120 ++++++++++++ .../testsuite/20_util/reference_wrapper/ref_neg.cc | 44 +++++ .../20_util/reference_wrapper/result_type.cc | 42 ++++ .../20_util/reference_wrapper/typedefs-2.cc | 69 +++++++ .../20_util/reference_wrapper/typedefs-3.cc | 148 ++++++++++++++ .../20_util/reference_wrapper/typedefs.cc | 59 ++++++ libstdc++-v3/testsuite/20_util/rel_ops.cc | 45 +++++ .../requirements/explicit_instantiation.cc | 31 +++ .../testsuite/20_util/remove_reference/value.cc | 52 +++++ .../testsuite/20_util/shared_ptr/assign/assign.cc | 72 +++++++ .../20_util/shared_ptr/assign/auto_ptr.cc | 85 ++++++++ .../20_util/shared_ptr/assign/auto_ptr_neg.cc | 50 +++++ .../20_util/shared_ptr/assign/auto_ptr_rvalue.cc | 61 ++++++ .../testsuite/20_util/shared_ptr/assign/dr541.cc | 30 +++ .../testsuite/20_util/shared_ptr/assign/move.cc | 118 +++++++++++ .../20_util/shared_ptr/assign/shared_ptr.cc | 96 +++++++++ .../20_util/shared_ptr/assign/shared_ptr_neg.cc | 52 +++++ .../shared_ptr/assign/unique_ptr_lvalue_neg.cc | 49 +++++ .../20_util/shared_ptr/assign/unique_ptr_rvalue.cc | 61 ++++++ .../testsuite/20_util/shared_ptr/casts/1.cc | 45 +++++ .../20_util/shared_ptr/comparison/42925.cc | 37 ++++ .../testsuite/20_util/shared_ptr/comparison/cmp.cc | 88 +++++++++ .../20_util/shared_ptr/comparison/less.cc | 102 ++++++++++ .../testsuite/20_util/shared_ptr/cons/39405.cc | 30 +++ .../testsuite/20_util/shared_ptr/cons/43820_neg.cc | 40 ++++ .../testsuite/20_util/shared_ptr/cons/46910.cc | 46 +++++ .../testsuite/20_util/shared_ptr/cons/alias.cc | 107 ++++++++++ .../testsuite/20_util/shared_ptr/cons/alloc.cc | 103 ++++++++++ .../testsuite/20_util/shared_ptr/cons/auto_ptr.cc | 49 +++++ .../20_util/shared_ptr/cons/auto_ptr_neg.cc | 36 ++++ .../testsuite/20_util/shared_ptr/cons/constexpr.cc | 35 ++++ .../testsuite/20_util/shared_ptr/cons/copy.cc | 136 +++++++++++++ .../testsuite/20_util/shared_ptr/cons/default.cc | 46 +++++ .../testsuite/20_util/shared_ptr/cons/move.cc | 164 ++++++++++++++++ .../testsuite/20_util/shared_ptr/cons/nullptr.cc | 93 +++++++++ .../testsuite/20_util/shared_ptr/cons/pointer.cc | 80 ++++++++ .../20_util/shared_ptr/cons/unique_ptr.cc | 49 +++++ .../20_util/shared_ptr/cons/unique_ptr_deleter.cc | 59 ++++++ .../shared_ptr/cons/unique_ptr_deleter_ref_1.cc | 60 ++++++ .../shared_ptr/cons/unique_ptr_deleter_ref_2.cc | 63 ++++++ .../20_util/shared_ptr/cons/unique_ptr_neg.cc | 48 +++++ .../testsuite/20_util/shared_ptr/cons/weak_ptr.cc | 51 +++++ .../20_util/shared_ptr/cons/weak_ptr_expired.cc | 62 ++++++ .../testsuite/20_util/shared_ptr/creation/36949.cc | 34 ++++ .../testsuite/20_util/shared_ptr/creation/alloc.cc | 110 +++++++++++ .../testsuite/20_util/shared_ptr/creation/dr402.cc | 48 +++++ .../testsuite/20_util/shared_ptr/creation/dr925.cc | 90 +++++++++ .../testsuite/20_util/shared_ptr/creation/make.cc | 97 +++++++++ .../testsuite/20_util/shared_ptr/dest/dest.cc | 134 +++++++++++++ .../testsuite/20_util/shared_ptr/hash/1.cc | 48 +++++ .../testsuite/20_util/shared_ptr/misc/24595.cc | 40 ++++ .../testsuite/20_util/shared_ptr/misc/42019.cc | 56 ++++++ .../testsuite/20_util/shared_ptr/misc/io.cc | 52 +++++ .../testsuite/20_util/shared_ptr/misc/swap.cc | 51 +++++ .../20_util/shared_ptr/modifiers/24805.cc | 30 +++ .../20_util/shared_ptr/modifiers/reset.cc | 89 +++++++++ .../20_util/shared_ptr/modifiers/reset_alloc.cc | 63 ++++++ .../20_util/shared_ptr/modifiers/reset_neg.cc | 47 +++++ .../testsuite/20_util/shared_ptr/modifiers/swap.cc | 51 +++++ .../20_util/shared_ptr/modifiers/swap_neg.cc | 48 +++++ .../20_util/shared_ptr/observers/bool_conv.cc | 75 +++++++ .../testsuite/20_util/shared_ptr/observers/get.cc | 73 +++++++ .../20_util/shared_ptr/observers/owner_before.cc | 94 +++++++++ .../20_util/shared_ptr/observers/unique.cc | 75 +++++++ .../20_util/shared_ptr/observers/use_count.cc | 74 +++++++ .../requirements/explicit_instantiation/1.cc | 31 +++ .../requirements/explicit_instantiation/2.cc | 34 ++++ .../shared_ptr/thread/default_weaktoshared.cc | 197 +++++++++++++++++++ .../shared_ptr/thread/mutex_weaktoshared.cc | 199 +++++++++++++++++++ .../uninitialized_copy/move_iterators/1.cc | 65 ++++++ .../uninitialized_copy_n/move_iterators/1.cc | 66 +++++++ .../uninitialized_fill/32158.cc | 34 ++++ .../uninitialized_fill_n/16505.cc | 30 +++ libstdc++-v3/testsuite/20_util/system_clock/1.cc | 39 ++++ .../20_util/system_clock/constexpr_data.cc | 52 +++++ libstdc++-v3/testsuite/20_util/temporary_buffer.cc | 50 +++++ libstdc++-v3/testsuite/20_util/time_point/1.cc | 48 +++++ libstdc++-v3/testsuite/20_util/time_point/2.cc | 71 +++++++ libstdc++-v3/testsuite/20_util/time_point/3.cc | 52 +++++ .../time_point/comparison_operators/constexpr.cc | 30 +++ .../testsuite/20_util/time_point/cons/constexpr.cc | 37 ++++ .../time_point/requirements/constexpr_functions.cc | 59 ++++++ .../explicit_instantiation.cc | 24 +++ .../testsuite/20_util/time_point_cast/constexpr.cc | 39 ++++ libstdc++-v3/testsuite/20_util/tuple/48476.cc | 51 +++++ .../tuple/comparison_operators/35480_neg.cc | 33 ++++ .../tuple/comparison_operators/comparisons.cc | 49 +++++ libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc | 34 ++++ libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc | 51 +++++ libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc | 43 ++++ libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc | 27 +++ .../testsuite/20_util/tuple/cons/assignment.cc | 52 +++++ .../testsuite/20_util/tuple/cons/big_tuples.cc | 105 ++++++++++ .../testsuite/20_util/tuple/cons/constexpr.cc | 47 +++++ .../testsuite/20_util/tuple/cons/constructor.cc | 65 ++++++ .../testsuite/20_util/tuple/cons/converting.cc | 37 ++++ .../20_util/tuple/creation_functions/23978.cc | 45 +++++ .../20_util/tuple/creation_functions/48476.cc | 85 ++++++++ .../tuple/creation_functions/forward_as_tuple.cc | 72 +++++++ .../20_util/tuple/creation_functions/make_tuple.cc | 37 ++++ .../20_util/tuple/creation_functions/tie.cc | 42 ++++ .../20_util/tuple/creation_functions/tie2.cc | 38 ++++ .../testsuite/20_util/tuple/element_access/get.cc | 44 +++++ libstdc++-v3/testsuite/20_util/tuple/moveable.cc | 42 ++++ libstdc++-v3/testsuite/20_util/tuple/moveable2.cc | 64 ++++++ .../testsuite/20_util/tuple/requirements/dr801.cc | 52 +++++ .../tuple/requirements/explicit_instantiation.cc | 24 +++ libstdc++-v3/testsuite/20_util/tuple/swap.cc | 111 +++++++++++ .../testsuite/20_util/tuple/tuple_element.cc | 37 ++++ libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc | 38 ++++ .../20_util/typeindex/comparison_operators.cc | 88 +++++++++ libstdc++-v3/testsuite/20_util/typeindex/hash.cc | 60 ++++++ .../testsuite/20_util/typeindex/hash_code.cc | 67 +++++++ libstdc++-v3/testsuite/20_util/typeindex/name.cc | 67 +++++++ .../testsuite/20_util/unique_ptr/assign/48635.cc | 78 ++++++++ .../20_util/unique_ptr/assign/48635_neg.cc | 50 +++++ .../20_util/unique_ptr/assign/assign_neg.cc | 53 +++++ .../testsuite/20_util/unique_ptr/assign/move.cc | 52 +++++ .../20_util/unique_ptr/assign/move_array.cc | 46 +++++ .../testsuite/20_util/unique_ptr/assign/nullptr.cc | 54 +++++ .../20_util/unique_ptr/comparison/42925.cc | 37 ++++ .../testsuite/20_util/unique_ptr/cons/auto_ptr.cc | 46 +++++ .../20_util/unique_ptr/cons/auto_ptr_neg.cc | 36 ++++ .../testsuite/20_util/unique_ptr/cons/constexpr.cc | 35 ++++ .../testsuite/20_util/unique_ptr/cons/nullptr.cc | 52 +++++ .../testsuite/20_util/unique_ptr/cons/pointer.cc | 117 +++++++++++ .../20_util/unique_ptr/cons/pointer_array.cc | 85 ++++++++ .../cons/pointer_array_convertible_neg.cc | 41 ++++ .../20_util/unique_ptr/cons/ptr_deleter.cc | 68 +++++++ .../20_util/unique_ptr/cons/ptr_deleter_neg.cc | 57 ++++++ .../testsuite/20_util/unique_ptr/hash/1.cc | 48 +++++ .../20_util/unique_ptr/modifiers/43183.cc | 55 ++++++ .../20_util/unique_ptr/modifiers/48398.cc | 41 ++++ .../20_util/unique_ptr/modifiers/reset_neg.cc | 38 ++++ .../explicit_instantiation.cc | 24 +++ .../unique_ptr/requirements/pointer_type.cc | 50 +++++ .../specialized_algorithms/comparisons.cc | 68 +++++++ .../specialized_algorithms/comparisons_array.cc | 68 +++++++ .../unique_ptr/specialized_algorithms/swap.cc | 47 +++++ .../requirements/explicit_instantiation.cc | 29 +++ .../uses_allocator/requirements/typedefs.cc | 33 ++++ .../testsuite/20_util/uses_allocator/value.cc | 59 ++++++ .../20_util/weak_ptr/comparison/cmp_neg.cc | 53 +++++ .../testsuite/20_util/weak_ptr/cons/constexpr.cc | 30 +++ libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc | 36 ++++ .../20_util/weak_ptr/observers/owner_before.cc | 77 ++++++++ .../requirements/explicit_instantiation/1.cc | 31 +++ .../requirements/explicit_instantiation/2.cc | 35 ++++ 382 files changed, 20922 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/addressof/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/aligned_storage/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/allocator/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/allocator/10378.cc create mode 100644 libstdc++-v3/testsuite/20_util/allocator/14176.cc create mode 100644 libstdc++-v3/testsuite/20_util/allocator/33807.cc create mode 100644 libstdc++-v3/testsuite/20_util/allocator/51626.cc create mode 100644 libstdc++-v3/testsuite/20_util/allocator/8230.cc create mode 100644 libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/2.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/3.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/4.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/5.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/6.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/7.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/35569.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/38889.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/42593.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/45924.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/49058_1.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/49058_2.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/all_bound.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/conv_result.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/cv_quals.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/move.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/nested.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/placeholders.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/ref.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/ref2.cc create mode 100644 libstdc++-v3/testsuite/20_util/bind/ref_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc create mode 100644 libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/declval/requirements/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-1.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/cons/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/cons/2.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/cons/dr974_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/requirements/constexpr_functions.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc create mode 100644 libstdc++-v3/testsuite/20_util/duration_cast/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/1_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/a.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/b.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/c_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/d.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/e.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/f_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/2.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/3.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/4.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/43397.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/48541.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/5.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/6.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/7.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/8.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/9.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/assign/move.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/assign/move_target.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/cmp/cmp_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/cons/move.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/cons/move_target.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/invoke/move_only.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc create mode 100644 libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc create mode 100644 libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc create mode 100644 libstdc++-v3/testsuite/20_util/function_objects/dr660.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/hash/chi2_quality.cc create mode 100644 libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc create mode 100644 libstdc++-v3/testsuite/20_util/hash/quality.cc create mode 100644 libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_constructible/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_constructible/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_constructible/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_convertible/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_explicitly_convertible/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_explicitly_convertible/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_explicitly_convertible/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_integral/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_literal_type/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_pod/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_reference/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_scalar/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_signed/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_trivial/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_trivial/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_unsigned/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc create mode 100644 libstdc++-v3/testsuite/20_util/move/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/owner_less/cmp.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/2.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/3.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/4.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/40925.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/44487.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/moveable.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/piecewise.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/swap.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/comparisons/comp3.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/operations/45866.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/operations/47913.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/ratio/requirements/constexpr_data.cc create mode 100644 libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc create mode 100644 libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/rel_ops.cc create mode 100644 libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/remove_reference/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/nullptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/hash/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/misc/42019.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc create mode 100644 libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc create mode 100644 libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc create mode 100644 libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc create mode 100644 libstdc++-v3/testsuite/20_util/system_clock/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc create mode 100644 libstdc++-v3/testsuite/20_util/temporary_buffer.cc create mode 100644 libstdc++-v3/testsuite/20_util/time_point/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/time_point/2.cc create mode 100644 libstdc++-v3/testsuite/20_util/time_point/3.cc create mode 100644 libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/time_point/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/time_point/requirements/constexpr_functions.cc create mode 100644 libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/time_point_cast/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/48476.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/moveable.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/moveable2.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/swap.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc create mode 100644 libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc create mode 100644 libstdc++-v3/testsuite/20_util/typeindex/comparison_operators.cc create mode 100644 libstdc++-v3/testsuite/20_util/typeindex/hash.cc create mode 100644 libstdc++-v3/testsuite/20_util/typeindex/hash_code.cc create mode 100644 libstdc++-v3/testsuite/20_util/typeindex/name.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc create mode 100644 libstdc++-v3/testsuite/20_util/uses_allocator/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/uses_allocator/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/uses_allocator/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc create mode 100644 libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc (limited to 'libstdc++-v3/testsuite/20_util') diff --git a/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..aa1dc3759 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct add_lvalue_reference; +} diff --git a/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc b/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc new file mode 100644 index 000000000..189f4457b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::add_lvalue_reference; + using std::is_same; + using namespace __gnu_test; + + VERIFY( (is_same::type, int&>::value) ); + VERIFY( (is_same::type, int&>::value) ); + VERIFY( (is_same::type, const int&>::value) ); + VERIFY( (is_same::type, int*&>::value) ); + VERIFY( (is_same::type, ClassType&>::value) ); + VERIFY( (is_same::type, ClassType&>::value) ); + VERIFY( (is_same::type, int(&)(int)>::value) ); + VERIFY( (is_same::type, int&>::value) ); + VERIFY( (is_same::type, ClassType&>::value) ); + VERIFY( (is_same::type, void>::value) ); + VERIFY( (is_same::type, const void>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..c99902816 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct add_rvalue_reference; +} diff --git a/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc b/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc new file mode 100644 index 000000000..397178cfe --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::add_rvalue_reference; + using std::is_same; + using namespace __gnu_test; + + VERIFY( (is_same::type, int&&>::value) ); + VERIFY( (is_same::type, int&&>::value) ); + VERIFY( (is_same::type, const int&&>::value) ); + VERIFY( (is_same::type, int*&&>::value) ); + VERIFY( (is_same::type, ClassType&&>::value) ); + VERIFY( (is_same::type, ClassType&&>::value) ); + VERIFY( (is_same::type, int(&&)(int)>::value) ); + VERIFY( (is_same::type, void>::value) ); + VERIFY( (is_same::type, const void>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/addressof/1.cc b/libstdc++-v3/testsuite/20_util/addressof/1.cc new file mode 100644 index 000000000..43009f3c8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/addressof/1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void f1(int) { } + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + OverloadedAddress* ao1 = new OverloadedAddress(); + OverloadedAddress& o1 = *ao1; + + VERIFY( std::addressof(o1) == ao1 ); + + const OverloadedAddress* ao2 = new OverloadedAddress(); + const OverloadedAddress& o2 = *ao2; + + VERIFY( std::addressof(o2) == ao2 ); + + VERIFY( std::addressof(f1) == &f1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..559cd20e2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing utility with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template short* addressof(short&); +} diff --git a/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6186d8e8a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-09-17 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct aligned_storage<1, alignment_of::value>; + template struct aligned_storage<2>; +} diff --git a/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc b/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc new file mode 100644 index 000000000..1399a11a7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// 2007-09-17 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +struct MSAlignType { } __attribute__((__aligned__)); + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::aligned_storage; + using std::alignment_of; + using namespace __gnu_test; + + const std::size_t align_c = alignment_of::value; + VERIFY( (sizeof(aligned_storage<4, align_c>::type) >= 4) ); + VERIFY( (__alignof__(aligned_storage<4, align_c>::type) == align_c) ); + + const std::size_t align_s = alignment_of::value; + VERIFY( (sizeof(aligned_storage<1, align_s>::type) >= 1) ); + VERIFY( (__alignof__(aligned_storage<1, align_s>::type) == align_s) ); + + const std::size_t align_i = alignment_of::value; + VERIFY( (sizeof(aligned_storage<7, align_i>::type) >= 7) ); + VERIFY( (__alignof__(aligned_storage<7, align_i>::type) == align_i) ); + + const std::size_t align_d = alignment_of::value; + VERIFY( (sizeof(aligned_storage<2, align_d>::type) >= 2) ); + VERIFY( (__alignof__(aligned_storage<2, align_d>::type) == align_d) ); + + const std::size_t align_ai = alignment_of::value; + VERIFY( (sizeof(aligned_storage<20, align_ai>::type) >= 20) ); + VERIFY( (__alignof__(aligned_storage<20, align_ai>::type) == align_ai) ); + + const std::size_t align_ct = alignment_of::value; + VERIFY( (sizeof(aligned_storage<11, align_ct>::type) >= 11) ); + VERIFY( (__alignof__(aligned_storage<11, align_ct>::type) == align_ct) ); + + const std::size_t align_msa = alignment_of::value; + VERIFY( (sizeof(aligned_storage<5>::type) >= 5) ); + VERIFY( (__alignof__(aligned_storage<5>::type) == align_msa) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/1.cc b/libstdc++-v3/testsuite/20_util/allocator/1.cc new file mode 100644 index 000000000..0e1024745 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/1.cc @@ -0,0 +1,65 @@ +// 2001-06-14 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.1.1 allocator members + +#include +#include +#include +#include + +struct gnu { }; + +bool check_new = false; +bool check_delete = false; + +void* +operator new(std::size_t n) throw(std::bad_alloc) +{ + check_new = true; + return std::malloc(n); +} + +void operator delete(void *v) throw() +{ + check_delete = true; + return std::free(v); +} + +void test01() +{ + bool test __attribute__((unused)) = true; + std::allocator obj; + + // NB: These should work for various size allocation and + // deallocations. Currently, they only work as expected for sizes > + // _MAX_BYTES as defined in stl_alloc.h, which happes to be 128. + gnu* pobj = obj.allocate(256); + VERIFY( check_new ); + + obj.deallocate(pobj, 256); + VERIFY( check_delete ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/20_util/allocator/10378.cc b/libstdc++-v3/testsuite/20_util/allocator/10378.cc new file mode 100644 index 000000000..f8a7f1ad3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/10378.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.1.5 allocator requirements / 20.4.1.1 allocator members + +#include +#include +#include + +class Bob +{ +public: + static void* operator new(size_t sz) + { return std::malloc(sz); } +}; + +// libstdc++/10378 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + list uniset; + uniset.push_back(Bob()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/14176.cc b/libstdc++-v3/testsuite/20_util/allocator/14176.cc new file mode 100644 index 000000000..c7442509d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/14176.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.1.1 allocator members + +#include +#include + +// libstdc++/14176 +void test02() +{ + unsigned int len = 0; + std::allocator a; + int* p = a.allocate(len); + a.deallocate(p, len); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/33807.cc b/libstdc++-v3/testsuite/20_util/allocator/33807.cc new file mode 100644 index 000000000..637bfcbae --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/33807.cc @@ -0,0 +1,32 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// libstdc++/33807 +template +bool operator != (const T& x, const T& y) { return !(x == y); } + +struct foo { }; + +void fnx() +{ + std::list l1, l2; + l1 = l2; +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/51626.cc b/libstdc++-v3/testsuite/20_util/allocator/51626.cc new file mode 100644 index 000000000..951aa18fe --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/51626.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++0x" } + +#include +#include +#include + +int count = 0; + +template + struct allocator98 : std::allocator + { + template struct rebind { typedef allocator98 other; }; + + allocator98() { } + + template allocator98(const allocator98&) { }; + + void construct(T* p, const T& val) + { + ++count; + std::allocator::construct(p, val); + } + }; + +template + struct allocator11 : std::allocator + { + template struct rebind { typedef allocator11 other; }; + + allocator11() { } + + template allocator11(const allocator11&) { }; + + template + void construct(T* p, Args&&... args) + { + ++count; + std::allocator::construct(p, std::forward(args)...); + } + }; + +int main() +{ + std::vector< int, allocator98 > v98(1); + VERIFY( count == 0 ); + + std::vector< int, allocator11 > v11(1); + VERIFY( count == 1 ); +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/8230.cc b/libstdc++-v3/testsuite/20_util/allocator/8230.cc new file mode 100644 index 000000000..e71f51d21 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/8230.cc @@ -0,0 +1,53 @@ +// 2001-06-14 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.1.1 allocator members + +#include +#include +#include + +// libstdc++/8230 +void test02() +{ + bool test __attribute__((unused)) = true; + try + { + std::allocator alloc; + const std::allocator::size_type n = alloc.max_size(); + int* p = alloc.allocate(n + 1); + p[n] = 2002; + } + catch(const std::bad_alloc& e) + { + // Allowed. + test = true; + } + catch(...) + { + test = false; + } + VERIFY( test ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..5ca0be4ab --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers. + +#include + +template class std::allocator; diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc new file mode 100644 index 000000000..f5246482f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc @@ -0,0 +1,94 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.4.5.1 auto_ptr constructors [lib.auto.ptr.cons] + +// Construction from pointer +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::auto_ptr A_from_A(new A); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::auto_ptr A_from_B(new B); + VERIFY( A_from_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc new file mode 100644 index 000000000..0ae57f97e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// Construction from std::auto_ptr +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr A_from_A(new A); + std::auto_ptr B_from_B(new B); + + std::auto_ptr A_from_ptr_A(A_from_A); + std::auto_ptr A_from_ptr_B(B_from_B); + VERIFY( A_from_A.get() == 0 ); + VERIFY( B_from_B.get() == 0 ); + VERIFY( A_from_ptr_A.get() != 0 ); + VERIFY( A_from_ptr_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc new file mode 100644 index 000000000..78fd5aaf6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// Assignment from std::auto_ptr +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr A_from_ptr_A; + std::auto_ptr A_from_ptr_B; + std::auto_ptr A_from_A(new A); + std::auto_ptr B_from_B(new B); + + A_from_ptr_A = A_from_A; + A_from_ptr_B = B_from_B; + VERIFY( A_from_A.get() == 0 ); + VERIFY( B_from_B.get() == 0 ); + VERIFY( A_from_ptr_A.get() != 0 ); + VERIFY( A_from_ptr_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc new file mode 100644 index 000000000..be034c00c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include +#include + +// libstdc++/3946 +// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html +struct Base { }; +struct Derived : public Base { }; + +std::auto_ptr +conversiontest08() { return std::auto_ptr(new Derived); } + +void +test08() +{ + std::auto_ptr ptr; + ptr = conversiontest08(); +} + + +int +main() +{ + test08(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc new file mode 100644 index 000000000..a623a87b5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// Destruction +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + {/*lifetine scope*/ + std::auto_ptr A_from_A(new A); + std::auto_ptr A_from_B(new B); + std::auto_ptr B_from_B(new B); + }/*destructors called here*/ + + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 3 ); + VERIFY( B::ctor_count == 2 ); + VERIFY( B::dtor_count == 2 ); + + return 0; +} + +int +main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc new file mode 100644 index 000000000..2f61520e2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// Class member construction/destruction +template +class pimpl +{ +public: + pimpl() : p_impl(new T) {} +private: + std::auto_ptr p_impl; +}; + +int +test05() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + pimpl(); + pimpl(); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); + return 0; +} + +int +main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc new file mode 100644 index 000000000..88c2405f2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.4.5.2 auto_ptr members [lib.auto.ptr.members] + +// Member access +int +test06() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr A_from_A(new A); + std::auto_ptr A_from_A_ptr(A_from_A.release()); + VERIFY( A_from_A.get() == 0 ); + VERIFY( A_from_A_ptr.get() != 0 ); + VERIFY( A_from_A_ptr->ctor_count == 1 ); + VERIFY( (*A_from_A_ptr).dtor_count == 0 ); + + A* A_ptr = A_from_A_ptr.get(); + + A_from_A_ptr.reset(A_ptr); + VERIFY( A_from_A_ptr.get() == A_ptr ); + VERIFY( A_from_A_ptr->ctor_count == 1 ); + VERIFY( (*A_from_A_ptr).dtor_count == 0 ); + + A_from_A_ptr.reset(new A); + VERIFY( A_from_A_ptr.get() != A_ptr ); + VERIFY( A_from_A_ptr->ctor_count == 2 ); + VERIFY( (*A_from_A_ptr).dtor_count == 1 ); + return 0; +} + +int +main() +{ + test06(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc new file mode 100644 index 000000000..cf7ea89bf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.4.5.3 auto_ptr conversions [lib.auto.ptr.conv] + +// Parameters and return values +template +static std::auto_ptr source() +{ + return std::auto_ptr(new T); +} + +template +static void drain(std::auto_ptr) +{} + +int +test07() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + drain(source()); + // The resolution of core issue 84, now a DR, breaks this call. + // drain(source()); + drain(source()); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); + return 0; +} + +int +main() +{ + test07(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc new file mode 100644 index 000000000..617d76b80 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc @@ -0,0 +1,52 @@ +// { dg-do compile } + +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011 +// Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.5 Template class auto_ptr negative tests [lib.auto.ptr] + +#include +#include + +// via Jack Reeves +// libstdc++/3946 +// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html +struct Base { }; +struct Derived : public Base { }; + +std::auto_ptr +foo() { return std::auto_ptr(new Derived); } + +int +test01() +{ + std::auto_ptr ptr2; + ptr2 = new Base; // { dg-error "no match" } + // { dg-error "candidate" "candidate note" { target *-*-* } 39 } + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-error "::auto_ptr|no known conversion" "" { target *-*-* } 136 } +// { dg-error "note" "" { target *-*-* } 154 } +// { dg-error "::auto_ptr|no known conversion" "" { target *-*-* } 264 } diff --git a/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..32b526bf3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers. + +#include + +template class std::auto_ptr; diff --git a/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc new file mode 100644 index 000000000..8ff6d981b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// 2007-05-29 Benjamin Kosnik + +// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + typedef std::bad_function_call test_type; + __gnu_test::diamond_derivation::test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/bind/35569.cc b/libstdc++-v3/testsuite/20_util/bind/35569.cc new file mode 100644 index 000000000..8d25f1a8a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/35569.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include + +using namespace std; +using namespace std::placeholders; + +void test01() +{ + bind(multiplies(),4,_1)(5); +} + diff --git a/libstdc++-v3/testsuite/20_util/bind/38889.cc b/libstdc++-v3/testsuite/20_util/bind/38889.cc new file mode 100644 index 000000000..b4f47c6c4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/38889.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include + +void goo(int); +void foo() { + std::bind (goo,1)(); + std::bind (goo,std::placeholders::_1)(1); +} + + diff --git a/libstdc++-v3/testsuite/20_util/bind/42593.cc b/libstdc++-v3/testsuite/20_util/bind/42593.cc new file mode 100644 index 000000000..327d1df54 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/42593.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +#include + +void f( int ) {} + +void test01() +{ + std::function< void( int ) > pf = std::bind( &f, std::placeholders::_1 ); + pf(1); +} + diff --git a/libstdc++-v3/testsuite/20_util/bind/45924.cc b/libstdc++-v3/testsuite/20_util/bind/45924.cc new file mode 100644 index 000000000..27adb70c0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/45924.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// PR libstdc++/45924 + +struct f +{ + int operator()(int, int) const { return 0; } +}; + +void test01() +{ + int i = 0; + using namespace std::placeholders; + auto b = std::bind(f(), _1, _2); + auto const bc(b); + b(i, i); + bc(i, i); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/20_util/bind/49058_1.cc b/libstdc++-v3/testsuite/20_util/bind/49058_1.cc new file mode 100644 index 000000000..fb34e0878 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/49058_1.cc @@ -0,0 +1,34 @@ +// { dg-options "-pedantic -std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// PR libstdc++/49058 + +struct F +{ + void + operator()(); +}; + +void f() +{ + std::bind( F() ); +} diff --git a/libstdc++-v3/testsuite/20_util/bind/49058_2.cc b/libstdc++-v3/testsuite/20_util/bind/49058_2.cc new file mode 100644 index 000000000..fc9d9a254 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/49058_2.cc @@ -0,0 +1,28 @@ +// { dg-options "-pedantic -std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// PR libstdc++/49058 + +void f() +{ + std::bind( []{} ); +} diff --git a/libstdc++-v3/testsuite/20_util/bind/all_bound.cc b/libstdc++-v3/testsuite/20_util/bind/all_bound.cc new file mode 100644 index 000000000..4335ee1d1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/all_bound.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +#include +#include + +// Operations on empty function<> objects +void test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( std::bind(std::plus(), 3, 5)() == 8 ); + VERIFY( std::bind(std::minus(), 3, 5)() == -2 ); + VERIFY( std::bind(std::plus(), 3, 5)() == 8 ); + VERIFY( std::bind(std::minus(), 3, 5)() == -2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/bind/conv_result.cc b/libstdc++-v3/testsuite/20_util/bind/conv_result.cc new file mode 100644 index 000000000..440a5276b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/conv_result.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +#include +#include + +struct X +{ + typedef int result_type; + int operator()(int i) const { return i+1; } + bool b; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::bind; + using std::ref; + ::X x = { true }; + + // test bind form + bind(ref(x), 1)(); + VERIFY( bind(ref(x), 1)() == 2 ); + bind(&::X::b, ref(x))(); + VERIFY( bind(&::X::b, ref(x))() == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc b/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc new file mode 100644 index 000000000..d597a56fd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc @@ -0,0 +1,119 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +// { dg-options "-std=gnu++0x" } + +#include +#include + +// target must be invoked with cv-quals of call wrapper + +struct X +{ + int operator()() { return 0; } + int operator()() const { return 1; } + int operator()() volatile { return 2; } + int operator()() const volatile { return 3; } + + int operator()(int, int, int) { return 0; } + int operator()(int, int, int) const { return 1; } + int operator()(int, int, int) volatile { return 2; } + int operator()(int, int, int) const volatile { return 3; } +}; + +using std::placeholders::_1; +using std::placeholders::_2; + +void test01() +{ + bool test __attribute__((unused)) = true; + + auto b0 = std::bind(X()); + VERIFY( b0() == 0 ); + + const auto b1 = std::bind(X()); + VERIFY( b1() == 1 ); + + volatile auto b2 = std::bind(X()); + VERIFY( b2() == 2 ); + + const volatile auto b3 = std::bind(X()); + VERIFY( b3() == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + auto b0 = std::bind(X()); + VERIFY( b0() == 0 ); + + const auto b1 = std::bind(X()); + VERIFY( b1() == 1 ); + + volatile auto b2 = std::bind(X()); + VERIFY( b2() == 2 ); + + const volatile auto b3 = std::bind(X()); + VERIFY( b3() == 3 ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + auto b0 = std::bind(X(), 0, _1, _2); + VERIFY( b0(0, 0) == 0 ); + + const auto b1 = std::bind(X(), _1, 0, _2); + VERIFY( b1(0, 0) == 1 ); + + volatile auto b2 = std::bind(X(), _1, _2, 0); + VERIFY( b2(0, 0) == 2 ); + + const volatile auto b3 = std::bind(X(), _1, 0, _2); + VERIFY( b3(0, 0) == 3 ); +} + +void test04() +{ + bool test __attribute__((unused)) = true; + + auto b0 = std::bind(X(), 0, _1, _2); + VERIFY( b0(0, 0) == 0 ); + + const auto b1 = std::bind(X(), _1, 0, _2); + VERIFY( b1(0, 0) == 1 ); + + volatile auto b2 = std::bind(X(), _1, _2, 0); + VERIFY( b2(0, 0) == 2 ); + + const volatile auto b3 = std::bind(X(), _1, 0, _2); + VERIFY( b3(0, 0) == 3 ); +} + + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc b/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc new file mode 100644 index 000000000..067d862b4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X +{ + int operator()() const { return 0; } + int operator()() volatile { return 1; } + int operator()() const volatile { return 2; } + void operator()() { }; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + const auto b0 = std::bind(X()); + VERIFY( b0() == 0 ); + + volatile auto b1 = std::bind(X()); + VERIFY( b1() == 1 ); + + const volatile auto b2 = std::bind(X()); + VERIFY( b2() == 2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/bind/move.cc b/libstdc++-v3/testsuite/20_util/bind/move.cc new file mode 100644 index 000000000..d9485ad31 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/move.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// PR libstdc++/45924 + +struct f +{ + f() : i(0) { } + f(f&& r) : i(1) { r.i = -1; } + f(const f&) = delete; + int operator()() { return i; } + int i; +}; + +void test01() +{ + auto b = std::bind(f()); + VERIFY( b() == 1 ); + auto bc(std::move(b)); + VERIFY( bc() == 1 ); + VERIFY( b() == -1 ); +} + +void test02() +{ + auto b = std::bind(f()); + VERIFY( b() == 1 ); + auto bc(std::move(b)); + VERIFY( bc() == 1 ); + VERIFY( b() == -1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/20_util/bind/nested.cc b/libstdc++-v3/testsuite/20_util/bind/nested.cc new file mode 100644 index 000000000..ae3a16686 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/nested.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +#include +#include + +// Operations on empty function<> objects +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::placeholders; + + int five = 5; + int seven = 7; + VERIFY( std::bind(std::multiplies(), _1, + std::bind(std::minus(), 6, _2))(five, seven) == -5 ); + VERIFY( std::bind(std::multiplies(), _1, + std::bind(std::minus(), 6, _2))(seven, five) == 7 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/bind/placeholders.cc b/libstdc++-v3/testsuite/20_util/bind/placeholders.cc new file mode 100644 index 000000000..fc0d9c64f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/placeholders.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +#include +#include + +// Operations on empty function<> objects +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::placeholders; + + int five = 5; + int seven = 7; + VERIFY( std::bind(std::minus(), _1, _2)(five, seven) == -2 ); + VERIFY( std::bind(std::minus(), _2, _1)(five, seven) == 2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/bind/ref.cc b/libstdc++-v3/testsuite/20_util/bind/ref.cc new file mode 100644 index 000000000..6b41f1887 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/ref.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +#include +#include + +struct X +{ + X() : bar(17) {} + + int foo(int x, int y) { return bar + x + y; } + + int bar; + +private: + X(const X&); + X& operator=(const X&); +}; + +// Operations on empty function<> objects +void test01() +{ + bool test __attribute__((unused)) = true; + using std::bind; + using std::ref; + ::X x; + + VERIFY( bind(&::X::foo, ref(x), 1, 2)() == 20 ); + VERIFY( bind(&::X::foo, ref(x), 1, 2)() == 20 ); + VERIFY( bind(&::X::bar, ref(x))() == 17 ); + VERIFY( bind(&::X::bar, ref(x))() == 17 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/bind/ref2.cc b/libstdc++-v3/testsuite/20_util/bind/ref2.cc new file mode 100644 index 000000000..614943157 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/ref2.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +// { dg-options "-std=gnu++0x" } + +#include +#include + +using namespace std::placeholders; + +int inc(int& i) { return ++i; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + int counter = 0; + std::bind(&inc, _1)(counter); + VERIFY(counter == 1 ); + std::bind(&inc, std::ref(counter))(); + VERIFY(counter == 2 ); +} + +struct Inc +{ + int operator()(int& i) const { return ++i; } + void operator()(int&&) const { } + + int f(int& i) const { return ++i; } +}; + +void test02() +{ + bool test __attribute__((unused)) = true; + + int counter = 0; + std::bind(Inc(), _1)(counter); + VERIFY(counter == 1 ); + std::bind(&Inc::f, Inc(), std::ref(counter))(); + VERIFY(counter == 2 ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc new file mode 100644 index 000000000..060bf8715 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.11 Function template bind + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include + +using namespace std::placeholders; + +int inc(int& i) { return ++i; } + +void test01() +{ + const int dummy = 0; + std::bind(&inc, _1)(0); // { dg-error ""} + std::bind(&inc, std::ref(dummy))(); // { dg-error ""} + std::bind(&inc, dummy)(); // { dg-error ""} + std::bind(&inc, 0)(); // { dg-error ""} +} + +struct Inc +{ + int operator()(int& i) const { return ++i; } + void operator()(int&&) const { } + + int f(int&& i) const { return ++i; } +}; + +void test02() +{ + const int dummy = 0; + std::bind(Inc(), _1)(dummy); // { dg-error ""} + std::bind(&Inc::f, Inc(), std::ref(dummy))(); // { dg-error ""} +} + +int main() +{ + test01(); + test02(); +} + +// { dg-excess-errors "" } diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..93422ca84 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef int test_type1; + typedef int& test_type2; + typedef double test_type3; + typedef float test_type4; + typedef void test_type5; + typedef const void test_type6; + + template struct common_type; + template struct common_type; + template struct common_type; + template struct common_type; + + template struct common_type; + template struct common_type; +} diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc new file mode 100644 index 000000000..94469d974 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc @@ -0,0 +1,117 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +#define JOIN( X, Y ) DO_JOIN( X, Y ) +#define DO_JOIN( X, Y ) DO_JOIN2(X,Y) +#define DO_JOIN2( X, Y ) X##Y + +#define COMMON_TYPE_TEST_1(type1, uid) \ + typedef common_type::type JOIN(test_t,uid); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,c)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,v)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,cv)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,l)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,lc)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,lv)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,lcv)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,r)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,rc)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,rv)); \ + VERIFY( (is_same::value) ); \ + typedef common_type::type JOIN(test_t,JOIN(uid,rcv)); \ + VERIFY( (is_same::value) ) + +struct A { }; +struct B : A { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::common_type; + using std::is_same; + + // Positive tests. + COMMON_TYPE_TEST_1(int, 1); + COMMON_TYPE_TEST_1(double, 2); + COMMON_TYPE_TEST_1(A, 3); + COMMON_TYPE_TEST_1(B, 4); +} + +#define COMMON_TYPE_TEST_2_IMPL(type1, type2, type3, uid) \ + typedef common_type::type JOIN(JOIN(test, uid),_t1); \ + typedef common_type::type JOIN(JOIN(test, uid),_t2); \ + VERIFY( (is_same::value) ); \ + VERIFY( (is_same::value) ) + +#define NO_CV + +#define COMMON_TYPE_TEST_2(cv_qual, type1, type2, type3, uid) \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1 &, type2, type3, JOIN(uid,l)); \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1 &&, type2, type3, JOIN(uid,r)) + +#define COMMON_TYPE_TEST_ALL_2(type1, type2, type3, uid) \ + COMMON_TYPE_TEST_2(NO_CV, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(const, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(volatile, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(const volatile, type1, type2, type3, uid) + +void test02() +{ + bool test __attribute__((unused)) = true; + using std::common_type; + using std::is_same; + + COMMON_TYPE_TEST_ALL_2(int, int, int, 1); + COMMON_TYPE_TEST_ALL_2(int, double, double, 2); + COMMON_TYPE_TEST_2(NO_CV, A, A, A, 3); + COMMON_TYPE_TEST_2(const, A, A, const A, 4); + COMMON_TYPE_TEST_2(NO_CV, B, A, A, 5); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc new file mode 100644 index 000000000..b4a96e540 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } +// 2009-11-12 Paolo Carlini +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 1255. +void test01() +{ + bool test __attribute__((unused)) = true; + using std::common_type; + using std::is_same; + + VERIFY( (is_same::type, void>::value) ); + VERIFY( (is_same::type, const void>::value) ); + VERIFY( (is_same::type, volatile void>::value) ); + VERIFY( (is_same::type, + const volatile void>::value) ); + + VERIFY( (is_same::type, void>::value) ); + VERIFY( (is_same::type, void>::value) ); + VERIFY( (is_same::type, void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + VERIFY( (is_same::type, + void>::value) ); + } + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..854f46d6f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct conditional; +} diff --git a/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc new file mode 100644 index 000000000..c1b145d80 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::conditional; + + typedef conditional::type test1_type; + VERIFY( (std::is_same::value) ); + + typedef conditional::type test2_type; + VERIFY( (std::is_same::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6433d945b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct decay; +} diff --git a/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc new file mode 100644 index 000000000..9a67ab47d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::decay; + using std::is_same; + + // Positive tests. + typedef decay::type test1_type; + VERIFY( (is_same::value) ); + + // NB: DR 705. + typedef decay::type test2_type; + VERIFY( (is_same::value) ); + + typedef decay::type test3_type; + VERIFY( (is_same::type*>::value) ); + + typedef void (fn_type) (); + typedef decay::type test4_type; + VERIFY( (is_same::type>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1.cc new file mode 100644 index 000000000..204d4ebb6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2009-11-12 Paolo Carlini +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +template + struct is_convertible_mini + { + private: + typedef char one; + typedef struct { char arr[2]; } two; + + static one test(To); + static two test(...); + + public: + static const bool value = sizeof(test(std::declval())) == 1; +}; + +template + const bool is_convertible_mini::value; + +void test01() +{ + static_assert(is_convertible_mini::value, "#1"); + static_assert(!is_convertible_mini::value, "#2"); + static_assert(is_convertible_mini::value, "#3"); + static_assert(!is_convertible_mini::value, "#4"); + static_assert(is_convertible_mini::value, "#5"); + static_assert(!is_convertible_mini::value, "#6"); +} diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc new file mode 100644 index 000000000..9113c031b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2009-11-12 Paolo Carlini +// +// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-error "static assertion failed" "" { target *-*-* } 1134 } + +#include + +void test01() +{ + std::declval(); // { dg-error "instantiated from here" } +} diff --git a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc new file mode 100644 index 000000000..9d779ac9c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x " } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct B { }; +struct D : B { }; + +// libstdc++/48631 +D d; +std::default_delete db; +typedef decltype(db(&d)) type; // { dg-error "use of deleted function" } +// { dg-error "declared here" "" { target *-*-* } 83 } diff --git a/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc new file mode 100644 index 000000000..01fb28476 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_defaulted_default_constructible test; + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc b/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc new file mode 100644 index 000000000..fb955abf1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3 Class template duration [time.duration] + +#include +#include + +// 20.8.3.3 duration arithmetic [time.duration.arithmetic] (unary member ops) +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration d0(3); + duration d1 = -d0; + VERIFY(d0.count() == 3); + VERIFY(d1.count() == -3); + + duration d2 = (+d0); + VERIFY(d2.count() == 3); + + duration d3(++d2); + VERIFY(d2.count() == 4); + VERIFY(d3.count() == 4); + + duration d4(d3++); + VERIFY(d3.count() == 5); + VERIFY(d4.count() == 4); + + duration d5(--d4); + VERIFY(d4.count() == 3); + VERIFY(d5.count() == 3); + + duration d6(d5--); + VERIFY(d5.count() == 2); + VERIFY(d6.count() == 3); +} + +// 20.8.3.3 duration arithmetic [time.duration.arithmetic] (binary member ops) +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration d7(3); + duration d8(9); + d7 += d8; + VERIFY(d7.count() == 12); + VERIFY(d8.count() == 9); + + duration d9(3); + duration d10(9); + d9 -= d10; + VERIFY(d9.count() == -6); + VERIFY(d10.count() == 9); + + duration d11(9); + int i = 3; + d11 *= i; + VERIFY(d11.count() == 27); + + duration d12(12); + d12 /= i; + VERIFY(d12.count() == 4); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc b/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc new file mode 100644 index 000000000..3940d6a67 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3 Class template duration [time.duration] + +#include +#include + +// 20.8.3.5 duration non-member arithmetic [time.duration.nonmember] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration d0(12); + duration d1(3); + int i = 3; + + duration d2 = d0 + d1; + VERIFY(d2.count() == 15); + + duration d3 = d0 - d1; + VERIFY(d3.count() == 9); + + duration d4 = d0 * i; + VERIFY(d4.count() == 36); + + duration d5 = i * d0; + VERIFY(d5.count() == 36); + + duration d6 = d0 / i; + VERIFY(d6.count() == 4); + + int j = d0 / d1; + VERIFY(j == 4); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-1.cc b/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-1.cc new file mode 100644 index 000000000..decf94c88 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-1.cc @@ -0,0 +1,48 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +class ClockTime +{ + typedef std::chrono::hours hours; + typedef std::chrono::minutes minutes; + typedef std::chrono::seconds seconds; + +public: + hours hours_; + minutes minutes_; + seconds seconds_; + + template + explicit + ClockTime(const std::chrono::duration& d) + : hours_ (std::chrono::duration_cast (d)), + minutes_(std::chrono::duration_cast(d % hours(1))), + seconds_(std::chrono::duration_cast(d % minutes(1))) { } +}; + +// DR 934. +void test01() +{ + std::chrono::duration d; + ClockTime ct(d); +} diff --git a/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-2.cc b/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-2.cc new file mode 100644 index 000000000..ada8ba573 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-2.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 934. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + const duration d0(17); + duration d3(d0); + d3 %= 5; + VERIFY( d3.count() == 2 ); + + const duration d4(7); + duration d5(d0); + d5 %= d4; + VERIFY( d5.count() == 3 ); + + const duration d6 = d0 % 6; + VERIFY( d6.count() == 5 ); + + const duration d7(11); + const duration d8 = d0 % d7; + VERIFY( d8.count() == 6 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc b/libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc new file mode 100644 index 000000000..35151f2ad --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3 Class template duration [time.duration] + +#include +#include + +// 20.8.3.6 duration comparisons [time.duration.comparisons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration d0(12); + duration d1(3); + duration d2(3); + + VERIFY(d1 < d0); + VERIFY(d0 > d1); + + VERIFY(d0 != d1); + VERIFY(d1 == d2); + + VERIFY(d1 <= d2); + VERIFY(d1 >= d2); + + VERIFY(d1 <= d0); + VERIFY(d0 >= d1); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc new file mode 100644 index 000000000..94338cee3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_comparison_operators test; + test.operator()(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/1.cc b/libstdc++-v3/testsuite/20_util/duration/cons/1.cc new file mode 100644 index 000000000..2cd22a4a7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/cons/1.cc @@ -0,0 +1,134 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3 Class template duration [time.duration] + +#include +#include +#include + +template +struct type_emulator +{ + type_emulator() + : i(T(0)) { } + + type_emulator(T j) + : i(j) { } + + type_emulator(const type_emulator& e) + : i(e.i) { } + + type_emulator& + operator*=(type_emulator a) + { + i *= a.i; + return *this; + } + + type_emulator& + operator+=(type_emulator a) + { + i += a.i; + return *this; + } + + operator T () + { return i; } + + T i; +}; + +template +bool +operator==(type_emulator a, type_emulator b) +{ return a.i == b.i; } + +template +bool +operator<(type_emulator a, type_emulator b) +{ return a.i < b.i; } + +template +type_emulator +operator+(type_emulator a, type_emulator b) +{ return a += b; } + +template +type_emulator +operator*(type_emulator a, type_emulator b) +{ return a *= b; } + +namespace std +{ + template + struct common_type, U> + { typedef typename common_type::type type; }; + + template + struct common_type> + { typedef typename common_type::type type; }; + + template + struct common_type, type_emulator> + { typedef typename common_type::type type; }; + + namespace chrono + { + template + struct treat_as_floating_point> + : is_floating_point + { }; + } +} + +typedef type_emulator int_emulator; +typedef type_emulator dbl_emulator; + +// 20.8.3.1 duration constructors [time.duration.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using std::chrono::duration; + + int r = 3; + duration d1(r); + VERIFY(d1.count() == static_cast::rep>(r)); + + double s = 8.0; + duration d2(s); + VERIFY(d2.count() == static_cast::rep>(s)); + + int_emulator ie(3); + duration d3(ie); + VERIFY(d3.count() == static_cast::rep>(ie)); + + dbl_emulator de(4.0); + duration d4(de); + VERIFY(d4.count() == static_cast::rep>(de)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc b/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc new file mode 100644 index 000000000..56b4e4f41 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3.1 duration constructors [time.duration.cons] + +#include + +void +test01() +{ + std::chrono::duration d1(1.0); // { dg-error "no matching" } +} + +void +test02() +{ + using namespace std::chrono; + + duration d2(8); + duration d2_copy(d2); // { dg-error "no matching" } +} + +// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/2.cc b/libstdc++-v3/testsuite/20_util/duration/cons/2.cc new file mode 100644 index 000000000..820d76401 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/cons/2.cc @@ -0,0 +1,119 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3 Class template duration [time.duration] + +#include +#include +#include + +template +struct type_emulator +{ + type_emulator() : i(T(0)) { } + type_emulator(T j) : i(j) { } + type_emulator(const type_emulator& e) : i(e.i) { } + + type_emulator& operator*=(type_emulator a) + { i *= a.i; return *this; } + + type_emulator& operator+=(type_emulator a) + { i += a.i; return *this; } + + operator T () { return i; } + T i; +}; + +template +bool operator==(type_emulator a, type_emulator b) +{ return a.i == b.i; } + +template +bool operator<(type_emulator a, type_emulator b) +{ return a.i < b.i; } + +template +type_emulator operator+(type_emulator a, type_emulator b) +{ return a += b; } + +template +type_emulator operator*(type_emulator a, type_emulator b) +{ return a *= b; } + +namespace std +{ + template + struct common_type, U> + { typedef typename common_type::type type; }; + + template + struct common_type> + { typedef typename common_type::type type; }; + + template + struct common_type, type_emulator> + { typedef typename common_type::type type; }; + + namespace chrono + { + template + struct treat_as_floating_point> + : is_floating_point + { }; + } +} + +typedef type_emulator int_emulator; +typedef type_emulator dbl_emulator; + +// 20.8.3.1 duration constructors [time.duration.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration d0(3); + duration d0_copy(d0); + VERIFY(d0_copy.count() == d0.count()); + + duration d1(5); + duration d1_copy(d1); + VERIFY(d1.count() * 1000 == d1_copy.count()); + + duration d2(8.0); + duration d2_copy(d2); + VERIFY(d2.count() == d2_copy.count() * 1000.0); + + duration d3(5); + duration d3_copy(d3); + VERIFY(d3.count() * 1000 == d3_copy.count()); + + duration d4(5.0); + duration d4_copy(d4); + VERIFY(d4.count() == d4_copy.count() * dbl_emulator(1000.0)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc new file mode 100644 index 000000000..ca7716f63 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()(); + test2.operator()(); + test2.operator()(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/dr974_neg.cc b/libstdc++-v3/testsuite/20_util/duration/cons/dr974_neg.cc new file mode 100644 index 000000000..4466d3009 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/cons/dr974_neg.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3.1 duration constructors [time.duration.cons] + +#include + +// DR 974. +void test01() +{ + using namespace std::chrono; + + duration d(3.5); + duration i = d; // { dg-error "conversion" } +} diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/constexpr_functions.cc new file mode 100644 index 000000000..faeab3b93 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/constexpr_functions.cc @@ -0,0 +1,64 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + constexpr auto v3 __attribute__((unused)) + = _Ttesttype::zero(); + + constexpr _Ttesttype obj { }; + constexpr auto v4 __attribute__((unused)) + = obj.count(); + constexpr auto v5 __attribute__((unused)) + = -obj; + constexpr auto v6 __attribute__((unused)) + = +obj; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + test.operator()(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..792d15cb9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +template class std::chrono::duration; +template class std::chrono::duration>; diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc new file mode 100644 index 000000000..5965f03b1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include + +void test01() +{ + // Check if rep is a duration type + typedef std::chrono::duration rep_type; + typedef std::chrono::duration test_type; + test_type d; +} + +// { dg-error "rep cannot be a duration" "" { target *-*-* } 226 } +// { dg-error "instantiated from here" "" { target *-*-* } 31 } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc new file mode 100644 index 000000000..d84ab9e8c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include + +void test01() +{ + // Check if period is a ratio + typedef int rep_type; + typedef int period_type; + typedef std::chrono::duration test_type; + test_type d; +} + +// { dg-error "must be a specialization of ratio" "" { target *-*-* } 227 } +// { dg-error "instantiated from here" "" { target *-*-* } 32 } +// { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc new file mode 100644 index 000000000..7c73bf996 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +void test01() +{ + // Check if period is positive + typedef int rep_type; + typedef std::ratio<-1> period_type; + typedef std::chrono::duration test_type; + test_type d; +} + +// { dg-error "period must be positive" "" { target *-*-* } 229 } +// { dg-error "instantiated from here" "" { target *-*-* } 33 } diff --git a/libstdc++-v3/testsuite/20_util/duration_cast/constexpr.cc b/libstdc++-v3/testsuite/20_util/duration_cast/constexpr.cc new file mode 100644 index 000000000..b8a89aee9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration_cast/constexpr.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + using namespace std::chrono; + + // non-constexpr + minutes mn1(6000); + hours hr1 __attribute__((unused)) = duration_cast(mn1); + + // constexpr + constexpr minutes mn2(6000); + constexpr hours hr2 __attribute__((unused)) = duration_cast(mn2); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..802a49984 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct enable_if; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc new file mode 100644 index 000000000..f17eebadd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Positive tests. + typedef enable_if::type test1_type; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc new file mode 100644 index 000000000..6ab1fef33 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Negative tests. + typedef enable_if::type test2_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 32 } diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc new file mode 100644 index 000000000..17f8c84d2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-final { scan-assembler-not "_ZNSt23enable_shared_from_thisIiEC2Ev" } } +// { dg-final { scan-assembler-not "_ZN7derivedC2Ev" } } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct derived : public std::enable_shared_from_this +{ + constexpr derived() { } +}; + +int main() +{ + __gnu_test::constexpr_default_constructible test; + test.operator()(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..9a18a507b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include + +template class std::enable_shared_from_this; diff --git a/libstdc++-v3/testsuite/20_util/forward/1.cc b/libstdc++-v3/testsuite/20_util/forward/1.cc new file mode 100644 index 000000000..7d40416ff --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/1.cc @@ -0,0 +1,43 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +template + std::shared_ptr + factory(A1&& a1, A2&& a2) + { + return std::shared_ptr(new T(std::forward(a1), + std::forward(a2))); + } + +struct A +{ + A(int&, const double&); +}; + +void g() +{ + int i = 2; + std::shared_ptr sp1 = factory(i, 1.414); +} diff --git a/libstdc++-v3/testsuite/20_util/forward/1_neg.cc b/libstdc++-v3/testsuite/20_util/forward/1_neg.cc new file mode 100644 index 000000000..6c007bee2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/1_neg.cc @@ -0,0 +1,44 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +template + std::shared_ptr + factory(A1&& a1, A2&& a2) + { + return std::shared_ptr(new T(std::forward(a1), + std::forward(a2))); // { dg-error "no matching function" } + } + +struct A +{ + A(int&, const double&); +}; + +void g() +{ + std::shared_ptr sp1 = factory(2, 1.414); // { dg-error "instantiated from here" } +} + +// { dg-excess-errors "" } diff --git a/libstdc++-v3/testsuite/20_util/forward/a.cc b/libstdc++-v3/testsuite/20_util/forward/a.cc new file mode 100644 index 000000000..296c9f449 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/a.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +template + struct C + { + T t_; + + template ::value + >::type> + C(U&& u) : t_(std::forward(std::move(u).get())) {} + }; + +class A +{ + int data_; +public: + explicit + A(int data = 1) + : data_(data) {} + + ~A() { data_ = -1; } + + void test() const + { + bool test __attribute__((unused)) = true; + VERIFY( data_ == 3 ); + } +}; + +class Awrap +{ + const A& a_; +public: + explicit Awrap(const A& a) : a_(a) { } + const A& get() const { return a_; } +}; + +template + void test(C c) + { + c.t_.test(); + } + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test A. +int main() +{ + std::list > list; + A a(3); + C c((Awrap(a))); + list.push_back(c); + test(c); + test(list.front()); +} diff --git a/libstdc++-v3/testsuite/20_util/forward/b.cc b/libstdc++-v3/testsuite/20_util/forward/b.cc new file mode 100644 index 000000000..4168800b4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/b.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +template + struct C + { + T t_; + + template ::value + >::type> + C(U&& u) : t_(std::forward(std::move(u).get())) {} + }; + +class A +{ + int data_; +public: + explicit + A(int data = 1) + : data_(data) { } + + ~A() { data_ = -1; } + + void test() const + { + bool test __attribute__((unused)) = true; + VERIFY( data_ == 3 ); + } +}; + +class Awrap +{ + A a_; +public: + explicit Awrap(const A& a) : a_(a) { } + A get() const { return a_; } +}; + +template +void test(C c) +{ + c.t_.test(); +} + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test B. +int main() +{ + std::list > list; + A a(3); + C c((Awrap(a))); + list.push_back(c); + test(c); + test(list.front()); +} diff --git a/libstdc++-v3/testsuite/20_util/forward/c_neg.cc b/libstdc++-v3/testsuite/20_util/forward/c_neg.cc new file mode 100644 index 000000000..50bfbf028 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/c_neg.cc @@ -0,0 +1,78 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-error "static assertion failed" "" { target *-*-* } 69 } + +#include + +template + struct C + { + T t_; + + template ::value + >::type> + C(U&& u) : t_(std::forward(std::move(u).get())) {} + }; + +class A +{ + int data_; +public: + explicit + A(int data = 1) + : data_(data) { } + + ~A() { data_ = -1; } + + void test() const + { + __builtin_abort(); + } +}; + +class Awrap +{ + const A& a_; +public: + explicit Awrap(const A& a) : a_(a) {} + const A /* & */ get() const { return a_; } +}; + +template + void test(C c) + { + c.t_.test(); + } + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test C. +int main() +{ + std::list > list; + A a(3); + C c((Awrap(a))); + list.push_back(c); + test(c); + test(list.front()); +} diff --git a/libstdc++-v3/testsuite/20_util/forward/d.cc b/libstdc++-v3/testsuite/20_util/forward/d.cc new file mode 100644 index 000000000..c2c7eb3c8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/d.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +template + struct C + { + T t_; + + template ::value + >::type> + C(U&& u) : t_(std::forward(std::move(u).get())) { } + }; + +class A +{ + int data_; +public: + explicit + A(int data = 1) + : data_(data) { } + + ~A() { data_ = -1; } + + void test() const + { + bool test __attribute__((unused)) = true; + VERIFY( data_ == 3 ); + } +}; + +class Awrap +{ + A& a_; +public: + explicit Awrap(A& a) : a_(a) { } + const A& get() const { return a_; } + A& get() { return a_; } +}; + +template + void test(C c) + { + c.t_.test(); + } + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test D. +int main() +{ + std::list > list; + A a(3); + C c((Awrap(a))); + list.push_back(c); + test(c); + test(list.front()); +} diff --git a/libstdc++-v3/testsuite/20_util/forward/e.cc b/libstdc++-v3/testsuite/20_util/forward/e.cc new file mode 100644 index 000000000..4d89cd1a8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/e.cc @@ -0,0 +1,54 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +template + struct C + { + T t_; + + C() { } + + template ::value + >::type> + C(U&& u) : t_(std::forward(std::move(u).get())) { } + + C(C&& c) : t_(std::forward(c.t_)) { } + }; + +template + struct Derived + : C + { + Derived() { } + Derived(Derived&& d) : C(std::forward>(d)) { } + }; + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test E. +int main() +{ + Derived d; + Derived d2(std::move(d)); +} diff --git a/libstdc++-v3/testsuite/20_util/forward/f_neg.cc b/libstdc++-v3/testsuite/20_util/forward/f_neg.cc new file mode 100644 index 000000000..418a469df --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/f_neg.cc @@ -0,0 +1,90 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-error "static assertion failed" "" { target *-*-* } 69 } + +#include + +template + struct C + { + T t_; + + C() {} + + explicit C(const T& t) : t_(t) { } + + template ::value + >::type> + C(C&& c) : t_(std::forward(c.t_)) { } + }; + +class B; + +class A +{ + int data_; + + friend class B; +public: + explicit + A(int data = 1) + : data_(data) { } + + ~A() { data_ = -1; } + + void test() const + { + __builtin_abort(); + } +}; + +class B +{ + int data_; +public: + explicit + B(int data = 1) + : data_(data) { } + + B(const A& a) : data_(a.data_) { } + + B(A&& a) : data_(a.data_) { a.data_ = 100; } + + ~B() { data_ = -1; } + + void test() const + { + __builtin_abort(); + } +}; + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test F. +int main() +{ + A a(3); + C ca(a); + C cb(std::move(ca)); + cb.t_.test(); +} diff --git a/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..88ba9e548 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-07-10 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing utility with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template test_type&& forward(test_type&&); +} diff --git a/libstdc++-v3/testsuite/20_util/function/1.cc b/libstdc++-v3/testsuite/20_util/function/1.cc new file mode 100644 index 000000000..89a22542b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/1.cc @@ -0,0 +1,94 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Operations on empty function<> objects +void test01() +{ + using std::function; + using std::bad_function_call; + + // Default-construction + function f1; + VERIFY( ((bool)f1 == false) ); + VERIFY( !f1 ); + VERIFY( f1 == 0 ); + VERIFY( 0 == f1 ); + VERIFY( !(f1 != 0) ); + VERIFY( !(0 != f1) ); + + // Copy-construction + function f2(f1); + VERIFY( !f2 ); + + // Construct with NULL pointer + function f3(0); + VERIFY( !f3 ); + + // Assignment + f1 = f2; + VERIFY( !f1); + + // Assignment to NULL pointer + f1 = 0; + VERIFY( !f1 ); + + // Swap + swap(f1, f2); + VERIFY( !f1 ); + VERIFY( !f2 ); + + // Invocation should throw bad_function_call + bool thrown = false; + try + { + f1(3.14159f); + VERIFY( false ); + } + catch (bad_function_call) + { + thrown = true; + } + VERIFY( thrown ); + + // target_type returns typeid(void) + VERIFY( f1.target_type() == typeid(void) ); + + // target() always returns a NULL pointer + VERIFY( f1.target() == 0); + + // Check const version + const function& f1c = f1; + VERIFY( f1c.target() == 0 ); + VERIFY( !f1c ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/2.cc b/libstdc++-v3/testsuite/20_util/function/2.cc new file mode 100644 index 000000000..f2866d085 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/2.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put function pointers into function<> wrappers +void test02() +{ + using std::function; + + function f1(truncate_float); + VERIFY( f1 ); + VERIFY( !!f1 ); + VERIFY( !(f1 == 0) ); + VERIFY( !(0 == f1) ); + VERIFY( f1 != 0 ); + VERIFY( 0 != f1 ); + + // Copy-construction + function f2(f1); + VERIFY( f2 ); + + // Invocation + VERIFY( f1(3.1f) == 3 ); + VERIFY( f2(3.1f) == 3 ); + + // Assignment to zero + f1 = 0; + VERIFY( !f1 ); + + // Swap + f1.swap(f2); + VERIFY( f1 ); + VERIFY( !f2 ); + VERIFY( f1(3.1f) == 3 ); + + // Assignment from a function pointer + f2 = truncate_float; + VERIFY( f2(3.1f) == 3 ); + + // target_type and target() functions + const function& f1c = f1; + VERIFY( typeid(int(*)(float)) == f1.target_type() ); + VERIFY( f2.target() != 0 ); + VERIFY( *f2.target() == &truncate_float ); + VERIFY( f1c.target() != 0 ); + VERIFY( *f1c.target() == &truncate_float ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/3.cc b/libstdc++-v3/testsuite/20_util/function/3.cc new file mode 100644 index 000000000..7f9239015 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/3.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put nearly-matching function pointers into function<> wrappers +void test03() +{ + using std::function; + + function f1(truncate_double); + VERIFY( f1 ); + VERIFY( !!f1 ); + VERIFY( !(f1 == 0) ); + VERIFY( !(0 == f1) ); + VERIFY( f1 != 0 ); + VERIFY( 0 != f1 ); + + // Copy-construction + function f2(f1); + VERIFY( f2 ); + + // Invocation + VERIFY( f1(3.1f) == 3 ); + VERIFY( f2(3.1f) == 3 ); + + // Assignment to zero + f1 = 0; + VERIFY( !f1 ); + + // Swap + f1.swap(f2); + VERIFY( f1 ); + VERIFY( !f2 ); + VERIFY( f1(3.1f) == 3 ); + + // Assignment from a function pointer + f2 = truncate_double; + VERIFY( f2(3.1f) == 3 ); + + // target_type and target() functions + const function& f1c = f1; + VERIFY( typeid(long(*)(double)) == f1.target_type() ); + VERIFY( f2.target() != 0 ); + VERIFY( *f2.target() == &truncate_double ); + VERIFY( f1c.target() != 0 ); + VERIFY( *f1c.target() == &truncate_double ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/4.cc b/libstdc++-v3/testsuite/20_util/function/4.cc new file mode 100644 index 000000000..824d17f59 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/4.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put function objects into function<> wrappers +void test04() +{ + using std::function; + + do_truncate_float_t truncate_float; + + function f1(truncate_float); + VERIFY( f1 ); + VERIFY( !!f1 ); + VERIFY( !(f1 == 0) ); + VERIFY( !(0 == f1) ); + VERIFY( f1 != 0 ); + VERIFY( 0 != f1 ); + + // Copy-construction + function f2(f1); + VERIFY( f2 ); + + // Invocation + VERIFY( f1(3.1f) == 3 ); + VERIFY( f2(3.1f) == 3 ); + + // Assignment to zero + f1 = 0; + VERIFY( !f1 ); + + // Swap + f1.swap(f2); + VERIFY( f1 ); + VERIFY( !f2 ); + VERIFY( f1(3.1f) == 3 ); + + // Assignment from a function pointer + f2 = do_truncate_float_t(); + VERIFY( f2(3.1f) == 3 ); + + // target_type and target() functions + const function& f1c = f1; + VERIFY( typeid(do_truncate_float_t) == f1.target_type() ); + VERIFY( f2.target() != 0 ); + VERIFY( f1c.target() != 0 ); +} + +int main() +{ + test04(); + + VERIFY( do_truncate_double_t::live_objects == 0 ); + VERIFY( do_truncate_float_t::live_objects == 0 ); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/43397.cc b/libstdc++-v3/testsuite/20_util/function/43397.cc new file mode 100644 index 000000000..d76a27f34 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/43397.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.15 polymorphic function object wrapper + +#include +#include + +struct Foo +{ + Foo() { } + short operator() ( int && ) { return 1; } + short operator() ( int && ) const { return 2; } + short operator() ( int && ) volatile { return 3; } + short operator() ( int && ) const volatile { return 4; } + short func( int && ) { return 5; } + short func_c( int && ) const { return 6; } + short func_v( int && ) volatile { return 7; } + short func_cv( int && ) const volatile { return 8; } +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + using std::function; + using std::ref; + + Foo foo; + Foo const foo_c; + Foo volatile foo_v; + Foo const volatile foo_cv; + + std::function< int ( int && ) > f1( ref(foo) ); + VERIFY( f1(0) == 1 ); + + std::function< int ( int && ) > f2( ref(foo_c) ); + VERIFY( f2(0) == 2 ); + + std::function< int ( int && ) > f3( ref(foo_v) ); + VERIFY( f3(0) == 3 ); + + std::function< int ( int && ) > f4( ref(foo_cv) ); + VERIFY( f4(0) == 4 ); + + std::function< int ( Foo &, int && ) > f5( &Foo::func ) ; + VERIFY( f5(foo, 0) == 5 ); + + std::function< int ( Foo const &, int && ) > f6( &Foo::func_c ) ; + VERIFY( f6(foo_c, 0) == 6 ); + + std::function< int ( Foo volatile &, int && ) > f7( &Foo::func_v ) ; + VERIFY( f7(foo_v, 0) == 7 ); + + std::function< int ( Foo const volatile &, int && ) > f8( &Foo::func_cv ) ; + VERIFY( f8(foo_cv, 0) == 8 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/48541.cc b/libstdc++-v3/testsuite/20_util/function/48541.cc new file mode 100644 index 000000000..f8123676f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/48541.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// libstdc++/48451 + +#include + +struct X { + void operator () () const { } + float operator & () const { return 1.2345; } +}; + +void test01() +{ + X x; + std::function f(x); + f(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/5.cc b/libstdc++-v3/testsuite/20_util/function/5.cc new file mode 100644 index 000000000..b86b198f0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/5.cc @@ -0,0 +1,107 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put member pointers into function<> wrappers +void test05() +{ + using std::function; + + X x; + x.bar = 17; + + function frm(&X::bar); + VERIFY( frm ); + VERIFY( frm(x) == 17 ); + VERIFY( typeid(int X::*) == frm.target_type() ); + VERIFY( *frm.target() == &X::bar ); + + function fr(&X::foo); + VERIFY( fr ); + VERIFY( fr(x) == 1 ); + VERIFY( typeid(int (X::*)()) == fr.target_type() ); + VERIFY( *fr.target() == &X::foo ); + + function frc(&X::foo_c); + VERIFY( frc ); + VERIFY( frc(x) == 2 ); + VERIFY( typeid(int (X::*)() const) == frc.target_type() ); + VERIFY( *frc.target() == &X::foo_c ); + + function frv(&X::foo_v); + VERIFY( frv ); + VERIFY( frv(x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == frv.target_type() ); + VERIFY( *frv.target() == &X::foo_v ); + VERIFY( frv.target() == 0 ); + + function frcv(&X::foo_cv); + VERIFY( frcv ); + VERIFY( frcv(x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == frcv.target_type() ); + VERIFY( *frcv.target() == &X::foo_cv ); + VERIFY( frcv.target() == 0 ); + + function grm(&X::bar); + VERIFY( grm ); + VERIFY( grm(&x) == 17 ); + VERIFY( typeid(int X::*) == grm.target_type() ); + VERIFY( *grm.target() == &X::bar ); + + function gr(&X::foo); + VERIFY( gr ); + VERIFY( gr(&x) == 1 ); + VERIFY( typeid(int (X::*)()) == gr.target_type() ); + VERIFY( *gr.target() == &X::foo ); + + function grc(&X::foo_c); + VERIFY( grc ); + VERIFY( grc(&x) == 2 ); + VERIFY( typeid(int (X::*)() const) == grc.target_type() ); + VERIFY( *grc.target() == &X::foo_c ); + + function grv(&X::foo_v); + VERIFY( grv ); + VERIFY( grv(&x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == grv.target_type() ); + VERIFY( *grv.target() == &X::foo_v ); + VERIFY( grv.target() == 0 ); + + function grcv(&X::foo_cv); + VERIFY( grcv ); + VERIFY( grcv(&x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == grcv.target_type() ); + VERIFY( *grcv.target() == &X::foo_cv ); + VERIFY( grcv.target() == 0 ); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/6.cc b/libstdc++-v3/testsuite/20_util/function/6.cc new file mode 100644 index 000000000..47d2c1f9b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/6.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +struct secret {}; + +struct noncopyable_function_object_type +{ + noncopyable_function_object_type(secret) {} + + int operator()() const { return 42; } + int operator()() { return 17; } + + private: + noncopyable_function_object_type(); + noncopyable_function_object_type(const noncopyable_function_object_type&); + void operator=(const noncopyable_function_object_type&); +}; + +// Put reference_wrappers into function<> wrappers +void test06() +{ + using std::function; + using std::ref; + using std::cref; + + secret password; + noncopyable_function_object_type x(password); + + function f(ref(x)); + VERIFY( f ); + VERIFY( f() == 17 ); + VERIFY( f.target_type() == typeid(noncopyable_function_object_type) ); + VERIFY( f.target() == &x ); + + function g = f; + VERIFY( g ); + VERIFY( g() == 17 ); + VERIFY( g.target_type() == typeid(noncopyable_function_object_type) ); + VERIFY( g.target() == &x ); + + function h = cref(x); + VERIFY( h ); + VERIFY( h() == 42 ); + VERIFY( h.target_type() == typeid(noncopyable_function_object_type) ); + VERIFY( h.target() == &x ); + VERIFY( h.target() == &x ); + + const function& hc = h; + VERIFY( h.target() == 0 ); + VERIFY( hc.target() == &x ); +} + +int main() +{ + test06(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/7.cc b/libstdc++-v3/testsuite/20_util/function/7.cc new file mode 100644 index 000000000..3b922116b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/7.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put reference_wrappers to function pointers into function<> wrappers +void test07() +{ + using std::function; + using std::ref; + using std::cref; + + int (*fptr)(float) = truncate_float; + + function f1(ref(fptr)); + VERIFY( f1 ); + VERIFY( !!f1 ); + VERIFY( !(f1 == 0) ); + VERIFY( !(0 == f1) ); + VERIFY( f1 != 0 ); + VERIFY( 0 != f1 ); + + // Invocation + VERIFY( f1(3.1f) == 3 ); + + // target_type and target() functions + const function& f1c = f1; + VERIFY( typeid(int(*)(float)) == f1.target_type() ); + VERIFY( f1.target() != 0 ); + VERIFY( f1.target() == &fptr ); + VERIFY( f1c.target() != 0 ); + VERIFY( f1c.target() == &fptr ); + + function f2(cref(fptr)); + VERIFY( f2 ); + VERIFY( !!f2 ); + VERIFY( !(f2 == 0) ); + VERIFY( !(0 == f2) ); + VERIFY( f2 != 0 ); + VERIFY( 0 != f2 ); + + // Invocation + VERIFY( f2(3.1f) == 3 ); + + // target_type and target() functions + const function& f2c = f2; + VERIFY( typeid(int(*)(float)) == f2.target_type() ); + VERIFY( f2.target() == 0 ); + VERIFY( f2.target() == &fptr ); + VERIFY( f2c.target() != 0 ); + VERIFY( f2c.target() == &fptr ); +} + +int main() +{ + test07(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/8.cc b/libstdc++-v3/testsuite/20_util/function/8.cc new file mode 100644 index 000000000..620f61610 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/8.cc @@ -0,0 +1,148 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put reference_wrappers to member pointers +void test08() +{ + using std::function; + using std::ref; + using std::cref; + + int X::* X_bar = &X::bar; + int (X::* X_foo)() = &X::foo; + int (X::* X_foo_c)() const = &X::foo_c; + int (X::* X_foo_v)() volatile = &X::foo_v; + int (X::* X_foo_cv)() const volatile = &X::foo_cv; + + X x; + x.bar = 17; + + function frm(ref(X_bar)); + VERIFY( frm ); + VERIFY( frm(x) == 17 ); + VERIFY( typeid(int X::*) == frm.target_type() ); + VERIFY( frm.target() == &X_bar ); + + function fr(ref(X_foo)); + VERIFY( fr ); + VERIFY( fr(x) == 1 ); + VERIFY( typeid(int (X::*)()) == fr.target_type() ); + VERIFY( fr.target() == &X_foo ); + + function frc(ref(X_foo_c)); + VERIFY( frc ); + VERIFY( frc(x) == 2 ); + VERIFY( typeid(int (X::*)() const) == frc.target_type() ); + VERIFY( frc.target() == &X_foo_c ); + + function frv(ref(X_foo_v)); + VERIFY( frv ); + VERIFY( frv(x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == frv.target_type() ); + VERIFY( *frv.target() == X_foo_v ); + VERIFY( frv.target() == 0 ); + + function frcv(ref(X_foo_cv)); + VERIFY( frcv ); + VERIFY( frcv(x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == frcv.target_type() ); + VERIFY( *frcv.target() == X_foo_cv ); + VERIFY( frcv.target() == 0 ); + + function grm(ref(X_bar)); + VERIFY( grm ); + VERIFY( grm(&x) == 17 ); + VERIFY( typeid(int X::*) == grm.target_type() ); + VERIFY( *grm.target() == X_bar ); + + function gr(ref(X_foo)); + VERIFY( gr ); + VERIFY( gr(&x) == 1 ); + VERIFY( typeid(int (X::*)()) == gr.target_type() ); + VERIFY( *gr.target() == X_foo ); + + function grc(ref(X_foo_c)); + VERIFY( grc ); + VERIFY( grc(&x) == 2 ); + VERIFY( typeid(int (X::*)() const) == grc.target_type() ); + VERIFY( *grc.target() == X_foo_c ); + + function grv(ref(X_foo_v)); + VERIFY( grv ); + VERIFY( grv(&x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == grv.target_type() ); + VERIFY( *grv.target() == X_foo_v ); + VERIFY( grv.target() == 0 ); + + function grcv(ref(X_foo_cv)); + VERIFY( grcv ); + VERIFY( grcv(&x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == grcv.target_type() ); + VERIFY( *grcv.target() == X_foo_cv ); + VERIFY( grcv.target() == 0 ); + + function hrm(cref(X_bar)); + VERIFY( hrm ); + VERIFY( hrm(x) == 17 ); + VERIFY( typeid(int X::*) == hrm.target_type() ); + VERIFY( hrm.target() == 0 ); + VERIFY( hrm.target() == &X_bar ); + + function hr(cref(X_foo)); + VERIFY( hr ); + VERIFY( hr(x) == 1 ); + VERIFY( typeid(int (X::*)()) == hr.target_type() ); + VERIFY( hr.target() == &X_foo ); + + function hrc(cref(X_foo_c)); + VERIFY( hrc ); + VERIFY( hrc(x) == 2 ); + VERIFY( typeid(int (X::*)() const) == hrc.target_type() ); + VERIFY( hrc.target() == &X_foo_c ); + + function hrv(cref(X_foo_v)); + VERIFY( hrv ); + VERIFY( hrv(x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == hrv.target_type() ); + VERIFY( hrv.target() == &X_foo_v ); + VERIFY( hrv.target() == 0 ); + + function hrcv(cref(X_foo_cv)); + VERIFY( hrcv ); + VERIFY( hrcv(x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == hrcv.target_type() ); + VERIFY( hrcv.target() == &X_foo_cv ); + VERIFY( hrcv.target() == 0 ); +} + +int main() +{ + test08(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/9.cc b/libstdc++-v3/testsuite/20_util/function/9.cc new file mode 100644 index 000000000..474ce6145 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/9.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.15 polymorphic function object wrapper +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put function objects into a void-returning function<> wrapper +void test09() +{ + using std::function; + using std::ref; + using std::cref; + + int (X::*X_foo_c)() const = &X::foo_c; + function f(&X::bar); + f = &X::foo; + f = ref(X_foo_c); + f = cref(X_foo_c); + + function g = &truncate_float; + g = do_truncate_float_t(); +} + +int main() +{ + test09(); + + VERIFY( do_truncate_double_t::live_objects == 0 ); + VERIFY( do_truncate_float_t::live_objects == 0 ); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/assign/move.cc b/libstdc++-v3/testsuite/20_util/function/assign/move.cc new file mode 100644 index 000000000..a2ab96245 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/assign/move.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int f1() { return 1; } +struct { int operator()() { return 2; } } f2; + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::function function; + + function fo(f1); + function fo1; + fo1 = (std::move(fo)); + VERIFY( static_cast(fo1) ); + VERIFY( fo1() == 1 ); + + fo = function(f2); + function fo2; + fo2 = (std::move(fo)); + VERIFY( static_cast(fo2) ); + VERIFY( fo2() == 2 ); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/assign/move_target.cc b/libstdc++-v3/testsuite/20_util/function/assign/move_target.cc new file mode 100644 index 000000000..0a1c189e5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/assign/move_target.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct moveable +{ + moveable() = default; + ~moveable() = default; + // target object must be CopyConstructible, + // but should not be copied during this test + moveable(const moveable& c) { throw "copied"; } + moveable& operator=(const moveable&) = delete; + moveable(moveable&&) { } + + void operator()() const { } +}; + +void test01() +{ + std::function f; + f = moveable(); + f(); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/cmp/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/function/cmp/cmp_neg.cc new file mode 100644 index 000000000..28c0e12d1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/cmp/cmp_neg.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-prune-output "include" } + +#include + +void test01() +{ + std::function f1; + std::function f2; + f1 == f2; // { dg-error "no match" } + f1 != f2; // { dg-error "no match" } +} +// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/20_util/function/cons/move.cc b/libstdc++-v3/testsuite/20_util/function/cons/move.cc new file mode 100644 index 000000000..43d71858c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/cons/move.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int f1() { return 1; } +struct { int operator()() { return 2; } } f2; + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::function function; + + function fo(f1); + function fo1(std::move(fo)); + VERIFY( static_cast(fo1) ); + VERIFY( fo1() == 1 ); + + fo = function(f2); + function fo2(std::move(fo)); + VERIFY( static_cast(fo2) ); + VERIFY( fo2() == 2 ); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc b/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc new file mode 100644 index 000000000..2396ca101 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct moveable +{ + moveable() = default; + ~moveable() = default; + // target object must be CopyConstructible, + // but should not be copied during this test + moveable(const moveable& c) { throw "copied"; } + moveable& operator=(const moveable&) = delete; + moveable(moveable&&) { } + + void operator()() const { } +}; + +void test01() +{ + std::function f = moveable(); + f(); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/invoke/move_only.cc b/libstdc++-v3/testsuite/20_util/function/invoke/move_only.cc new file mode 100644 index 000000000..fbfb0624a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/invoke/move_only.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct moveable +{ + moveable() = default; + ~moveable() = default; + moveable(const moveable& c) = delete; + moveable& operator=(const moveable&) = delete; + moveable(moveable&&) { } +}; + +void f1(moveable) { } +void f2(moveable&&) { } +struct { void operator()(moveable&&) { } } f3; + +void test01() +{ + std::function fo1a(f1); + fo1a(moveable()); + + std::function fo2a(f2); + fo2a(moveable()); + + std::function fo3a(f3); + fo3a(moveable()); + + std::function fo1b(f1); + fo1b(moveable()); + + std::function fo2b(f2); + fo2b(moveable()); + + std::function fo3b(f3); + fo3b(moveable()); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc b/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc new file mode 100644 index 000000000..7f446d7d6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// libstdc++/40273 +int main() +{ + std::function f = 0; + if (f != 0) + { + } + + if (0 != f) + { + } + + if (f == 0) + { + } + + if (0 == f) + { + } + return 0; +} + diff --git a/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..dbd8be630 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace std +{ + template class function; +} diff --git a/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc b/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc new file mode 100644 index 000000000..bbca92716 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc @@ -0,0 +1,103 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.3.6 Binders + +// { dg-do compile } + +#include +using namespace std; + +struct s +{ + void f_void_int_const(int) const {} + void f_void_int(int) {} + int f_int_int_const(int) const { return 1; } + int f_int_int(int) {return 1; } + void f_void_void_const() const {} + void f_void_void() {} + int f_int_void_const() const { return 1; } + int f_int_void() { return 1; } +}; + +void test01(s& a) +{ + mem_fun_t p1(&s::f_void_void); + mem_fun_t p2(&s::f_int_void); + p1(&a); + p2(&a); + mem_fun1_t q1(&s::f_void_int); + mem_fun1_t q2(&s::f_int_int); + q1(&a,0); + q2(&a,0); + + (mem_fun(&s::f_void_void))(&a); + (mem_fun(&s::f_void_int))(&a,0); + (mem_fun(&s::f_int_void))(&a); + (mem_fun(&s::f_int_int))(&a,0); + + mem_fun_ref_t ref1(&s::f_void_void); + mem_fun_ref_t ref2(&s::f_int_void); + + ref1(a); + ref2(a); + + mem_fun1_ref_t ref3(&s::f_void_int); + mem_fun1_ref_t ref4(&s::f_int_int); + + ref3(a,0); + ref4(a,0); + + (mem_fun_ref(&s::f_void_void))(a); + (mem_fun_ref(&s::f_void_int))(a, 0); + (mem_fun_ref(&s::f_int_void))(a); + (mem_fun_ref(&s::f_int_int))(a, 0); +} + +void test02(const s& a) +{ + const_mem_fun_t p1(&s::f_void_void_const); + const_mem_fun_t p2(&s::f_int_void_const); + p1(&a); + p2(&a); + const_mem_fun1_t q1(&s::f_void_int_const); + const_mem_fun1_t q2(&s::f_int_int_const); + q1(&a,0); + q2(&a,0); + + (mem_fun(&s::f_void_void_const))(&a); + (mem_fun(&s::f_void_int_const))(&a, 0); + (mem_fun(&s::f_int_void_const))(&a); + (mem_fun(&s::f_int_int_const))(&a, 0); + + const_mem_fun_ref_t ref1(&s::f_void_void_const); + const_mem_fun_ref_t ref2(&s::f_int_void_const); + + ref1(a); + ref2(a); + + const_mem_fun1_ref_t ref3(&s::f_void_int_const); + const_mem_fun1_ref_t ref4(&s::f_int_int_const); + + ref3(a,0); + ref4(a,0); + + (mem_fun_ref(&s::f_void_void_const))(a); + (mem_fun_ref(&s::f_void_int_const))(a, 0); + (mem_fun_ref(&s::f_int_void_const))(a); + (mem_fun_ref(&s::f_int_int_const))(a, 0); +} diff --git a/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc b/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc new file mode 100644 index 000000000..229e56a4d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc @@ -0,0 +1,49 @@ +// 2001-06-11 Benjamin Kosnik + +// Copyright (C) 2001, 2003, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.3.6 Binders + +#include +#include // for_each +#include + +class Elem +{ +public: + void print(int) const { } + void modify(int) { } +}; + +// libstdc++/3113 +void test01() +{ + std::vector coll(2); + // OK + std::for_each(coll.begin(), coll.end(), + std::bind2nd(std::mem_fun_ref(&Elem::print), 42)); + // OK + std::for_each(coll.begin(), coll.end(), + std::bind2nd(std::mem_fun_ref(&Elem::modify), 42)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc b/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc new file mode 100644 index 000000000..fbc7c63c1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc @@ -0,0 +1,52 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.3.3 Comparisons + +#include + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator!=(const gnu_obj& rhs) const { return i != rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator!=(const gnu_t& rhs) const { return b != rhs.b; } + bool operator<(const gnu_t& rhs) const { return b == rhs.b; } + }; + +template struct std::not_equal_to; +template struct std::not_equal_to; +template struct std::not_equal_to >; + +int main() +{ + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc b/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc new file mode 100644 index 000000000..d16542d15 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc @@ -0,0 +1,41 @@ +// 2007-08-02 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 660. Missing Bitwise Operations. +void test01() +{ + bool test __attribute__((unused)) = true; + + for (int i1 = 0; i1 < 1000; ++i1) + for (int i2 = 0; i2 < 1000; ++i2) + { + VERIFY( std::bit_and()(i1, i2) == (i1 & i2) ); + VERIFY( std::bit_or()(i1, i2) == (i1 | i2) ); + VERIFY( std::bit_xor()(i1, i2) == (i1 ^ i2) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..0a4a6224b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-06-08 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_nothrow_copy_assign; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/requirements/typedefs.cc new file mode 100644 index 000000000..3781d1f9b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-06-08 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_copy_assign test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/value.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/value.cc new file mode 100644 index 000000000..0201c9cb9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_assign/value.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } +// 2010-06-08 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_copy_assign; + using namespace __gnu_test; + + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + + // Negative tests. + VERIFY( (test_property(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7c8445150 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_nothrow_copy_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..5c40837aa --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_copy_constructor test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc new file mode 100644 index 000000000..963c7bd57 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_copy_constructor; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Negative tests. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..dec9b965e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_nothrow_default_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..709fff331 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini +// +// Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_default_constructor test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc new file mode 100644 index 000000000..01548211c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_default_constructor; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Negative tests. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6ec5c5a42 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-06-08 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_trivial_copy_assign; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/typedefs.cc new file mode 100644 index 000000000..1c5f0fe7a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-06-08 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_copy_assign test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/value.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/value.cc new file mode 100644 index 000000000..7663a688a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/value.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } +// 2010-06-08 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_copy_assign; + using namespace __gnu_test; + + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + + // Negative tests. + VERIFY( (test_property(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6377f60a8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_trivial_copy_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..4b0013f7f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_copy_constructor test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc new file mode 100644 index 000000000..4f6e287b5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_copy_constructor; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Negative tests. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..2d98181d9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_trivial_default_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..40f38c34a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini +// +// Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_default_constructor test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc new file mode 100644 index 000000000..397149406 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_default_constructor; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Negative tests. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/hash/chi2_quality.cc b/libstdc++-v3/testsuite/20_util/hash/chi2_quality.cc new file mode 100644 index 000000000..8a388349b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/hash/chi2_quality.cc @@ -0,0 +1,218 @@ +// { dg-options "-std=gnu++0x" } + +// Use smaller statistics when running on simulators, so it takes less time. +// { dg-options "-std=gnu++0x -DSAMPLES=10000" { target simulator } } + +// Copyright (C) 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +// This file uses the chi^2 test to measure the quality of a hash +// function, by computing the uniformity with which it distributes a set +// of N strings into k buckets (where k is significantly greater than N). +// +// Each bucket has B[i] strings in it. The expected value of each bucket +// for a uniform distribution is z = N/k, so +// chi^2 = Sum_i (B[i] - z)^2 / z. +// +// We check whether chi^2 is small enough to be consistent with the +// hypothesis of a uniform distribution. If F(chi^2, k-1) is close to +// 0 (where F is the cumulative probability distribution), we can +// reject that hypothesis. So we don't want F to be too small, which +// for large k, means we want chi^2 to be not too much larger than k. +// +// We use the chi^2 test for several sets of strings. Any non-horrible +// hash function should do well with purely random strings. A really +// good hash function will also do well with more structured sets, +// including ones where the strings differ by only a few bits. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef SAMPLES +#define SAMPLES 300000 +#endif + +template + double + chi2_hash(const Container& c, long buckets) + { + std::vector counts(buckets); + std::hash hasher; + double elements = 0; + for (auto i = c.begin(); i != c.end(); ++i) + { + ++counts[hasher(*i) % buckets]; + ++elements; + } + + const double z = elements / buckets; + double sum = 0; + for (long i = 0; i < buckets; ++i) + { + double delta = counts[i] - z; + sum += delta*delta; + } + return sum/z; + } + +// Tests chi^2 for a distribution of uniformly generated random strings. +void +test_uniform_random() +{ + bool test __attribute__((unused)) = true; + std::srand(137); + std::unordered_set set; + std::string s; + const unsigned long N = SAMPLES; + const unsigned long k = N/100; + const unsigned int len = 25; + while (set.size() < N) + { + s.clear(); + for (unsigned int i = 0; i < len; ++i) + s.push_back(rand() % 128); + set.insert(s); + } + + double chi2 = chi2_hash(set, k); + VERIFY( chi2 < k*1.1 ); +} + +// Tests chi^2 for a distribution of strings that differ from each +// other by only a few bits. We start with an arbitrary base string, and +// flip three random bits for each member of the set. +void +test_bit_flip_set() +{ + bool test __attribute__((unused)) = true; + const unsigned long N = SAMPLES; + const unsigned long k = N/100; + const unsigned int len = 67; + const unsigned int bitlen = len * 8; + const unsigned int bits_to_flip = 3; + const char base[len+1] = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789!@#$%"; + + std::unordered_set set; + while (set.size() < N) + { + std::string s(base, base+len); + for (unsigned int i = 0; i < bits_to_flip; ++i) + { + int bit = rand() % bitlen; + s[bit/8] ^= (1 << (bit%8)); + } + set.insert(s); + } + + double chi2 = chi2_hash(set, k); + VERIFY( chi2 < k*1.1 ); +} + +// Tests chi^2 of a set of strings that all have a similar pattern, +// intended to mimic some sort of ID string. +void +test_numeric_pattern_set() +{ + bool test __attribute__((unused)) = true; + const unsigned long N = SAMPLES; + const unsigned long k = N/100; + std::vector set; + for (unsigned long i = 0; i < N; ++i) + { + long i1 = i % 100000; + long i2 = i / 100000; + char buf[16]; + std::sprintf(buf, "XX-%05lu-%05lu", i1, i2); + set.push_back(buf); + } + + double chi2 = chi2_hash(set, k); + VERIFY( chi2 < k*1.1 ); +} + +// Tests chi^2 for a set of strings that all consist of '1' and '0'. +void +test_bit_string_set() +{ + bool test __attribute__((unused)) = true; + const unsigned long N = SAMPLES; + const unsigned long k = N/100; + std::vector set; + std::string s; + for (unsigned long i = 0; i < N; ++i) + { + s.clear(); + for (unsigned int j = 0; j < sizeof(unsigned long) * 8; ++j) + { + const bool bit = (1UL << j) & i; + s.push_back(bit ? '1' : '0'); + } + set.push_back(s); + } + + double chi2 = chi2_hash(set, k); + VERIFY( chi2 < k*1.1 ); +} + +// Tests chi^2 for a set of words taken from a document written in English. +void +test_document_words() +{ + // That file is 187587 single-word lines. To avoid a timeout, just skip + // this part, which would take up to 95% of the program runtime (with + // SAMPLES == 10000), if we're not supposed to run anywhere that long. +#if SAMPLES >= 100000 + bool test __attribute__((unused)) = true; + const std::string f_name = "thirty_years_among_the_dead_preproc.txt"; + std::ifstream in(f_name); + VERIFY( in.is_open() ); + std::vector words; + words.assign(std::istream_iterator(in), + std::istream_iterator()); + VERIFY( words.size() > 100000 ); + std::sort(words.begin(), words.end()); + auto it = std::unique(words.begin(), words.end()); + words.erase(it, words.end()); + VERIFY( words.size() > 5000 ); + + const unsigned long k = words.size() / 20; + double chi2 = chi2_hash(words, k); + VERIFY( chi2 < k*1.1 ); +#endif +} + +int +main() +{ + test_uniform_random(); + test_bit_flip_set(); + test_numeric_pattern_set(); + test_bit_string_set(); + test_document_words(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc b/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc new file mode 100644 index 000000000..af0c54ec4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// 2007-08-20 +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +template + void + do_test() + { + bool test __attribute__((unused)) = true; + + typedef T value_type; + typedef std::hash hash_type; + using std::size_t; + + value_type v; // default initialized is fine, same value all that matters. + hash_type h1; + size_t r1 = size_t(h1(v)); + + hash_type h2; + size_t r2 = size_t(h2(v)); + + VERIFY( r1 == r2 ); + } + +void test01() +{ + do_test(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/hash/quality.cc b/libstdc++-v3/testsuite/20_util/hash/quality.cc new file mode 100644 index 000000000..0bc263724 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/hash/quality.cc @@ -0,0 +1,172 @@ +// { dg-options "-std=gnu++0x" } +// { dg-options "-DNTESTS=1 -DNSTRINGS=100 -DSTRSIZE=21 -std=gnu++0x" { target simulator } } + +// Copyright (C) 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include +#include +#include + +using namespace std; + +#ifndef NTESTS +#define NTESTS 5 +#endif +#ifndef NSTRINGS +#define NSTRINGS 200 +#endif +#ifndef STRSIZE +#define STRSIZE 42 +#endif + +const unsigned int num_quality_tests = NTESTS; +const unsigned int num_strings_for_quality_tests = NSTRINGS; +const unsigned int string_size = STRSIZE; + +vector +random_strings(unsigned int n, unsigned int len) +{ + string s(len, '\0'); + unordered_set result_set; + while (result_set.size() < n) + { + result_set.insert(s); + unsigned int tmp = rand(); + tmp %= len * 256; + s[tmp / 256] = tmp % 256; + } + return vector(result_set.begin(), result_set.end()); +} + +double +score_from_varying_position(string s, unsigned int index) +{ + bool test __attribute__((unused)) = true; + unsigned int bits_in_hash_code = sizeof(size_t) * 8; + + // We'll iterate through all 256 vals for s[index], leaving the rest + // of s fixed. Then, for example, out of the 128 times that + // s[index] has its 3rd bit equal to 0 we would like roughly half 1s + // and half 0s in bit 9 of the hash codes. + // + // Bookkeeping: Conceptually we want a 3D array of ints. We want to + // count the number of times each output position (of which there are + // bits_in_hash_code) is 1 for each bit position within s[index] (of + // which there are 8) and value of that bit (of which there are 2). + const unsigned int jj = 2; + const unsigned int kk = jj * bits_in_hash_code; + const unsigned int array_size = 8 * kk; + vector ones(array_size, 0); + + for (int i = 0; i < 256; i++) + { + s[index] = i; + size_t h = hash()(s); + for (int j = 0; h != 0; j++, h >>= 1) + { + if (h & 1) + { + for (int k = 0; k < 8; k++) + ++ones[k * kk + j * jj + ((i >> k) & 1)]; + } + } + } + + // At most, the innermost statement in the above loop nest can + // execute 256 * bits_in_hash_code * 8 times. If the hash is good, + // it'll execute about half that many times, with a pretty even + // spread across the elements of ones[]. + VERIFY( 256 * bits_in_hash_code * 8 / array_size == 128 ); + int max_ones_possible = 128; + int good = 0, bad = 0; + for (int bit = 0; bit <= 1; bit++) + { + for (unsigned int j = 0; j < bits_in_hash_code; j++) + { + for (int bitpos = 0; bitpos < 8; bitpos++) + { + int z = ones[bitpos * kk + j * jj + bit]; + if (z <= max_ones_possible / 6 + || z >= max_ones_possible * 5 / 6) + { + // The hash function screwed up, or was just unlucky, + // as 128 flips of a perfect coin occasionally yield + // far from 64 heads. + bad++; + } + else + good++; + } + } + } + return good / (double)(good + bad); +} + +double +score_from_varying_position(const vector& v, unsigned int index) +{ + double score = 0; + for (unsigned int i = 0; i < v.size(); i++) + score += score_from_varying_position(v[i], index); + return score / v.size(); +} + +double +quality_test(unsigned int num_strings, unsigned int string_size) +{ + // Construct random strings. + vector v = random_strings(num_strings, string_size); + double sum_of_scores = 0; + for (unsigned int i = 0; i < string_size; i++) + sum_of_scores += score_from_varying_position(v, i); + + // A good hash function should have a score very close to 1, and a bad + // hash function will have a score close to 0. + return sum_of_scores / string_size; +} + +void +quality_test() +{ + bool test __attribute__((unused)) = true; + srand(137); + double sum_of_scores = 0; + for (unsigned int i = 0; i < num_quality_tests; i++) + { + double score = quality_test(num_strings_for_quality_tests, + string_size); + sum_of_scores += score; + VERIFY( score > 0.99 ); + } + + if (num_quality_tests > 1) + { + double mean_quality = sum_of_scores / num_quality_tests; + VERIFY( mean_quality > 0.9999 ); + } +} + +int +main() +{ + quality_test(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..9c71a5fc9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// Verify that we can instantiate hash for every required type. +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; +template class std::hash; + +#ifdef _GLIBCXX_USE_WCHAR_T +template class std::hash; +template class std::hash; +#endif + diff --git a/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc b/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc new file mode 100644 index 000000000..ad25a7f5e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc @@ -0,0 +1,28 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using std::calloc; + using std::malloc; + using std::free; + using std::realloc; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc b/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc new file mode 100644 index 000000000..34bc2b945 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using std::memchr; + using std::memcmp; + using std::memcpy; + using std::memmove; + using std::memset; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc b/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc new file mode 100644 index 000000000..d85767dd5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ +#ifndef NULL + #error "NULL_must_be_a_macro" +#endif +} diff --git a/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc b/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc new file mode 100644 index 000000000..306d2547b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + std::size_t s; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc b/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc new file mode 100644 index 000000000..baba33fc8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc @@ -0,0 +1,33 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using std::asctime; + using std::clock; + using std::difftime; + using std::localtime; + using std::strftime; + using std::ctime; + using std::gmtime; + using std::mktime; + using std::time; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc b/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc new file mode 100644 index 000000000..0633aa2f8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ +#ifndef NULL + #error "NULL_must_be_a_macro" +#endif +} diff --git a/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc b/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc new file mode 100644 index 000000000..db7bb7ff1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + std::size_t s; + std::clock_t c; + std::time_t t; + + std::tm t2; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc new file mode 100644 index 000000000..b58314466 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc @@ -0,0 +1,100 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace std { + // lib.base, base: + template struct unary_function; + template struct binary_function; + + // lib.arithmetic.operations, arithmetic operations: + template struct plus; + template struct minus; + template struct multiplies; + template struct divides; + template struct modulus; + template struct negate; + + // lib.comparisons, comparisons: + template struct equal_to; + template struct not_equal_to; + template struct greater; + template struct less; + template struct greater_equal; + template struct less_equal; + + // lib.logical.operations, logical operations: + template struct logical_and; + template struct logical_or; + template struct logical_not; + + // lib.negators, negators: + template struct unary_negate; + template + unary_negate not1(const Predicate&); + template struct binary_negate; + template + binary_negate not2(const Predicate&); + + // lib.binders, binders: + template class binder1st; + template + binder1st bind1st(const Operation&, const T&); + template class binder2nd; + template + binder2nd bind2nd(const Operation&, const T&); + + // lib.function.pointer.adaptors, adaptors: + template class pointer_to_unary_function; + template + pointer_to_unary_function ptr_fun(Result (*)(Arg)); + template + class pointer_to_binary_function; + template + pointer_to_binary_function + ptr_fun(Result (*)(Arg1,Arg2)); + + // lib.member.pointer.adaptors, adaptors: + template class mem_fun_t; + template class mem_fun1_t; + template + mem_fun_t mem_fun(S (T::*f)()); + template + mem_fun1_t mem_fun(S (T::*f)(A)); + template class mem_fun_ref_t; + template class mem_fun1_ref_t; + template + mem_fun_ref_t mem_fun_ref(S (T::*f)()); + template + mem_fun1_ref_t mem_fun_ref(S (T::*f)(A)); + + template class const_mem_fun_t; + template class const_mem_fun1_t; + template + const_mem_fun_t mem_fun(S (T::*f)() const); + template + const_mem_fun1_t mem_fun(S (T::*f)(A) const); + template class const_mem_fun_ref_t; + template class const_mem_fun1_ref_t; + template + const_mem_fun_ref_t mem_fun_ref(S (T::*f)() const); + template + const_mem_fun1_ref_t mem_fun_ref(S (T::*f)(A) const); +} diff --git a/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc b/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc new file mode 100644 index 000000000..264542811 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using std::bad_function_call; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc b/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc new file mode 100644 index 000000000..5d2a7a863 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using namespace std::placeholders; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc new file mode 100644 index 000000000..4d45071e6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc @@ -0,0 +1,53 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace std { + // lib.default.allocator, the default allocator: + template class allocator; + template <> class allocator; + template + bool operator==(const allocator&, const allocator&) throw(); + template + bool operator!=(const allocator&, const allocator&) throw(); + + // lib.storage.iterator, raw storage iterator: + template class raw_storage_iterator; + + // lib.temporary.buffer, temporary buffers: + template + pair get_temporary_buffer(ptrdiff_t n); + template + void return_temporary_buffer(T* p); + + // lib.specialized.algorithms, specialized algorithms: + template + ForwardIterator + uninitialized_copy(InputIterator first, InputIterator last, + ForwardIterator result); + template + void uninitialized_fill(ForwardIterator first, ForwardIterator last, + const T& x); + template + void uninitialized_fill_n(ForwardIterator first, Size n, const T& x); + + // lib.auto.ptr, pointers: + template class auto_ptr; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc b/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc new file mode 100644 index 000000000..dc50b63bb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using std::bad_weak_ptr; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc b/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc new file mode 100644 index 000000000..4fd554e35 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc new file mode 100644 index 000000000..0fc1ce295 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using std::true_type; + using std::false_type; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc new file mode 100644 index 000000000..5ada352ec --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + // C++0x changes from TR1. + using std::has_trivial_constructor; + using std::has_nothrow_constructor; + using std::has_trivial_copy; + using std::has_nothrow_copy; +} + +// { dg-error "has not been declared" "" { target *-*-* } 26 } +// { dg-error "has not been declared" "" { target *-*-* } 27 } +// { dg-error "has not been declared" "" { target *-*-* } 28 } +// { dg-error "has not been declared" "" { target *-*-* } 29 } + diff --git a/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc new file mode 100644 index 000000000..aea7bb3bf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc @@ -0,0 +1,45 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace std { + // lib.operators, operators: + namespace rel_ops { + template bool operator!=(const T&, const T&); + template bool operator> (const T&, const T&); + template bool operator<=(const T&, const T&); + template bool operator>=(const T&, const T&); + } + + // lib.pairs, pairs: + template struct pair; + template + _GLIBCXX_CONSTEXPR bool operator==(const pair&, const pair&); + template + _GLIBCXX_CONSTEXPR bool operator< (const pair&, const pair&); + template + _GLIBCXX_CONSTEXPR bool operator!=(const pair&, const pair&); + template + _GLIBCXX_CONSTEXPR bool operator> (const pair&, const pair&); + template + _GLIBCXX_CONSTEXPR bool operator>=(const pair&, const pair&); + template + _GLIBCXX_CONSTEXPR bool operator<=(const pair&, const pair&); +} diff --git a/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc b/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc new file mode 100644 index 000000000..60753a00f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using namespace std::rel_ops; +} diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..356f73cac --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-12-30 Paolo Carlini + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_constructible; +} diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..4b9ecd9e1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_constructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-12-30 Paolo Carlini +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_constructible test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/value.cc b/libstdc++-v3/testsuite/20_util/is_constructible/value.cc new file mode 100644 index 000000000..280710beb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_constructible/value.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_constructible; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + + // Negative tests. + VERIFY( (test_property(false)) ); + VERIFY( (test_property(false)) ); + VERIFY( (test_property(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..646c4b25b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_convertible; +} diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc new file mode 100644 index 000000000..1e8deb511 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_convertible test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/value.cc b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc new file mode 100644 index 000000000..f6282a901 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-10-29 Paolo Carlini +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_convertible; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + + VERIFY( (test_relationship(true)) ); + + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + + // Negative tests. + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + + // C++0x + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..87dd950b2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-12-30 Paolo Carlini + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_explicitly_convertible; +} diff --git a/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/requirements/typedefs.cc new file mode 100644 index 000000000..52ba964b1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-12-30 Paolo Carlini +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_explicitly_convertible test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/value.cc b/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/value.cc new file mode 100644 index 000000000..7e7048732 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_explicitly_convertible/value.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_explicitly_convertible; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + + // Negative tests. + VERIFY( (test_relationship(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..a294d097b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2008-05-20 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_integral; +} diff --git a/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc new file mode 100644 index 000000000..43bac85ee --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-20 Paolo Carlini +// +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_integral test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_integral/value.cc b/libstdc++-v3/testsuite/20_util/is_integral/value.cc new file mode 100644 index 000000000..6b1717b38 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_integral/value.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-20 Paolo Carlini +// +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_integral; + using namespace __gnu_test; + + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category(true)) ); +#endif + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6669a1e89 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_literal_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc new file mode 100644 index 000000000..25bc88f29 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_literal_type test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc b/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc new file mode 100644 index 000000000..77a6902b7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-23 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_literal_type; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..09ae91219 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_lvalue_reference; +} diff --git a/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000..348b59936 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_lvalue_reference test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc b/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc new file mode 100644 index 000000000..f57713585 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_lvalue_reference; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..37ba9eb8b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-06-09 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_nothrow_constructible; +} diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..53a64a78f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-06-09 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_nothrow_constructible test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value.cc new file mode 100644 index 000000000..b3246fad1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-09 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_nothrow_constructible; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + VERIFY( (test_property(true)) ); + + // Negative tests. + VERIFY( (test_property(false)) ); + VERIFY( (test_property + (false)) ); + VERIFY( (test_property(false)) ); + VERIFY( (test_property(false)) ); + VERIFY( (test_property + (false)) ); + VERIFY( (test_property(false)) ); + + VERIFY( (test_property(false)) ); + VERIFY( (test_property(false)) ); + VERIFY( (test_property(false)) ); + VERIFY( (test_property(false)) ); + VERIFY( (test_property(false)) ); + VERIFY( (test_property(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..241cff719 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_pod; +} diff --git a/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc new file mode 100644 index 000000000..9c02b99e9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_pod test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_pod/value.cc b/libstdc++-v3/testsuite/20_util/is_pod/value.cc new file mode 100644 index 000000000..e4926d5a6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_pod/value.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_pod; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..faf66d772 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_reference; +} diff --git a/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc new file mode 100644 index 000000000..ff572915f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_reference test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_reference/value.cc b/libstdc++-v3/testsuite/20_util/is_reference/value.cc new file mode 100644 index 000000000..a6782ab9a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_reference/value.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_reference; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..336881339 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_rvalue_reference; +} diff --git a/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000..b7523bb8d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_rvalue_reference test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc b/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc new file mode 100644 index 000000000..1e83d0514 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_rvalue_reference; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..1ff9ddc74 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_scalar; +} diff --git a/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc new file mode 100644 index 000000000..b2d0dd17c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// 2010-11-30 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +void test01() +{ + // Check for required typedefs + typedef std::is_scalar test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_scalar/value.cc b/libstdc++-v3/testsuite/20_util/is_scalar/value.cc new file mode 100644 index 000000000..7d6521ed6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_scalar/value.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// 2010-11-30 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_scalar; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d64ce7e40 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_signed; +} diff --git a/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc new file mode 100644 index 000000000..6706c60bf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_signed test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_signed/value.cc b/libstdc++-v3/testsuite/20_util/is_signed/value.cc new file mode 100644 index 000000000..194e268b6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_signed/value.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_signed; + using namespace __gnu_test; + + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(char(-1) < char(0))) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(false)) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category(wchar_t(-1) < wchar_t(0))) ); +#endif + VERIFY( (test_category(true)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc new file mode 100644 index 000000000..619dc3e6b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_standard_layout; +} diff --git a/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc new file mode 100644 index 000000000..e209101e4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_standard_layout test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc b/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc new file mode 100644 index 000000000..7ef860906 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-23 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_standard_layout; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..043d12230 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_trivial; +} diff --git a/libstdc++-v3/testsuite/20_util/is_trivial/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_trivial/requirements/typedefs.cc new file mode 100644 index 000000000..4b8047f5c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_trivial/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_trivial test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_trivial/value.cc b/libstdc++-v3/testsuite/20_util/is_trivial/value.cc new file mode 100644 index 000000000..e6ff8fac5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_trivial/value.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-23 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_trivial; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..52b8406e2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_unsigned; +} diff --git a/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc new file mode 100644 index 000000000..3538edca7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_unsigned test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc b/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc new file mode 100644 index 000000000..5163cf975 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini +// +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_unsigned; + using namespace __gnu_test; + + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(char(-1) > char(0))) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(true)) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category(wchar_t(-1) > wchar_t(0))) ); +#endif + VERIFY( (test_category(false)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..77061d5b4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct make_signed; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc new file mode 100644 index 000000000..6c21a1e75 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_signed; + using std::is_same; + using std::is_signed; + + // Positive tests. + typedef make_signed::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test22_type; + VERIFY( (is_same::value) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_signed::type test23_type; + VERIFY( (is_same::value) ); +#endif + + // Chapter 48, chapter 20. Smallest rank such that new signed type same size. + typedef make_signed::type test25_type; + VERIFY( is_signed::value ); + VERIFY( sizeof(test25_type) == sizeof(test_enum) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc new file mode 100644 index 000000000..cb40b7bff --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" } +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// Ensure that this enum has "short" as its underlying type. +enum test_enum { first_selection = ((unsigned char)-1) + 1 }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_signed; + using std::is_same; + + // Positive tests. + typedef make_signed::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test22_type; + VERIFY( (is_same::value) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_signed::type test23_type; + VERIFY( (is_same::value) ); +#endif + + typedef make_signed::type test25_type; + VERIFY( (is_same::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc new file mode 100644 index 000000000..5179abfeb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_signed; + + // Negative tests. + typedef make_signed::type test1_type; + + typedef make_signed<__gnu_test::pod_uint>::type test2_type; + + typedef make_signed::type test3_type; + + typedef void (fn_type) (); + typedef make_signed::type test4_type; + + typedef make_signed::type test5_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 33 } +// { dg-error "instantiated from here" "" { target *-*-* } 35 } +// { dg-error "instantiated from here" "" { target *-*-* } 37 } +// { dg-error "instantiated from here" "" { target *-*-* } 40 } +// { dg-error "instantiated from here" "" { target *-*-* } 42 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1097 } +// { dg-error "declaration of" "" { target *-*-* } 1061 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7821dd7ae --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct make_unsigned; +} diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc new file mode 100644 index 000000000..9d96d5b89 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_unsigned; + using std::is_same; + using std::is_unsigned; + + // Positive tests. + typedef make_unsigned::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test22_type; + VERIFY( (is_same::value) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_unsigned::type test23_type; + VERIFY( (is_same::value) ); +#endif + + // Chapter 48, chapter 20. Smallest rank such that new unsigned type + // same size. + typedef make_unsigned::type test25_type; + VERIFY( is_unsigned::value ); + VERIFY( sizeof(test25_type) == sizeof(test_enum) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc new file mode 100644 index 000000000..d71c01282 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" } +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux*eabi } } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// Ensure that this enum has "short" as its underlying type. +enum test_enum { first_selection = ((unsigned char)-1) + 1 }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_unsigned; + using std::is_same; + + // Positive tests. + typedef make_unsigned::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test22_type; + VERIFY( (is_same::value) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_unsigned::type test23_type; + VERIFY( (is_same::value) ); +#endif + + typedef make_unsigned::type test25_type; + VERIFY( (is_same::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc new file mode 100644 index 000000000..1a1724d74 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_unsigned; + + // Negative tests. + typedef make_unsigned::type test1_type; + + typedef make_unsigned<__gnu_test::pod_uint>::type test2_type; + + typedef make_unsigned::type test3_type; + + typedef void (fn_type) (); + typedef make_unsigned::type test4_type; + + typedef make_unsigned::type test5_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 33 } +// { dg-error "instantiated from here" "" { target *-*-* } 35 } +// { dg-error "instantiated from here" "" { target *-*-* } 37 } +// { dg-error "instantiated from here" "" { target *-*-* } 40 } +// { dg-error "instantiated from here" "" { target *-*-* } 42 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1020 } +// { dg-error "declaration of" "" { target *-*-* } 984 } diff --git a/libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc b/libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc new file mode 100644 index 000000000..34477ea18 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/monotonic_clock/constexpr_data.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_member_data + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::is_monotonic; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + test.operator()(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/move/1.cc b/libstdc++-v3/testsuite/20_util/move/1.cc new file mode 100644 index 000000000..bb7b4e601 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/move/1.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +template + std::shared_ptr + factory(A1&& a1) + { + return std::shared_ptr(new T(std::forward(a1))); + } + +struct A +{ + A(); + A(const A&); + A(A&&); +}; + +void g() +{ + A a; + std::shared_ptr sp1 = factory(a); + std::shared_ptr sp2 = factory(std::move(a)); +} diff --git a/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..53b4e9bb8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-07-10 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing utility with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template std::remove_reference::type&& move(test_type&&); +} diff --git a/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc b/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc new file mode 100644 index 000000000..e1524cc18 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc @@ -0,0 +1,135 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.13.4 Template class owner_less [util.smartptr.ownerless] + +#include +#include +#include + +struct A { }; + +struct B { A a[2]; }; + +// 20.8.13.4 Template class owner_less [util.smartptr.ownerless] + +int +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty shared_ptrs compare equivalent + std::owner_less> less; + std::owner_less> wless; + std::shared_ptr p1; + std::shared_ptr p2; + VERIFY( !less(p1, p2) && !less(p2, p1) ); + std::weak_ptr p3; + VERIFY( !less(p1, p3) && !less(p3, p1) ); + VERIFY( !wless(p1, p3) && !wless(p3, p1) ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::owner_less> less; + std::owner_less> wless; + + std::shared_ptr empty; + + std::shared_ptr a1(new A); + VERIFY( less(empty, a1) || less(a1, empty) ); + + std::shared_ptr a2(new A); + VERIFY( less(a1, a2) || less(a2, a1) ); + + std::weak_ptr w1(a1); + VERIFY( !less(a1, w1) && !less(w1, a1) ); + + std::weak_ptr w2(a2); + VERIFY( wless(w1, w2) || wless(w2, w1) ); + + a1.reset(); + VERIFY( !less(empty, a1) && !less(a1, empty) ); + VERIFY( less(a1, w1) || less(w1, a1) ); + + a2.reset(); + VERIFY( !less(a2, a1) && !less(a1, a2) ); + + return 0; +} + +// aliasing +int +test03() +{ + bool test __attribute__((unused)) = true; + + std::owner_less> less; + std::owner_less> wless; + + std::shared_ptr b(new B); + std::shared_ptr a0(b, &b->a[0]); + std::shared_ptr a1(b, &b->a[1]); + // values are different but owners are equivalent: + VERIFY( a0 < a1 && !less(a0, a1) && !less(a1, a0) ); + + std::weak_ptr w0(a0); + std::weak_ptr w1(a1); + VERIFY( !wless(w0, w1) && !wless(w1, w0) ); + VERIFY( !less(a0, w1) && !less(w1, a0) ); + VERIFY( !wless(w0, a1) && !wless(a1, w0) ); + + return 0; +} + +// strict weak ordering +int +test04() +{ + bool test __attribute__((unused)) = true; + + std::owner_less> less; + + std::shared_ptr a[3]; + a[0].reset(new A); + a[1].reset(new A); + a[2].reset(new A); + std::sort(a, a+3, less); + VERIFY( !less(a[0], a[0]) ); + VERIFY( less(a[0], a[1]) && !less(a[1], a[0]) ); + VERIFY( less(a[0], a[1]) && less(a[1], a[2]) && less(a[0], a[2]) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/1.cc b/libstdc++-v3/testsuite/20_util/pair/1.cc new file mode 100644 index 000000000..f5b15f755 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/1.cc @@ -0,0 +1,78 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.2 Pairs + +#include +#include + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + + +// heterogeneous +void test01() +{ + bool test __attribute__((unused)) = true; + + std::pair p_bl_1(true, 433); + std::pair p_bl_2 = std::make_pair(true, 433); + VERIFY( p_bl_1 == p_bl_2 ); + VERIFY( !(p_bl_1 < p_bl_2) ); + + std::pair p_sf_1("total enlightenment", 433.00); + std::pair p_sf_2 = std::make_pair("total enlightenment", + 433.00); + VERIFY( p_sf_1 == p_sf_2 ); + VERIFY( !(p_sf_1 < p_sf_2) ); + + std::pair p_sg_1("enlightenment", gnu_obj(5)); + std::pair p_sg_2 = std::make_pair("enlightenment", + gnu_obj(5)); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + std::pair, gnu_obj> p_st_1(gnu_t(false), gnu_obj(5)); + std::pair, gnu_obj> p_st_2 = std::make_pair(gnu_t(false), + gnu_obj(5)); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/2.cc b/libstdc++-v3/testsuite/20_util/pair/2.cc new file mode 100644 index 000000000..0826cdb2f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/2.cc @@ -0,0 +1,59 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.2 Pairs + +#include +#include + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + +// homogeneous +void test02() +{ + bool test __attribute__((unused)) = true; + + std::pair p_bb_1(true, false); + std::pair p_bb_2 = std::make_pair(true, false); + VERIFY( p_bb_1 == p_bb_2 ); + VERIFY( !(p_bb_1 < p_bb_2) ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/3.cc b/libstdc++-v3/testsuite/20_util/pair/3.cc new file mode 100644 index 000000000..fc19a4acd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/3.cc @@ -0,0 +1,78 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.2 Pairs + +#include +#include + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + + +// const +void test03() +{ + bool test __attribute__((unused)) = true; + + const std::pair p_bl_1(true, 433); + const std::pair p_bl_2 = std::make_pair(true, 433); + VERIFY( p_bl_1 == p_bl_2 ); + VERIFY( !(p_bl_1 < p_bl_2) ); + + const std::pair p_sf_1("total enlightenment", 433.00); + const std::pair p_sf_2 = + std::make_pair("total enlightenment", 433.00); + VERIFY( p_sf_1 == p_sf_2 ); + VERIFY( !(p_sf_1 < p_sf_2) ); + + const std::pair p_sg_1("enlightenment", gnu_obj(5)); + const std::pair p_sg_2 = + std::make_pair("enlightenment", gnu_obj(5)); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + const std::pair, gnu_obj> p_st_1(gnu_t(false), gnu_obj(5)); + const std::pair, gnu_obj> p_st_2 = + std::make_pair(gnu_t(false), gnu_obj(5)); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/4.cc b/libstdc++-v3/testsuite/20_util/pair/4.cc new file mode 100644 index 000000000..7431fc1e7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/4.cc @@ -0,0 +1,66 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.2 Pairs + +#include +#include + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + +// const& +void test04() +{ + bool test __attribute__((unused)) = true; + const gnu_obj& obj1 = gnu_obj(5); + const std::pair p_sg_1("enlightenment", obj1); + const std::pair p_sg_2 = + std::make_pair("enlightenment", obj1); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + const gnu_t& tmpl1 = gnu_t(false); + const std::pair, gnu_obj> p_st_1(tmpl1, obj1); + const std::pair, gnu_obj> p_st_2 = std::make_pair(tmpl1, obj1); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/40925.cc b/libstdc++-v3/testsuite/20_util/pair/40925.cc new file mode 100644 index 000000000..6abeb617f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/40925.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct X +{ + explicit X(int, int) { } + +private: + X(const X&) = delete; +}; + +struct move_only +{ + move_only() { } + move_only(move_only&&) { } + +private: + move_only(const move_only&) = delete; +}; + +// libstdc++/40925 +void test01() +{ + int *ip = 0; + int X::*mp = 0; + + std::pair p1(0, 0); + std::pair p2(ip, 0); + std::pair p3(0, ip); + std::pair p4(ip, ip); + + std::pair p5(0, 0); + std::pair p6(mp, 0); + std::pair p7(0, mp); + std::pair p8(mp, mp); + + std::pair p9(0, move_only()); + std::pair p10(0, move_only()); + std::pair p11(move_only(), 0); + std::pair p12(move_only(), 0); + + std::pair p13(ip, move_only()); + std::pair p14(mp, move_only()); + std::pair p15(move_only(), ip); + std::pair p16(move_only(), mp); + + std::pair p17(move_only(), move_only()); +} diff --git a/libstdc++-v3/testsuite/20_util/pair/44487.cc b/libstdc++-v3/testsuite/20_util/pair/44487.cc new file mode 100644 index 000000000..833d98645 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/44487.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +int x, y; + +std::pair +foo1() +{ + std::pair blah(x, y); + return blah; +} + +std::pair +foo2() +{ + const std::pair blah(x, y); + return blah; +} + +std::pair +foo3() +{ + std::pair blah(x, y); + return std::pair(std::move(blah)); +} + +std::pair +foo4() +{ + const std::pair blah(x, y); + return std::pair(std::move(blah)); +} diff --git a/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc new file mode 100644 index 000000000..d5dc6e4e1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_comparison_operators test; + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc new file mode 100644 index 000000000..1c854627e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator(), std::pair>(); + test2.operator(), std::pair>(); + + // test 3 + const int i1(129); + const int i2(6); + constexpr std::pair p3(i1, i2); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/moveable.cc b/libstdc++-v3/testsuite/20_util/pair/moveable.cc new file mode 100644 index 000000000..9abdd8107 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/moveable.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on pair, and also vector. If the implementation +// changes this test may begin to fail. + +#include +#include +#include + +bool test __attribute__((unused)) = true; + +void +test1() +{ + std::pair a(1,1),b(2,2); + a=std::move(b); + VERIFY(a.first == 2 && a.second == 2 && b.first == 2 && b.second == 2); + std::pair c(std::move(a)); + VERIFY(c.first == 2 && c.second == 2 && a.first == 2 && a.second == 2); +} + +void +test2() +{ + std::vector v,w; + v.push_back(1); + w.push_back(2); + w.push_back(2); + std::pair > p = make_pair(1,v); + std::pair > q = make_pair(2,w); + p = std::move(q); + VERIFY(p.first == 2 && q.first == 2 && + p.second.size() == 2 && q.second.size() == 0); + std::pair > r(std::move(p)); + VERIFY(r.first == 2 && p.first == 2 && + r.second.size() == 2 && p.second.size() == 0); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/20_util/pair/piecewise.cc b/libstdc++-v3/testsuite/20_util/pair/piecewise.cc new file mode 100644 index 000000000..ef7147320 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/piecewise.cc @@ -0,0 +1,98 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-04-30 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +struct type_zero +{ + type_zero() : n_(757) { } + + type_zero(const type_zero&) = delete; + type_zero(type_zero&& other) : n_(other.n_) { } + + int get() const { return n_; } + +private: + int n_; +}; + +struct type_one +{ + type_one(int n) : n_(n) { } + + type_one(const type_one&) = delete; + type_one(type_one&& other) : n_(other.n_) { } + + int get() const { return n_; } + +private: + int n_; +}; + +struct type_two +{ + type_two(int n1, int n2) : n1_(n1), n2_(n2) { } + + type_two(const type_two&) = delete; + type_two(type_two&& other) : n1_(other.n1_), n2_(other.n2_) { } + + int get1() const { return n1_; } + int get2() const { return n2_; } + +private: + int n1_, n2_; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::pair pp0(std::piecewise_construct_t(), + std::forward_as_tuple(-3), + std::forward_as_tuple()); + VERIFY( pp0.first.get() == -3 ); + VERIFY( pp0.second.get() == 757 ); + + std::pair pp1(std::piecewise_construct_t(), + std::forward_as_tuple(6), + std::forward_as_tuple(5, 4)); + VERIFY( pp1.first.get() == 6 ); + VERIFY( pp1.second.get1() == 5 ); + VERIFY( pp1.second.get2() == 4 ); + + std::pair pp2(std::piecewise_construct_t(), + std::forward_as_tuple(2, 1), + std::forward_as_tuple(-1, -3)); + VERIFY( pp2.first.get1() == 2 ); + VERIFY( pp2.first.get2() == 1 ); + VERIFY( pp2.second.get1() == -1 ); + VERIFY( pp2.second.get2() == -3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc b/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc new file mode 100644 index 000000000..36d380dcf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 801, pair and tuple vs. "passed in registers" +void test_trivial() +{ + // PODType, TType, NType, SLType, LType, NLType, LTypeDerived + typedef std::pair pair_type; + // static_assert(std::is_literal_type::value, "! literal"); + static_assert(std::has_trivial_copy_constructor::value, + "! triv copy"); + static_assert(std::has_trivial_destructor::value, + "! triv destructor"); + // static_assert(std::is_standard_layout::value, + // "! standard layout"); + + // Negative + /* + static_assert(std::has_trivial_default_constructor::value, + "! triv default"); + static_assert(std::has_trivial_copy_assign::value, + "! triv assign"); + static_assert(std::is_trivial::value, "! triv"); + static_assert(std::is_pod::value, "! pod"); + */ +} + +int main() +{ + test_trivial(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..262c575cf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers. + +#include + +template class std::pair; diff --git a/libstdc++-v3/testsuite/20_util/pair/swap.cc b/libstdc++-v3/testsuite/20_util/pair/swap.cc new file mode 100644 index 000000000..a76f5f3cb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/swap.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef __gnu_test::uneq_allocator ua_type; + ua_type one(1), two(2); + + std::pair p1(one, 1), p2(two, 2); + + p1.swap(p2); + VERIFY( p1.first.get_personality() == 2 ); + VERIFY( p1.second == 2 ); + VERIFY( p2.first.get_personality() == 1 ); + VERIFY( p2.second == 1 ); + + swap(p1, p2); + VERIFY( p2.first.get_personality() == 2 ); + VERIFY( p2.second == 2 ); + VERIFY( p1.first.get_personality() == 1 ); + VERIFY( p1.second == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc new file mode 100644 index 000000000..eb1bd212f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc @@ -0,0 +1,86 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY(( std::ratio_equal, std::ratio<1,3>>::value == 1 )); + VERIFY(( std::ratio_equal, std::ratio<1,4>>::value == 0 )); + + VERIFY( (std::ratio_not_equal, + std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_not_equal, + std::ratio<1,4>>::value == 1) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + VERIFY( (std::ratio_less, std::ratio<1,3>>::value == 1) ); + VERIFY( (std::ratio_less, std::ratio<1,3>>::value == 1) ); + + VERIFY( (std::ratio_less, std::ratio<1,4>>::value == 0) ); + VERIFY( (std::ratio_less, std::ratio<-1,3>>::value == 0) ); + + VERIFY( (std::ratio_less, std::ratio<-1,4>>::value == 1) ); + VERIFY( (std::ratio_less, std::ratio<0,3>>::value == 0) ); + VERIFY( (std::ratio_less, std::ratio<0,3>>::value == 0) ); + VERIFY( (std::ratio_less, std::ratio<-1,4>>::value == 0) ); + + VERIFY( (std::ratio_less_equal, + std::ratio<-1,3>>::value == 1) ); + VERIFY( ( std::ratio_less_equal, + std::ratio<1,3>>::value == 1) ); + + VERIFY( (std::ratio_less_equal, + std::ratio<-1,3>>::value == 0) ); + VERIFY( (std::ratio_less_equal, + std::ratio<-1,3>>::value == 0) ); + + VERIFY( (std::ratio_greater, std::ratio<1,4>>::value == 1) ); + VERIFY( (std::ratio_greater, std::ratio<-1,3>>::value == 1) ); + + VERIFY( (std::ratio_greater, std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_greater, std::ratio<1,3>>::value == 0) ); + + VERIFY( (std::ratio_greater_equal, + std::ratio<1,3>>::value == 1) ); + VERIFY( (std::ratio_greater_equal, + std::ratio<-1,3>>::value == 1) ); + + VERIFY( (std::ratio_greater_equal, + std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_greater_equal, + std::ratio<1,3>>::value == 0) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc new file mode 100644 index 000000000..20da30cbe --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +static const std::intmax_t M = INTMAX_MAX; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + // No overflow with same denominator + VERIFY( (std::ratio_less, + std::ratio>::value == 1) ); + + VERIFY( (std::ratio_less, + std::ratio>::value == 0) ); + + // No overflow if signs differ + VERIFY( (std::ratio_less, + std::ratio>::value == 1) ); + + VERIFY( (std::ratio_less, + std::ratio<-M, M - 1>>::value == 0) ); + + // No overflow + VERIFY( (std::ratio_less, + std::ratio>::value == 1) ); + + VERIFY( (std::ratio_less, + std::ratio<-M, M - 2>>::value == 0) ); + + VERIFY( (std::ratio_less, + std::ratio>::value == 1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp3.cc b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp3.cc new file mode 100644 index 000000000..f8c0c486b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp3.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2011-02-28 Paolo Carlini + +// Copyright (C) 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( (std::ratio_less, + std::ratio<59, 29129>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<4751, 13>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<25733, 25741>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<673, 773>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<17891, 32099>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<18457, 19571>>::value == 1) ); + + VERIFY( (std::ratio_less, + std::ratio<60, 29130>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<4752, 14>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<25732, 25742>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<674, 774>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<17892, 32100>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<18458, 19572>>::value == 1) ); + + VERIFY( (std::ratio_less, + std::ratio<58, 29128>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<4750, 12>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<25734, 25740>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<672, 772>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<17890, 32102>>::value == 1) ); + VERIFY( (std::ratio_less, + std::ratio<18456, 19570>>::value == 1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc b/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc new file mode 100644 index 000000000..a3dab54fd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio<1,3> r0; + std::ratio<2,6> r1; + std::ratio<2,-6> r2; + std::ratio<-2,6> r3; + + VERIFY( r0.num == 1 ); + VERIFY( r0.den == 3 ); + + VERIFY( r1.num == r0.num ); + VERIFY( r1.den == r0.den ); + VERIFY( r2.num == -r0.num ); + VERIFY( r2.den == r0.den ); + VERIFY( r3.num == -r0.num ); + VERIFY( r3.den == r0.den ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc new file mode 100644 index 000000000..ca91e46c8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc @@ -0,0 +1,54 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include + +void +test01() +{ + std::ratio r1 __attribute__((unused)); + std::ratio<-INTMAX_MAX, INTMAX_MAX> r2 __attribute__((unused)); +} + +void +test02() +{ + std::ratio r1 __attribute__((unused)); +} + +void +test03() +{ + std::ratio<1, INTMAX_MIN> r1 __attribute__((unused)); +} + +void +test04() +{ + std::ratio<1,0> r1 __attribute__((unused)); +} + +// { dg-error "instantiated from here" "" { target *-*-* } 34 } +// { dg-error "instantiated from here" "" { target *-*-* } 40 } +// { dg-error "instantiated from here" "" { target *-*-* } 46 } +// { dg-error "denominator cannot be zero" "" { target *-*-* } 155 } +// { dg-error "out of range" "" { target *-*-* } 156 } +// { dg-error "overflow in constant expression" "" { target *-*-* } 74 } diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/45866.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/45866.cc new file mode 100644 index 000000000..19735fc3e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/45866.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2010-10-18 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +// libstdc++/45866 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::ratio<1, 4>::type r_type1; + typedef std::ratio<3, 2>::type r_type2; + + typedef std::ratio_add ra_type; + + VERIFY( ra_type::num == ra_type::type::num ); + VERIFY( ra_type::den == ra_type::type::den ); + VERIFY( ra_type::num == 7 ); + VERIFY( ra_type::den == 4 ); + + typedef std::ratio_subtract rs_type; + + VERIFY( rs_type::num == rs_type::type::num ); + VERIFY( rs_type::den == rs_type::type::den ); + VERIFY( rs_type::num == -5 ); + VERIFY( rs_type::den == 4 ); + + typedef std::ratio_multiply rm_type; + + VERIFY( rm_type::num == rm_type::type::num ); + VERIFY( rm_type::den == rm_type::type::den ); + VERIFY( rm_type::num == 3 ); + VERIFY( rm_type::den == 8 ); + + typedef std::ratio_divide rd_type; + + VERIFY( rd_type::num == rd_type::type::num ); + VERIFY( rd_type::den == rd_type::type::den ); + VERIFY( rd_type::num == 1 ); + VERIFY( rd_type::den == 6 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/47913.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/47913.cc new file mode 100644 index 000000000..4105a710d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/47913.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +// libstdc++/47913 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + const intmax_t m = (intmax_t)1 << (4 * sizeof(intmax_t) - 1); + typedef ratio_add, + ratio<1, (m - 3) * (m - 2)> > ra_type; + + VERIFY( ra_type::num == 2 ); + VERIFY( ra_type::den == (m - 1) * (m - 3) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc new file mode 100644 index 000000000..183269e62 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_add, std::ratio<5,12>>::type r; + + VERIFY( r.num == 19 ); + VERIFY( r.den == 24 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + std::ratio_subtract, std::ratio<5,12>>::type r; + + VERIFY( r.num == -1 ); + VERIFY( r.den == 24 ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + std::ratio_multiply, std::ratio<5,12>>::type r; + + VERIFY( r.num == 5 ); + VERIFY( r.den == 32 ); +} + +void +test04() +{ + bool test __attribute__((unused)) = true; + std::ratio_divide, std::ratio<5,12>>::type r; + + VERIFY( r.num == 9 ); + VERIFY( r.den == 10 ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc new file mode 100644 index 000000000..abd2e7556 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +typedef std::ratio<1, INTMAX_MAX> one_over_max; +typedef std::ratio<2, INTMAX_MAX> two_over_max; +typedef std::ratio max_over_one; +typedef std::ratio max_over_two; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_add::type r1; + + VERIFY( r1.num == two_over_max::num); + VERIFY( r1.den == two_over_max::den); + + std::ratio_add< + std::ratio, + std::ratio>::type r2; + + VERIFY( r2.num == INTMAX_MAX ); + VERIFY( r2.den == (INTMAX_MAX / 2) + 1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::ratio_subtract::type r1; + + VERIFY( r1.num == 0); + VERIFY( r1.den == 1); + + std::ratio_subtract< + std::ratio, + std::ratio>::type r2; + + VERIFY( r2.num == 1 ); + VERIFY( r2.den == (INTMAX_MAX / 2) + 1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc new file mode 100644 index 000000000..fde9fb9dd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_multiply< + std::ratio<2, INTMAX_MAX>, + std::ratio>::type r1; + + VERIFY( r1.num == 1 ); + VERIFY( r1.den == 1 ); + + std::ratio_multiply< + std::ratio, + std::ratio<2 , INTMAX_MAX - 1>>::type r2; + + VERIFY( r2.num == INTMAX_MAX ); + VERIFY( r2.den == INTMAX_MAX - 1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::ratio_divide< + std::ratio, + std::ratio>::type r1; + + VERIFY( r1.num == 1 ); + VERIFY( r1.den == 1 ); + + std::ratio_divide< + std::ratio, + std::ratio>::type r2; + + VERIFY( r2.num == INTMAX_MAX - 1 ); + VERIFY( r2.den == INTMAX_MAX ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc new file mode 100644 index 000000000..b7076dfc5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles + +// Copyright (C) 2008, 2009, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include + +void +test01() +{ + std::ratio_add, std::ratio<1>>::type r1; +} + +void +test02() +{ + std::ratio_multiply, std::ratio<3, 2>>::type r1; + std::ratio_multiply, std::ratio>::type r2; +} + +// { dg-error "instantiated from here" "" { target *-*-* } 29 } +// { dg-error "instantiated from here" "" { target *-*-* } 35 } +// { dg-error "instantiated from here" "" { target *-*-* } 36 } +// { dg-error "overflow in addition" "" { target *-*-* } 132 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 104 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 100 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 102 } +// { dg-excess-errors "In instantiation of" } +// { dg-excess-errors "out of range" } diff --git a/libstdc++-v3/testsuite/20_util/ratio/requirements/constexpr_data.cc b/libstdc++-v3/testsuite/20_util/ratio/requirements/constexpr_data.cc new file mode 100644 index 000000000..d3a1543de --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/ratio/requirements/constexpr_data.cc @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_member_data + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr intmax_t v1 __attribute__((unused)) + = _Ttesttype::num; + constexpr intmax_t v2 __attribute__((unused)) + = _Ttesttype::den; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + typedef std::ratio<600, 900> R1; + typedef std::ratio<700, 200> R2; + test.operator()(); + test.operator()>(); + test.operator()>(); + test.operator()>(); + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc new file mode 100644 index 000000000..865e2885a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2003, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.2 raw storage iterator + +#include + +void test01() +{ + using namespace std; + + // Check for required base class. + long l; + typedef raw_storage_iterator test_iterator; + typedef iterator base_iterator; + test_iterator rs_it(&l); + base_iterator* base __attribute__((unused)) = &rs_it; +} diff --git a/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..906954681 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers. + +#include + +template class std::raw_storage_iterator; diff --git a/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc new file mode 100644 index 000000000..a62bde782 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.2 raw storage iterator + +#include + +void test01() +{ + using namespace std; + + // Check for required typedefs + typedef raw_storage_iterator test_iterator; + typedef test_iterator::value_type value_type; + typedef test_iterator::difference_type difference_type; + typedef test_iterator::pointer pointer; + typedef test_iterator::reference reference; + typedef test_iterator::iterator_category iteratory_category; +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc new file mode 100644 index 000000000..4bf61485c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include + +struct test_type +{ + int member(); + int cmember()const; + int member2(char); + int cmember2(char)const; +}; + +struct functor1 : public std::unary_function +{ + double operator()(int) const; +}; + +struct functor2 : public std::binary_function +{ + double operator()(int, char) const; +}; + +template +void verify_return_type(T, T) +{ +} + +void test01() +{ + test_type* null_tt = 0; + const test_type* null_ttc = 0; + int zero; + + std::reference_wrapper* pr1(0); + verify_return_type((*pr1)(0), double()); + std::reference_wrapper* pr2(0); + verify_return_type((*pr2)(0), double()); + std::reference_wrapper* pr3(0); + verify_return_type((*pr3)(null_tt), int()); + std::reference_wrapper* pr4(0); + verify_return_type((*pr4)(null_ttc), int()); + std::reference_wrapper* pr5(0); + + // libstdc++/24803 + verify_return_type((*pr5)(0), double()); + verify_return_type((*pr5)(zero), double()); + + std::reference_wrapper* pr1b(0); + verify_return_type((*pr1b)(0, 0), double()); + std::reference_wrapper* pr2b(0); + verify_return_type((*pr2b)(0, 0), double()); + std::reference_wrapper* pr3b(0); + verify_return_type((*pr3b)(null_tt,zero), int()); + std::reference_wrapper* pr4b(0); + verify_return_type((*pr4b)(null_ttc), int()); + std::reference_wrapper* pr5b(0); + + // libstdc++/24803 + verify_return_type((*pr5b)(0, 0), double()); + verify_return_type((*pr5b)(zero, zero), double()); +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc new file mode 100644 index 000000000..b167d7122 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// libstdc++/41792 +void test01() +{ + using namespace __gnu_test; + + OverloadedAddress* ao1 = new OverloadedAddress(); + std::reference_wrapper rw1(*ao1); +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc new file mode 100644 index 000000000..c1b62932f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile} +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.4 function object return types [func.ret] +#include + +struct X +{ + int f(int) { return 0; } + int i; +}; + +void test01() +{ + typedef int (X::*mfp)(int); + typedef int X::*mp; + mfp m = &X::f; + mp m2 = &X::i; + X x = { }; + std::ref(m)(x, 1); + std::ref(m)(&x, 1); + int& i1 = std::ref(m2)(x); + int& i2 = std::ref(m2)(&x); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc new file mode 100644 index 000000000..7b694c764 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc @@ -0,0 +1,120 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +struct X +{ + typedef int result_type; + + X() : bar(17) {} + + int foo(float x) { return truncate_float(x); } + int foo_c(float x) const { return truncate_float(x); } + int foo_v(float x) volatile { return truncate_float(x); } + int foo_cv(float x) const volatile { return truncate_float(x); } + int foo_varargs(float x, ...) { return truncate_float(x); } + + int operator()(float x) + { + return foo(x) + 1; + } + + int operator()(float x) const + { + return foo_c(x) + 2; + } + + int bar; + + private: + X(const X&); + X& operator=(const X&); +}; + +int seventeen() { return 17; } + +struct get_seventeen +{ + typedef int result_type; + int operator()() const { return 17; } +}; + +void test01() +{ + using std::ref; + using std::cref; + + ::get_seventeen get_sev; + ::X x; + ::X* xp = &x; + int (::X::* p_foo)(float) = &::X::foo; + int (::X::* p_foo_c)(float) const = &::X::foo_c; + int (::X::* p_foo_v)(float) volatile = &::X::foo_v; + int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv; + int (::X::* p_foo_varargs)(float, ...) = &::X::foo_varargs; + int ::X::* p_bar = &::X::bar; + + const float pi = 3.14; + + // Functions + VERIFY(ref(truncate_float)(pi) == 3); + VERIFY(ref(seventeen)() == 17); + + // Function pointers + VERIFY(cref(truncate_float)(pi) == 3); + VERIFY(cref(seventeen)() == 17); + + // Member function pointers + VERIFY(ref(p_foo)(x, pi) == 3); + VERIFY(ref(p_foo)(xp, pi) == 3); + VERIFY(ref(p_foo_c)(x, pi) == 3); + VERIFY(ref(p_foo_c)(xp, pi) == 3); + VERIFY(ref(p_foo_v)(x, pi) == 3); + VERIFY(ref(p_foo_v)(xp, pi) == 3); + VERIFY(ref(p_foo_cv)(x, pi) == 3); + VERIFY(ref(p_foo_cv)(xp, pi) == 3); + // VERIFY(ref(p_foo_varargs)(x, pi) == 3); + // VERIFY(ref(p_foo_varargs)(xp, pi, 1, 1) == 3); + // VERIFY(ref(p_foo_varargs)(x, pi, 1, 1) == 3); + // VERIFY(ref(p_foo_varargs)(xp, pi) == 3); + + // Member data pointers + VERIFY(ref(p_bar)(x) == 17); + VERIFY(ref(p_bar)(xp) == 17); + + // Function objects + VERIFY(ref(get_sev)() == 17); + VERIFY(cref(get_sev)() == 17); + VERIFY(ref(x)(pi) == 4); + VERIFY(cref(x)(pi) == 5); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc new file mode 100644 index 000000000..947a9b02f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3 Class template reference_wrapper + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include + +struct X { }; +X rval(); +X&& rvalref(); + +void test01() +{ + std::ref(1); // { dg-error "deleted" } + std::cref(1); // { dg-error "deleted" } + std::ref( int() ); // { dg-error "deleted" } + std::cref( int() ); // { dg-error "deleted" } + std::ref(rval()); // { dg-error "deleted" } + std::cref(rvalref()); // { dg-error "deleted" } +} + +int main() +{ + test02(); +} + +// { dg-excess-errors "" } diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc new file mode 100644 index 000000000..911e9a944 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-10-06 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +using namespace std; + +struct T; + +reference_wrapper::result_type i01; +reference_wrapper::result_type i02; +reference_wrapper::result_type i03; +reference_wrapper::result_type i04; + +reference_wrapper::result_type i05; +reference_wrapper::result_type i06; +reference_wrapper::result_type i07; +reference_wrapper::result_type i08; + +reference_wrapper::result_type i09; +reference_wrapper::result_type i10; +reference_wrapper::result_type i11; +reference_wrapper::result_type i12; diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc new file mode 100644 index 000000000..8b1b7e3f1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-10-06 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +using namespace std; + +reference_wrapper::argument_type i01; +reference_wrapper::argument_type i02; +reference_wrapper::argument_type i03; +reference_wrapper::argument_type i04; +reference_wrapper::result_type i05; +reference_wrapper::result_type i06; +reference_wrapper::result_type i07; +reference_wrapper::result_type i08; + +reference_wrapper::argument_type i09; +reference_wrapper::argument_type i10; +reference_wrapper::argument_type i11; +reference_wrapper::argument_type i12; +reference_wrapper::result_type i13; +reference_wrapper::result_type i14; +reference_wrapper::result_type i15; +reference_wrapper::result_type i16; + +reference_wrapper::first_argument_type i17; +reference_wrapper::first_argument_type i18; +reference_wrapper::first_argument_type i19; +reference_wrapper::first_argument_type i20; +reference_wrapper::second_argument_type i21; +reference_wrapper::second_argument_type i22; +reference_wrapper::second_argument_type i23; +reference_wrapper::second_argument_type i24; +reference_wrapper::result_type i25; +reference_wrapper::result_type i26; +reference_wrapper::result_type i27; +reference_wrapper::result_type i28; + +reference_wrapper::first_argument_type i29; +reference_wrapper::first_argument_type i30; +reference_wrapper::first_argument_type i31; +reference_wrapper::first_argument_type i32; +reference_wrapper::second_argument_type i33; +reference_wrapper::second_argument_type i34; +reference_wrapper::second_argument_type i35; +reference_wrapper::second_argument_type i36; +reference_wrapper::result_type i37; +reference_wrapper::result_type i38; +reference_wrapper::result_type i39; +reference_wrapper::result_type i40; diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc new file mode 100644 index 000000000..2fea52eed --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc @@ -0,0 +1,148 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct S { }; + +struct S0 +{ + typedef int argument_type; +}; + +struct S1 +{ + typedef float first_argument_type; +}; + +struct S2 +{ + typedef char second_argument_type; +}; + +struct S01 : S0, S1 { }; +struct S02 : S0, S2 { }; +struct S12 : S1, S2 { }; + +struct S012 : S0, S1, S2 { }; + +using std::__sfinae_types; +using std::integral_constant; +using std::remove_cv; + +_GLIBCXX_HAS_NESTED_TYPE(argument_type) +_GLIBCXX_HAS_NESTED_TYPE(first_argument_type) +_GLIBCXX_HAS_NESTED_TYPE(second_argument_type) + +template + struct has_arg_type : __has_argument_type + { }; + +template + struct has_1st_arg_type : __has_first_argument_type + { }; + +template + struct has_2nd_arg_type : __has_second_argument_type + { }; + +template::value> +struct test_arg_type +{ + static_assert( !has_arg_type>::value, + "reference_wrapper has no nested argument_type"); +}; + +template +struct test_arg_type +{ + typedef std::reference_wrapper ref; + + static_assert( has_arg_type::value, + "reference_wrapper has nested argument_type"); + + static_assert( + std::is_same< typename T::argument_type, + typename ref::argument_type >::value, + "reference_wrapper has the correct argument_type"); +}; + +template::value && has_2nd_arg_type::value> +struct test_1st_2nd_arg_types +{ + typedef std::reference_wrapper ref; + + static_assert( !has_1st_arg_type::value, + "reference_wrapper has no nested first_argument_type"); + + static_assert( !has_2nd_arg_type::value, + "reference_wrapper has no nested second_argument_type"); +}; + +template +struct test_1st_2nd_arg_types +{ + typedef std::reference_wrapper ref; + + static_assert( has_1st_arg_type::value, + "reference_wrapper has nested first_argument_type"); + + static_assert( has_2nd_arg_type::value, + "reference_wrapper has nested second_argument_type"); + + static_assert( + std::is_same< typename T::first_argument_type, + typename ref::first_argument_type>::value, + "reference_wrapper has correct first_argument_type"); + + static_assert( + std::is_same< typename T::second_argument_type, + typename ref::second_argument_type>::value, + "reference_wrapper has correct second_argument_type"); +}; + + +template + void test() + { + test_arg_type t; + test_arg_type tc; + test_arg_type tv; + test_arg_type tcv; + test_1st_2nd_arg_types t12; + test_1st_2nd_arg_types t12c; + test_1st_2nd_arg_types t12v; + test_1st_2nd_arg_types t12cv; + } + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} + diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc new file mode 100644 index 000000000..815700f1c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct X {}; + +struct int_result_type { typedef int result_type; }; + +struct derives_unary : std::unary_function {}; + +struct derives_binary : std::binary_function {}; + +struct derives_unary_binary + : std::unary_function, + std::binary_function +{ + typedef int result_type; +}; + +void test01() +{ + using std::reference_wrapper; + using std::is_same; + + // Check result_type typedef + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/rel_ops.cc b/libstdc++-v3/testsuite/20_util/rel_ops.cc new file mode 100644 index 000000000..534b4b626 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/rel_ops.cc @@ -0,0 +1,45 @@ +// 2002-04-13 Paolo Carlini + +// Copyright (C) 2002, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.1 Operators + +#include +#include + +using namespace std::rel_ops; + +// libstdc++/3628 +void test01() +{ + std::vector v; + std::vector::iterator vi; + v.push_back(1); + vi = v.end(); + vi != v.begin(); + vi > v.begin(); + vi <= v.begin(); + vi >= v.begin(); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..aeffd5a0f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct remove_reference; +} diff --git a/libstdc++-v3/testsuite/20_util/remove_reference/value.cc b/libstdc++-v3/testsuite/20_util/remove_reference/value.cc new file mode 100644 index 000000000..a412303d0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/remove_reference/value.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::remove_reference; + using std::is_same; + using namespace __gnu_test; + + VERIFY( (is_same::type, int>::value) ); + VERIFY( (is_same::type, int>::value) ); + VERIFY( (is_same::type, const int>::value) ); + VERIFY( (is_same::type, int*>::value) ); + VERIFY( (is_same::type, ClassType>::value) ); + VERIFY( (is_same::type, ClassType>::value) ); + VERIFY( (is_same::type, int(int)>::value) ); + VERIFY( (is_same::type, int>::value) ); + VERIFY( (is_same::type, int>::value) ); + VERIFY( (is_same::type, const int>::value) ); + VERIFY( (is_same::type, int*>::value) ); + VERIFY( (is_same::type, ClassType>::value) ); + VERIFY( (is_same::type, ClassType>::value) ); + VERIFY( (is_same::type, int(int)>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc new file mode 100644 index 000000000..7c93eb077 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from shared_ptr +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + + a = std::shared_ptr(new A); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + a = std::shared_ptr(); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc new file mode 100644 index 000000000..e2ec07860 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from auto_ptr +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a(new A); + std::auto_ptr b(new B); + a = std::move(b); + VERIFY( a.get() != 0 ); + VERIFY( b.get() == 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc new file mode 100644 index 000000000..b79a25b13 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +struct B { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from incompatible auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::auto_ptr b; + a = std::move(b); // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "In constructor" } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc new file mode 100644 index 000000000..376e8945f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x -Wno-deprecated" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +std::auto_ptr source() { return std::auto_ptr(); } + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from rvalue auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + a = source(); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::auto_ptr au; + a = std::move(au); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc new file mode 100644 index 000000000..48ddf9053 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include + +// DR 541. shared_ptr template assignment and void +void test01() +{ + std::shared_ptr p; + p.operator=(p); +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc new file mode 100644 index 000000000..1a7b20caf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc @@ -0,0 +1,118 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Rvalue assignment from shared_ptr +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a1; + std::shared_ptr a2(new A); + + a1 = std::move(a2); + VERIFY( a1.get() != 0 ); + VERIFY( a2.get() == 0 ); + VERIFY( a1.use_count() == 1 ); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + a1 = std::move(std::shared_ptr()); + VERIFY( a1.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +// Rvalue assignment from shared_ptr +void +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::shared_ptr b(new B); + + a = std::move(b); + VERIFY( a.get() != 0 ); + VERIFY( b.get() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( b.use_count() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + a = std::move(std::shared_ptr()); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc new file mode 100644 index 000000000..4543be696 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc @@ -0,0 +1,96 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from shared_ptr +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + + a = std::shared_ptr(); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + a = std::shared_ptr(new A); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + a = std::shared_ptr(new B); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc new file mode 100644 index 000000000..e0d09dee9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +struct B { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from incompatible shared_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::shared_ptr b; + a = b; // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-error "In member function" "" { target *-*-* } 0 } +// { dg-error "cannot convert" "" { target *-*-* } 0 } +// { dg-error "instantiated from" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc new file mode 100644 index 000000000..dae967bfd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from lvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::unique_ptr u; + a = u; // { dg-error "cannot bind" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "initializing argument" } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc new file mode 100644 index 000000000..e759a42c3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +std::unique_ptr source() { return std::unique_ptr(); } + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from rvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + a = source(); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::unique_ptr u; + a = std::move(u); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc new file mode 100644 index 000000000..a12c54964 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2.10 shared_ptr casts [util.smartptr.shared.cast] + +#include +#include + +// { dg-do compile } + +struct MyP { virtual ~MyP() { }; }; +struct MyDP : MyP { }; + +int main() +{ + using __gnu_test::check_ret_type; + using std::shared_ptr; + using std::static_pointer_cast; + using std::const_pointer_cast; + using std::dynamic_pointer_cast; + + shared_ptr spd; + shared_ptr spci; + shared_ptr spa; + + check_ret_type >(static_pointer_cast(spd)); + check_ret_type >(const_pointer_cast(spci)); + check_ret_type >(static_pointer_cast(spa)); +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc new file mode 100644 index 000000000..41e09d666 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.11.2 Class template shared_ptr [util.smartptr.shared] + +#include + +// libstdc++/42925 (also see GB 99) +void test01() +{ + std::shared_ptr ptr; + if (ptr == 0) + { } + if (0 == ptr) + { } + if (ptr != 0) + { } + if (0 != ptr) + { } +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc new file mode 100644 index 000000000..ba8280716 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc @@ -0,0 +1,88 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.6.2.6 shared_ptr comparison [util.smartptr.shared.cmp] + +int +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty shared_ptrs compare equivalent + std::shared_ptr p1; + std::shared_ptr p2; + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p2 < p1) ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr A_default; + + std::shared_ptr A_from_A(new A); + VERIFY( A_default != A_from_A ); + VERIFY( !(A_default == A_from_A) ); + VERIFY( (A_default < A_from_A) || (A_from_A < A_default) ); + + std::shared_ptr B_from_B(new B); + VERIFY( B_from_B != A_from_A ); + VERIFY( !(B_from_B == A_from_A) ); + VERIFY( (B_from_B < A_from_A) || (A_from_A < B_from_B) ); + + A_from_A.reset(); + VERIFY( A_default == A_from_A ); + VERIFY( !(A_default != A_from_A) ); + VERIFY( !(A_default < A_from_A) && !(A_from_A < A_default) ); + + B_from_B.reset(); + VERIFY( B_from_B == A_from_A ); + VERIFY( !(B_from_B != A_from_A) ); + VERIFY( !(B_from_B < A_from_A) && !(A_from_A < B_from_B) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc new file mode 100644 index 000000000..b51b222a0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc @@ -0,0 +1,102 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.13.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +namespace std +{ + template<> + struct less : binary_function + { + static int count; + bool operator()(A* l, A* r) { ++count; return l < r; } + }; + int less::count = 0; +} + +// 20.8.13.2.7 shared_ptr comparison [util.smartptr.shared.cmp] + + +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::less> less; + // test empty shared_ptrs compare equivalent + std::shared_ptr p1; + std::shared_ptr p2; + VERIFY( !less(p1, p2) && !less(p2, p1) ); + VERIFY( std::less::count == 2 ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::less> less; + + std::shared_ptr empty; + std::shared_ptr p1(new A); + std::shared_ptr p2(new A); + + VERIFY( less(p1, p2) || less(p2, p1) ); + VERIFY( !(less(p1, p2) && less(p2, p1)) ); + + p1.reset(); + VERIFY( !less(p1, empty) && !less(empty, p1) ); + + p2.reset(); + VERIFY( !less(p1, p2) && !less(p2, p1) ); + + return 0; +} + +// Aliasing +int +test03() +{ + bool test __attribute__((unused)) = true; + + std::less> less; + + A a; + std::shared_ptr p1(new A); + std::shared_ptr p2(p1, &a); + VERIFY( less(p1, p2) || less(p2, p1) ); + + return 0; +} +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc new file mode 100644 index 000000000..d5b3f7dea --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// libstdc++/39405 +template + struct foo + { + std::shared_ptr > m_foo; + }; + +std::shared_ptr > t; diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc new file mode 100644 index 000000000..f5899d399 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.11.2 Template class shared_ptr [util.smartptr.shared] + +#include + +// incomplete type +struct X; + +// get an auto_ptr rvalue +std::auto_ptr&& ap(); + +void test01() +{ + X* px = 0; + std::shared_ptr p1(px); // { dg-error "here" } + // { dg-error "incomplete" "" { target *-*-* } 766 } + + std::shared_ptr p9(ap()); // { dg-error "here" } + // { dg-error "incomplete" "" { target *-*-* } 859 } + +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc new file mode 100644 index 000000000..d8275198c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10.2 Class template shared_ptr [util.smartptr.shared] + +#include +#include + +// 20.9.10.2.1 shared_ptr constructors [util.smartptr.shared.const] + +struct deleter; + +class A +{ + ~A() = default; + friend struct deleter; +}; + +struct deleter +{ + void operator()(A* a) const; +}; + +void +test01() +{ + std::shared_ptr p(new A, deleter()); +} + diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc new file mode 100644 index 000000000..9c39ed50d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc @@ -0,0 +1,107 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + A() : i() { } + virtual ~A() { } + int i; +}; + +struct B : A +{ + B() : A(), a() { } + virtual ~B() { } + A a; +}; + +void deletefunc(A* p) { delete p; } + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Aliasing constructors + +int test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + std::shared_ptr b1(a, &test); + VERIFY( b1.use_count() == 0 ); + VERIFY( a.get() == 0 ); + VERIFY( b1.get() == &test ); + + std::shared_ptr b2(b1); + VERIFY( b2.use_count() == 0 ); + VERIFY( b1.get() == b2.get() ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a(new A); + std::shared_ptr i1(a, &a->i); + VERIFY( i1.use_count() == 2 ); + + std::shared_ptr i2(i1); + VERIFY( i2.use_count() == 3 ); + VERIFY( i2.get() == &a->i ); + + return 0; +} + +int +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr b(new B); + std::shared_ptr a1(b, b.get()); + std::shared_ptr a2(b, &b->a); + VERIFY( a2.use_count() == 3 ); + VERIFY( a1 == b ); + VERIFY( a2 != b ); + VERIFY( a1.get() != a2.get() ); + + std::shared_ptr a3(a1); + VERIFY( a3 == b ); + + a3 = a2; + VERIFY( a3.get() == &b->a ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc new file mode 100644 index 000000000..4a4be9a68 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc @@ -0,0 +1,103 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A { }; +void deletefunc(A* p) { delete p; } +struct D +{ + void operator()(A* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction with allocator +int +test01() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + std::shared_ptr p1(new A, deletefunc, tracker_allocator()); + std::size_t const sz = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz > 0 ); + { + std::shared_ptr p2(p1); + VERIFY( p2.use_count() == 2 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + } + VERIFY( p1.use_count() == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + p1.reset(); + VERIFY( p1.use_count() == 0 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz ); + + return 0; +} + +// Construction with allocator +int +test02() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + std::shared_ptr p1(new A, deletefunc, tracker_allocator()); + std::size_t const sz1 = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz1 > 0 ); + std::shared_ptr p2(new A, D(), tracker_allocator()); + std::size_t const sz2 = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz2 > sz1 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + p1 = p2; + VERIFY( p2.use_count() == 2 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz1 ); + p1.reset(); + VERIFY( p2.use_count() == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz1 ); + p2.reset(); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz2 ); + VERIFY( D::delete_count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc new file mode 100644 index 000000000..eb5bb9590 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::auto_ptr a(new A); + std::shared_ptr a2(std::move(a)); + VERIFY( a.get() == 0 ); + VERIFY( a2.get() != 0 ); + VERIFY( a2.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc new file mode 100644 index 000000000..b078a7df7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include + +struct A { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.const] + +// Construction from const auto_ptr +void +test01() +{ + const std::auto_ptr a; + std::shared_ptr p(std::move(a)); // { dg-error "no match" } +} +// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc new file mode 100644 index 000000000..5a1fc818f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-final { scan-assembler-not "_ZNSt10shared_ptrIiEC2Ev" } } +// { dg-final { scan-assembler-not "_ZNSt10shared_ptrIiEC2EDn" } } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; //not literal + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; //not literal + test2.operator(), std::nullptr_t>(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc new file mode 100644 index 000000000..c5dcffea0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc @@ -0,0 +1,136 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +void deleter(A* p) { delete p; } + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Copy construction +int test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a1; + std::shared_ptr a2(a1); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a1(new A); + std::shared_ptr a2(a1); + VERIFY( a2.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr b(new B); + std::shared_ptr a(b); + VERIFY( a.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr b(new B, &deleter); + std::shared_ptr a(b); + VERIFY( a.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc new file mode 100644 index 000000000..ec4c1fdab --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Default construction +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + VERIFY( a.get() == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc new file mode 100644 index 000000000..795155829 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc @@ -0,0 +1,164 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// TR1 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct D +{ + void operator()(B* p) const { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + D::delete_count = 0; + } +}; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Rvalue construction +int test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a1; + std::shared_ptr a2(std::move(a1)); + VERIFY( a1.use_count() == 0 ); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a1(new A); + std::shared_ptr a2(std::move(a1)); + VERIFY( a1.use_count() == 0 ); + VERIFY( a2.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + return 0; +} + +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr b(new B); + std::shared_ptr a(std::move(b)); + VERIFY( b.use_count() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr b(new B, D()); + std::shared_ptr a(std::move(b)); + VERIFY( b.use_count() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + a = std::move(std::shared_ptr()); + VERIFY( D::delete_count == 1 ); + VERIFY( B::dtor_count == 1 ); + + return 0; +} + +int +test05() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a(std::move(std::shared_ptr(new A))); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/nullptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/nullptr.cc new file mode 100644 index 000000000..82acaed36 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/nullptr.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.11.2 Class template shared_ptr [util.smartptr.shared] + +#include +#include +#include +#include + +// 20.9.11.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from nullptr + +struct deleter +{ + int count; + deleter() : count(0) { } + void operator()(std::nullptr_t) { ++count; } + void operator()(int*) const { throw "wrong type passed to deleter"; } +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p = nullptr; + VERIFY( p.get() == nullptr ); + VERIFY( p.use_count() == 0 ); + +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + deleter d; + std::shared_ptr p(nullptr, std::ref(d)); + VERIFY( p.get() == nullptr ); + VERIFY( p.use_count() == 1 ); + + p = nullptr; + VERIFY( p.use_count() == 0 ); + VERIFY( d.count == 1 ); +} + + +void +test03() +{ + bool test __attribute__((unused)) = true; + + deleter d; + __gnu_test::tracker_allocator a; + std::shared_ptr p(nullptr, std::ref(d), a); + VERIFY( p.get() == nullptr ); + VERIFY( p.use_count() == 1 ); + + p = nullptr; + VERIFY( p.use_count() == 0 ); + VERIFY( d.count == 1 ); + + typedef __gnu_test::tracker_allocator_counter c; + VERIFY( c::get_destruct_count() == c::get_construct_count() ); + VERIFY( c::get_deallocation_count() == c::get_allocation_count() ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc new file mode 100644 index 000000000..701f12439 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +struct B : A { }; + + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from pointer + +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = 0; + std::shared_ptr p(a); + VERIFY( p.get() == 0 ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr p(a); + VERIFY( p.get() == a ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + + +int +test03() +{ + bool test __attribute__((unused)) = true; + + B * const b = new B; + std::shared_ptr p(b); + VERIFY( p.get() == b ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc new file mode 100644 index 000000000..cfca90d90 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr up(new A); + std::shared_ptr sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc new file mode 100644 index 000000000..67485aee7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +struct D { + void operator()(A* p) const { delete p; ++count; } + static int count; +}; + +int D::count = 0; + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr up(new A, D()); + { + std::shared_ptr sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + } + VERIFY( D::count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc new file mode 100644 index 000000000..d0998c94c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +struct D { + typedef void result_type; + void operator()(A* p) { delete p; ++count; } + int count; +}; + + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + D d = D(); + std::unique_ptr up(new A, d); + { + std::shared_ptr sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + } + VERIFY( d.count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc new file mode 100644 index 000000000..7b09cfa7d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +struct A { }; + +struct D { + typedef void result_type; + void operator()(A* p) { delete p; ++count; } + int count; +}; + + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +// See: http://gcc.gnu.org/ml/libstdc++/2008-09/msg00070.html. +int +test01() +{ + bool test __attribute__((unused)) = true; + + D d; + std::unique_ptr p1(new A, d); + + std::shared_ptr p2(std::move(p1)); + + typedef std::reference_wrapper D2; + D2* p3 = std::get_deleter(p2); + + VERIFY( p3 != 0 ); + VERIFY( &p3->get() == &d ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc new file mode 100644 index 000000000..0e2fd68d5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from lvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr a; + std::shared_ptr p(a); // { dg-error "cannot bind" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-excess-errors "initializing argument" } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc new file mode 100644 index 000000000..7e24c1822 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from weak_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr a1(a); + std::weak_ptr wa(a1); + std::shared_ptr a2(wa); + VERIFY( a2.get() == a ); + VERIFY( a2.use_count() == wa.use_count() ); + + return 0; +} + + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc new file mode 100644 index 000000000..cff9b3b99 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do run { xfail *-*-* } } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from expired weak_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a1(new A); + std::weak_ptr wa(a1); + a1.reset(); + VERIFY( wa.expired() ); + try + { + std::shared_ptr a2(wa); + } + catch (const std::bad_weak_ptr&) + { + // Expected. + __throw_exception_again; + } + catch (...) + { + // Failed. + } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc new file mode 100644 index 000000000..31230776e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct A : std::enable_shared_from_this { }; + +// libstdc++/36949 +void test01() +{ + std::make_shared()->shared_from_this(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc new file mode 100644 index 000000000..e6bc6f47f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc @@ -0,0 +1,110 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A +{ + A(int i, double d, char c = '\0') : i(i), d(d), c(c) { ++ctor_count; } + explicit A(int i) : i(i), d(), c() { ++ctor_count; } + A() : i(), d(), c() { ++ctor_count; } + ~A() { ++dtor_count; } + int i; + double d; + char c; + static int ctor_count; + static int dtor_count; +}; +int A::ctor_count = 0; +int A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + tracker_allocator_counter::reset(); + } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + { + std::shared_ptr p1 = std::allocate_shared(tracker_allocator()); + VERIFY( p1.get() != 0 ); + VERIFY( p1.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + } + VERIFY( A::ctor_count == A::dtor_count ); + VERIFY( tracker_allocator_counter::get_allocation_count() + == tracker_allocator_counter::get_deallocation_count() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + std::shared_ptr p1; + + p1 = std::allocate_shared(tracker_allocator(), 1); + VERIFY( A::ctor_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + + p1 = std::allocate_shared(tracker_allocator(), 1, 2.0); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() > 0 ); + + p1 = std::allocate_shared(tracker_allocator(), 1, 2.0, '3'); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( p1->i == 1 ); + VERIFY( p1->d == 2.0 ); + VERIFY( p1->c == '3' ); + + p1 = std::shared_ptr(); + VERIFY( A::ctor_count == A::dtor_count ); + VERIFY( tracker_allocator_counter::get_allocation_count() + == tracker_allocator_counter::get_deallocation_count() ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc new file mode 100644 index 000000000..462c6f848 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +struct A +{ + void* operator new(size_t n) { return new char[sizeof(A)]; } + void operator delete(void* p, size_t) { delete (char*)p; } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p = std::make_shared(); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc new file mode 100644 index 000000000..db176650e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc @@ -0,0 +1,90 @@ +// { dg-options "-std=gnu++0x -Wno-deprecated" } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.11.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ +}; + +std::unique_ptr +create_unique_ptr() +{ + return std::unique_ptr(new A()); +} + +std::auto_ptr +create_auto_ptr() +{ + return std::auto_ptr(new A()); +} + +void +process(std::shared_ptr a) +{ + bool test __attribute__((unused)) = true; + + VERIFY( a.get() != 0 ); + VERIFY( a.use_count() == 1 ); +} + +// 20.9.11.2.1 shared_ptr creation [util.smartptr.shared.const] + +// Implicit conversion of auto_ptr to shared_ptr is allowed + +void +test01() +{ + process(create_auto_ptr()); +} + +void +test02() +{ + std::auto_ptr a = create_auto_ptr(); + process(std::move(a)); +} + +// Implicit conversion of unique_ptr to shared_ptr is allowed + +void +test03() +{ + process(create_unique_ptr()); +} + +void +test04() +{ + std::unique_ptr a = create_unique_ptr(); + process(std::move(a)); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc new file mode 100644 index 000000000..2441b9302 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc @@ -0,0 +1,97 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + A(int i, double d, char c = '\0') : i(i), d(d), c(c) { ++ctor_count; } + explicit A(int i) : i(i), d(), c() { ++ctor_count; } + A() : i(), d(), c() { ++ctor_count; } + ~A() { ++dtor_count; } + int i; + double d; + char c; + static int ctor_count; + static int dtor_count; +}; +int A::ctor_count = 0; +int A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + { + std::shared_ptr p1 = std::make_shared(); + VERIFY( p1.get() != 0 ); + VERIFY( p1.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + } + VERIFY( A::ctor_count == A::dtor_count ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + std::shared_ptr p1; + + p1 = std::make_shared(1); + VERIFY( A::ctor_count == 1 ); + + p1 = std::make_shared(1, 2.0); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + + p1 = std::make_shared(1, 2.0, '3'); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( p1->i == 1 ); + VERIFY( p1->d == 2.0 ); + VERIFY( p1->c == '3' ); + + p1 = std::shared_ptr(); + VERIFY( A::ctor_count == A::dtor_count ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc new file mode 100644 index 000000000..5e1a6135f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc @@ -0,0 +1,134 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct D +{ + void operator()(const B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + D::delete_count = 0; + } +}; + + +// 20.6.6.2.2 shared_ptr destructor [util.smartptr.shared.dest] + +// empty shared_ptr +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + { + std::shared_ptr a; + } + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + VERIFY( D::delete_count == 0 ); + + return 0; +} + +// shared ownership +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr a; + { + a = std::shared_ptr(new B, D()); + } + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + VERIFY( D::delete_count == 0 ); + + return 0; +} + +// exclusive ownership +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + { + std::shared_ptr a1(new B); + std::shared_ptr a2(new B, D()); + } + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 2 ); + VERIFY( B::dtor_count == 2 ); + VERIFY( D::delete_count == 1 ); + + return 0; +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/hash/1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/hash/1.cc new file mode 100644 index 000000000..93f4739d7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/hash/1.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-11 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + struct T { }; + + std::shared_ptr s0(new T); + std::hash> hs0; + std::hash hp0; + + VERIFY( hs0(s0) == hp0(s0.get()) ); + + std::__shared_ptr s1(new T); + std::hash> hs1; + std::hash hp1; + + VERIFY( hs1(s1) == hp1(s1.get()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc new file mode 100644 index 000000000..b44c9bdf8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +using std::get_deleter; + +// libstdc++/24595 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr sp; + VERIFY( !get_deleter(sp) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/misc/42019.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/misc/42019.cc new file mode 100644 index 000000000..bea1771d2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/misc/42019.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x -fno-rtti" } +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.15.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +// libstdc++/42019 + +class A {}; + +struct B { + explicit B(int i) : i(i) { } + int i; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr spA = std::make_shared(); + + VERIFY( spA.get() != 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr spB = std::make_shared(99); + + VERIFY( spB->i == 99 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc new file mode 100644 index 000000000..a84f4bebf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +struct A { }; + +// 20.6.6.2.8 shared_ptr I/O [util.smartptr.shared.io] + +// operator<< +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p(new A); + std::ostringstream buf; + buf << p; + const std::string s = buf.str(); + buf.str(""); + buf << p.get(); + VERIFY( s == buf.str() ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc new file mode 100644 index 000000000..10ccf8cad --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.9 shared_ptr specialized algorithms [util.smartptr.shared.spec] + +// std::swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a1 = new A; + A * const a2 = new A; + std::shared_ptr p1(a1); + std::shared_ptr p2(a2); + std::swap(p1, p2); + VERIFY( p1.get() == a2 ); + VERIFY( p2.get() == a1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc new file mode 100644 index 000000000..8b64014c0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap + +// libstdc++/24805 +using std::swap; diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc new file mode 100644 index 000000000..c3b6745b4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc @@ -0,0 +1,89 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +struct B : A { }; +struct D +{ + void operator()(B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// reset +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr p1(a); + std::shared_ptr p2(p1); + p1.reset(); + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == a ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + B * const b = new B; + std::shared_ptr p1(a); + std::shared_ptr p2(p1); + p1.reset(b); + VERIFY( p1.get() == b ); + VERIFY( p2.get() == a ); + + return 0; +} + +int +test03() +{ + bool test __attribute__((unused)) = true; + + { + std::shared_ptr p1; + p1.reset(new B, D()); + } + VERIFY( D::delete_count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc new file mode 100644 index 000000000..61ac3b98e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include +#include + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A { }; +struct B : A { }; +struct D +{ + void operator()(B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// Reset with allocator +int +test01() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + { + std::shared_ptr p1; + p1.reset(new B, D(), tracker_allocator()); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + } + VERIFY( D::delete_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count() ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc new file mode 100644 index 000000000..5f133f547 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// reset +int +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr p1(new A); + p1.reset(); // { dg-error "discards qualifiers" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc new file mode 100644 index 000000000..aab41ddc8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a1 = new A; + A * const a2 = new A; + std::shared_ptr p1(a1); + std::shared_ptr p2(a2); + p1.swap(p2); + VERIFY( p1.get() == a2 ); + VERIFY( p2.get() == a1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc new file mode 100644 index 000000000..db173630f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr p1(new A); + std::shared_ptr p2(new A); + p1.swap(p2); // { dg-error "discards qualifiers" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc new file mode 100644 index 000000000..dc2d53386 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// conversion to bool +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr p1; + VERIFY( static_cast(p1) == false ); + const std::shared_ptr p2(p1); + VERIFY( static_cast(p2) == false ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p1(new A); + VERIFY( static_cast(p1) ); + std::shared_ptr p2(p1); + VERIFY( static_cast(p2) ); + p1.reset(); + VERIFY( !static_cast(p1) ); + VERIFY( static_cast(p2) ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p1(new A); + std::shared_ptr p2(p1); + p2.reset(new A); + VERIFY( static_cast(p1) ); + VERIFY( static_cast(p2) ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc new file mode 100644 index 000000000..104c7219d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + A() : i() {} + int i; +}; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// get +void +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr p(a); + VERIFY( p.get() == a ); +} + +// operator* +void +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr p(a); + VERIFY( &*p == a ); +} + +// operator-> +void +test03() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr p(a); + VERIFY( &p->i == &a->i ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc new file mode 100644 index 000000000..79ede6833 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc @@ -0,0 +1,94 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.13.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A +{ + int i; + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty shared_ptrs compare equivalent + std::shared_ptr p1; + std::shared_ptr p2; + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); +} + + +// Construction from pointer +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a0; + + std::shared_ptr a1(new A); + VERIFY( a1.owner_before(a0) || a0.owner_before(a1) ); + VERIFY( !(a1.owner_before(a0) && a0.owner_before(a1)) ); + + std::shared_ptr b1(new B); + VERIFY( a1.owner_before(b1) || b1.owner_before(a1) ); + VERIFY( !(a1.owner_before(b1) && b1.owner_before(a1)) ); + + std::shared_ptr a2(a1); + VERIFY( !a1.owner_before(a2) && !a2.owner_before(a1) ); + a2 = b1; + VERIFY( !b1.owner_before(a2) && !a2.owner_before(b1) ); + + std::weak_ptr w1(a1); + VERIFY( !a1.owner_before(w1) && !w1.owner_before(a1) ); + std::weak_ptr w2(a2); + VERIFY( !b1.owner_before(w2) && !w2.owner_before(b1) ); +} + +// Aliasing +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p1(new A()); + std::shared_ptr p2(p1, &p1->i); + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc new file mode 100644 index 000000000..fae5eba37 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// unique +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr p1; + VERIFY( !p1.unique() ); + const std::shared_ptr p2(p1); + VERIFY( !p1.unique() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p1(new A); + VERIFY( p1.unique() ); + std::shared_ptr p2(p1); + VERIFY( !p1.unique() ); + p1.reset(); + VERIFY( !p1.unique() ); + VERIFY( p2.unique() ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p1(new A); + std::shared_ptr p2(p1); + p2.reset(new A); + VERIFY( p1.unique() ); + VERIFY( p2.unique() ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc new file mode 100644 index 000000000..a7f34cfac --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +struct A { }; +struct B : A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// use_count +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr p1; + VERIFY( p1.use_count() == 0 ); + const std::shared_ptr p2(p1); + VERIFY( p1.use_count() == 0 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p1(new A); + std::shared_ptr p2(p1); + p1.reset(); + VERIFY( p1.use_count() == 0 ); + VERIFY( p2.use_count() == 1 ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p1(new A); + std::shared_ptr p2(p1); + p2.reset(new B); + VERIFY( p1.use_count() == 1 ); + VERIFY( p2.use_count() == 1 ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..0f2d2c366 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +using namespace __gnu_test; +using std::shared_ptr; +template class shared_ptr; +template class shared_ptr; +template class shared_ptr; +template class shared_ptr; diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..781657cb0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +// Check the _S_single lock policy can be instantiated. For a thread-enabled +// library this checks the templates can be instantiated for non-default +// lock policy, for a single-threaded lib this is redundant but harmless. +using namespace __gnu_test; +using std::__shared_ptr; +using std::_S_single; +template class __shared_ptr; +template class __shared_ptr; +template class __shared_ptr; diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc new file mode 100644 index 000000000..b215f654a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc @@ -0,0 +1,197 @@ +// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options "-pthread -std=gnu++0x" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options "-pthreads -std=gnu++0x" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } + +#include +#include +#include +#include +#include +#include + +#include + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif + +/* This (brute-force) tests the atomicity and thus thread safety of the + * shared_ptr <- weak_ptr + * assignment operation by allocating a test object, retrieving a weak + * reference to it, and letting a number of threads repeatedly create strong + * references from the weak reference. + * Specifically, this tests the function _Sp_counted_base::add_ref_lock() + */ + + +const unsigned int HAMMER_MAX_THREADS = 10; +const unsigned int POOL_SIZE = 1000; +const unsigned long HAMMER_REPEAT = 100000; +const unsigned long KILL_ONE_IN = 1000; + +struct A + { + static _Atomic_word counter; + A() + { + __gnu_cxx::__atomic_add(&counter, 1); + } + ~A() + { + __gnu_cxx::__atomic_add(&counter, -1); + } + }; + +_Atomic_word A::counter = 0; + +typedef std::shared_ptr sp_A_t; +typedef std::weak_ptr wp_A_t; + +typedef std::vector sp_vector_t; +typedef std::vector wp_vector_t; + +struct shared_and_weak_pools +{ + sp_vector_t& shared_pool; + wp_vector_t& weak_pool; + + shared_and_weak_pools(sp_vector_t& _shared_pool, wp_vector_t& _weak_pool) + : shared_pool(_shared_pool), weak_pool(_weak_pool) + { } +}; + +void* thread_hammer_and_kill(void* opaque_pools) +{ + shared_and_weak_pools& pools = *static_cast(opaque_pools); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> rng; + + sp_vector_t::iterator cur_shared = pools.shared_pool.begin(); + wp_vector_t::iterator cur_weak = pools.weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == pools.weak_pool.end()) + break; + } + + if (rng() % KILL_ONE_IN == 0) + { + cur_shared->reset(); + ++cur_shared; + } + } + return 0; +} + +void* thread_hammer(void* opaque_weak) +{ + wp_vector_t& weak_pool = *static_cast(opaque_weak); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> rng; + + wp_vector_t::iterator cur_weak = weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == weak_pool.end()) + break; + } + } + return 0; +} + +int +test01() +{ + bool test __attribute__((unused)) = true; + sp_vector_t obj_pool(POOL_SIZE); + + for(sp_vector_t::iterator cur = obj_pool.begin(); cur != obj_pool.end(); ++cur) + { + cur->reset(new A); + } + // Obtain weak references. + std::vector weak_pool(HAMMER_MAX_THREADS, wp_vector_t(obj_pool.begin(), obj_pool.end())); + + // Launch threads with pointer to weak reference. + pthread_t threads[HAMMER_MAX_THREADS]; +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (HAMMER_MAX_THREADS); +#endif + + pthread_attr_t tattr; + pthread_attr_init(&tattr); + + shared_and_weak_pools pools(obj_pool, weak_pool[0]); + pthread_create(threads, &tattr, thread_hammer_and_kill, static_cast(&pools)); + for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_create(&threads[worker], &tattr, + thread_hammer, static_cast(&weak_pool[worker]))) + std::abort(); + } + // Wait for threads to complete, then check integrity of reference. + void* status; + for (unsigned int worker = 0; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_join(threads[worker], &status)) + std::abort(); + } + obj_pool.clear(); + + VERIFY( A::counter == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc new file mode 100644 index 000000000..c1ca796bb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc @@ -0,0 +1,199 @@ +// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } + +#include +#include +#include +#include +#include +#include + +#include + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif + +/* This (brute-force) tests the atomicity and thus thread safety of the + * shared_ptr <- weak_ptr + * assignment operation by allocating a test object, retrieving a weak + * reference to it, and letting a number of threads repeatedly create strong + * references from the weak reference. + * Specifically, this tests the function _Sp_counted_base::add_ref_lock() + */ + + +const unsigned int HAMMER_MAX_THREADS = 10; +const unsigned int POOL_SIZE = 1000; +const unsigned long HAMMER_REPEAT = 100000; +const unsigned long KILL_ONE_IN = 1000; + +struct A + { + static _Atomic_word counter; + A() + { + __gnu_cxx::__atomic_add(&counter, 1); + } + ~A() + { + __gnu_cxx::__atomic_add(&counter, -1); + } + }; + +_Atomic_word A::counter = 0; + +using std::_S_mutex; + +typedef std::__shared_ptr sp_A_t; +typedef std::__weak_ptr wp_A_t; + +typedef std::vector sp_vector_t; +typedef std::vector wp_vector_t; + +struct shared_and_weak_pools +{ + sp_vector_t& shared_pool; + wp_vector_t& weak_pool; + + shared_and_weak_pools(sp_vector_t& _shared_pool, wp_vector_t& _weak_pool) + : shared_pool(_shared_pool), weak_pool(_weak_pool) + { } +}; + +void* thread_hammer_and_kill(void* opaque_pools) +{ + shared_and_weak_pools& pools = *static_cast(opaque_pools); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> rng; + + sp_vector_t::iterator cur_shared = pools.shared_pool.begin(); + wp_vector_t::iterator cur_weak = pools.weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == pools.weak_pool.end()) + break; + } + + if (rng() % KILL_ONE_IN == 0) + { + cur_shared->reset(); + ++cur_shared; + } + } + return 0; +} + +void* thread_hammer(void* opaque_weak) +{ + wp_vector_t& weak_pool = *static_cast(opaque_weak); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> rng; + + wp_vector_t::iterator cur_weak = weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == weak_pool.end()) + break; + } + } + return 0; +} + +int +test01() +{ + bool test __attribute__((unused)) = true; + sp_vector_t obj_pool(POOL_SIZE); + + for(sp_vector_t::iterator cur = obj_pool.begin(); cur != obj_pool.end(); ++cur) + { + cur->reset(new A); + } + // Obtain weak references. + std::vector weak_pool(HAMMER_MAX_THREADS, wp_vector_t(obj_pool.begin(), obj_pool.end())); + + // Launch threads with pointer to weak reference. + pthread_t threads[HAMMER_MAX_THREADS]; +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (HAMMER_MAX_THREADS); +#endif + + pthread_attr_t tattr; + pthread_attr_init(&tattr); + + shared_and_weak_pools pools(obj_pool, weak_pool[0]); + pthread_create(threads, &tattr, thread_hammer_and_kill, static_cast(&pools)); + for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_create(&threads[worker], &tattr, + thread_hammer, static_cast(&weak_pool[worker]))) + std::abort(); + } + // Wait for threads to complete, then check integrity of reference. + void* status; + for (unsigned int worker = 0; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_join(threads[worker], &status)) + std::abort(); + } + obj_pool.clear(); + + VERIFY( A::counter == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc new file mode 100644 index 000000000..788f7b172 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::uninitialized_copy; + +typedef test_container container_in; +typedef test_container container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + uninitialized_copy(std::move_iterator >(incon.begin()), + std::move_iterator >(incon.end()), + outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc new file mode 100644 index 000000000..1a29613f4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::uninitialized_copy_n; + +typedef test_container container_in; +typedef test_container container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + uninitialized_copy_n(std::move_iterator >(incon.begin()), + size, outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc new file mode 100644 index 000000000..961be2fdb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.4 specialized algorithms + +// { dg-do compile } + +#include +#include + +// c++/32158 + +typedef std::pair MyPair; + +void +Alpha(MyPair* start, MyPair* end) +{ + MyPair my_pair(1, 2); + std::uninitialized_fill(start, end, my_pair); +}; diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc new file mode 100644 index 000000000..380c53d39 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.4 specialized algorithms + +// { dg-do compile } + +#include + +// libstdc++/16505 + +struct S { }; + +template + void + std::uninitialized_fill_n(S*, int, const S&); diff --git a/libstdc++-v3/testsuite/20_util/system_clock/1.cc b/libstdc++-v3/testsuite/20_util/system_clock/1.cc new file mode 100644 index 000000000..ead20873c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/system_clock/1.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.5 Clocks [time.clock] + +#include + +// 20.8.5.1 system_clock [time.clock.system] +int +main() +{ + using namespace std::chrono; + + system_clock::time_point t1 = system_clock::now(); + bool is_monotonic = system_clock::is_monotonic; + is_monotonic = is_monotonic; // suppress unused warning + std::time_t t2 = system_clock::to_time_t(t1); + system_clock::time_point t3 = system_clock::from_time_t(t2); + t3 = t3; // suppress unused warning + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc b/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc new file mode 100644 index 000000000..2407ef16a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_member_data + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::is_monotonic; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + test.operator()(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/temporary_buffer.cc b/libstdc++-v3/testsuite/20_util/temporary_buffer.cc new file mode 100644 index 000000000..b6e3d448a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/temporary_buffer.cc @@ -0,0 +1,50 @@ +// 2002-01-24 Phil Edwards + +// Copyright (C) 2002, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.4.3 temporary buffers + +#include +#include + +struct junk { char j[12]; }; + +int main(void) +{ + bool test __attribute__((unused)) = true; + + typedef std::pair pair_type; + pair_type results = std::get_temporary_buffer(5); + + if (results.second != 0) + { + // make sure it works: test the returned capacity, and then construct + // some junk in the buffer. + // XXX + VERIFY( results.first != 0 ); + } + else + { + // if it says it didn't work, make sure it didn't work + VERIFY( results.first == 0 ); + } + + std::return_temporary_buffer(results.first); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/time_point/1.cc b/libstdc++-v3/testsuite/20_util/time_point/1.cc new file mode 100644 index 000000000..e18c6e58c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/time_point/1.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.4 Class template time_point [time.point] + +#include +#include + +// 20.8.4.1 time_point constructors [time.point.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point t1; + VERIFY(t1.time_since_epoch() == system_clock::duration::zero()); + + time_point t2; + VERIFY(t2.time_since_epoch() == monotonic_clock::duration::zero()); + + time_point t3; + VERIFY(t3.time_since_epoch() == high_resolution_clock::duration::zero()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/time_point/2.cc b/libstdc++-v3/testsuite/20_util/time_point/2.cc new file mode 100644 index 000000000..8aab7ac69 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/time_point/2.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.4 Class template time_point [time.point] + +#include +#include + +// 20.8.4.3 time_point arithmetic [time.point.arithmetic] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point t1, t2; + t1 += seconds(1); + VERIFY(t2.time_since_epoch() + seconds(1) == t1.time_since_epoch()); + + t1 -= std::chrono::seconds(1); + VERIFY(t2.time_since_epoch() == t1.time_since_epoch()); +} + +// 20.8.4.5 time_point non-member arithmetic [time.point.nonmember] +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point t1; + time_point t2(t1 + seconds(1)); + VERIFY(t2.time_since_epoch() == t1.time_since_epoch() + seconds(1)); + + time_point t3(seconds(1) + t1); + VERIFY(t3.time_since_epoch() == t1.time_since_epoch() + seconds(1)); + + time_point t4(seconds(1)); + time_point t5(seconds(2)); + + time_point t6(t5 - seconds(1)); + VERIFY(t6.time_since_epoch() == t4.time_since_epoch()); + + time_point t7(t5 - t4); + VERIFY(t7.time_since_epoch() == t4.time_since_epoch()); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/time_point/3.cc b/libstdc++-v3/testsuite/20_util/time_point/3.cc new file mode 100644 index 000000000..ebf75b12f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/time_point/3.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.4 Class template time_point [time.point] + +#include +#include + +// 20.8.4.6 time_point comparisons [time.point.comparisons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point t1(seconds(1)); + time_point t2(seconds(1)); + time_point t3(seconds(2)); + + VERIFY(t1 == t2); + VERIFY(t1 != t3); + VERIFY(t1 < t3); + VERIFY(t1 <= t3); + VERIFY(t1 <= t2); + VERIFY(t3 > t1); + VERIFY(t3 >= t1); + VERIFY(t2 >= t1); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc new file mode 100644 index 000000000..427c51370 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + using namespace std::chrono; + __gnu_test::constexpr_comparison_operators test; + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/time_point/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/time_point/cons/constexpr.cc new file mode 100644 index 000000000..d12d2f164 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/time_point/cons/constexpr.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + using namespace std::chrono; + + __gnu_test::constexpr_default_constructible test1; + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator(), seconds>(); + test2.operator(), + time_point>(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/time_point/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/20_util/time_point/requirements/constexpr_functions.cc new file mode 100644 index 000000000..2beccd4ff --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/time_point/requirements/constexpr_functions.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + + constexpr _Ttesttype obj; + constexpr auto v3 __attribute__((unused)) + = obj.time_since_epoch(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + using namespace std::chrono; + __gnu_test::constexpr_member_functions test; + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..5c0455d65 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include + +template class std::chrono::time_point; diff --git a/libstdc++-v3/testsuite/20_util/time_point_cast/constexpr.cc b/libstdc++-v3/testsuite/20_util/time_point_cast/constexpr.cc new file mode 100644 index 000000000..436a4fbfc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/time_point_cast/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + using namespace std::chrono; + typedef time_point to_type; + typedef time_point from_type; + + // constexpr + constexpr minutes m(6000); + constexpr hours h(19); + constexpr to_type tpm(h); // time_point object with minutes + constexpr from_type tph(m); // time_point object with hours + + constexpr auto res(time_point_cast(tpm)); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/48476.cc b/libstdc++-v3/testsuite/20_util/tuple/48476.cc new file mode 100644 index 000000000..efe0007a6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/48476.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +template + typename std::decay::type copy(T&& x) + { return std::forward(x); } + +// libstdc++/48476 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr p(new int()), q, r; + + std::tuple&, int> t0(p, 23), t1(q, 0); + t1 = copy(t0); // shall be equivalent to + // q = p; std::get<1>(t1) = std::get<1>(t0); + VERIFY( q == p ); + + std::tuple&, char> t2(r, 0); + t2 = copy(t1); // shall be equivalent to + // r = q; std::get<1>(t2) = std::get<1>(t1); + VERIFY( r == q ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc new file mode 100644 index 000000000..613c27f8b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include + +// libstdc++/35480 +void test01() +{ + std::tuple t1( 1 ); + std::tuple t2( 1, 2 ); + if ( t1 < t2 ) {} // { dg-error "here" } + if ( t1 == t2 ) {} // { dg-error "here" } +} +// { dg-excess-errors "incomplete type" } diff --git a/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc new file mode 100644 index 000000000..c10fb1cbc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +bool test __attribute__((unused)) = true; + +#define TEST1(x) VERIFY( x == x && !(x != x) && x <= x && !(x < x) ) + +int +main() +{ + int i=0; + int j=0; + int k=2; + tuple a(0, 0, 0); + tuple b(0, 0, 1); + tuple c(i,j,k); + tuple d(c); + TEST1(a); + TEST1(b); + TEST1(c); + TEST1(d); + VERIFY(!(a > a) && !(b > b)); + VERIFY(a >= a && b >= b); + VERIFY(a < b && !(b < a) && a <= b && !(b <= a)); + VERIFY(b > a && !(a > b) && b >= a && !(a >= b)); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc new file mode 100644 index 000000000..6bd405c09 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include + +class A {}; +class B : public A {}; + +// PR libstdc++/41530 +void test01() +{ + std::tuple b; + std::tuple a1(b); + std::tuple a2(std::move(b)); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc new file mode 100644 index 000000000..dade58de8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +int x, y; + +std::tuple +foo1() +{ + std::pair blah(x, y); + return blah; +} + +std::tuple +foo2() +{ + const std::pair blah(x, y); + return blah; +} + +std::tuple +foo3() +{ + std::pair blah(x, y); + return std::tuple(std::move(blah)); +} + +std::tuple +foo4() +{ + const std::pair blah(x, y); + return std::tuple(std::move(blah)); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc new file mode 100644 index 000000000..863d78847 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +typedef std::tuple Tuple_1; +typedef std::tuple Tuple_2; +typedef std::tuple Tuple_3; + + Tuple_1 A_1() { return Tuple_1(); } +const Tuple_1 B_1() { return Tuple_1(); } + + Tuple_2 A_2() { return Tuple_2(); } +const Tuple_2 B_2() { return Tuple_2(); } + + Tuple_3 A_3() { return Tuple_3(); } +const Tuple_3 B_3() { return Tuple_3(); } + +Tuple_1 test_A_1(A_1()); +Tuple_1 test_B_1(B_1()); + +Tuple_2 test_A_2(A_2()); +Tuple_2 test_B_2(B_2()); + +Tuple_3 test_A_3(A_3()); +Tuple_3 test_B_3(B_3()); diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc new file mode 100644 index 000000000..b5e3604d2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +void f() +{ + int i = 0; + std::tuple t __attribute__((unused)) = std::forward_as_tuple(i, 0); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc new file mode 100644 index 000000000..111a398ff --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + tuple<> ta; + tuple<> tb; + ta = tb; + + tuple tc(1); + tuple td(0); + td = tc; + VERIFY(get<0>(td) == 1); + + int i=0; + tuple te(i); + te = tc; + VERIFY(i == 1); + + tuple tf(tc); + + get<0>(tc) = 2; + VERIFY(get<0>(tf) == 2); + tuple tg; + tg = tc; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc new file mode 100644 index 000000000..7bcb51771 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc @@ -0,0 +1,105 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include // for pair +#include + +using namespace std; + +// A simple class without conversions to check some things +struct foo +{ }; + +void +test_constructors() +{ + bool test __attribute__((unused)) = true; + + int x1=0,x2=0; + const int &z1=x1; + + // Test empty constructor + tuple<> ta __attribute__((unused)); + tuple tb; + // Test construction from values + tuple tc(x1,x2); + tuple td(x1,x2); + tuple te(z1); + x1=1; + x2=1; + VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1); + + // Test identical tuple copy constructor + tuple tf(tc); + tuple tg(td); + tuple th(te); + // Test different tuple copy constructor + tuple ti(tc); + tuple tj(td); + // Test constructing from a pair + pair pair1(1,1); + const pair pair2(pair1); + tuple tl(pair1); + tuple tm(pair1); + tuple tn(pair2); + tuple to(pair2); +} + +int +main(void) +{ + //test construction + typedef tuple type1; + type1 a(0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + type1 b(0, 0, 0, 0, 0, 0, 0, 0, 0, 2); + type1 c(a); + typedef tuple type2; + type2 d(0, 0, 0, 0, 0, 0, 0, 0, 0, 3); + type1 e(d); + typedef tuple type3; + // get + VERIFY(get<9>(a)==1 && get<9>(b)==2); + // comparisons + VERIFY(a==a && !(a!=a) && a<=a && a>=a && !(aa)); + VERIFY(!(a==b) && a!=b && a<=b && a=b) && !(a>b)); + //tie + { + int i = 0; + tie(ignore, ignore, ignore, ignore, ignore, ignore, ignore, ignore, + ignore, i) = a; + VERIFY(i == 1); + } + //test_assignment + a=d; + a=b; + //make_tuple + make_tuple(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + //tuple_size + VERIFY(tuple_size::value == 10); + //tuple_element + { + foo q1; + tuple_element<0,type3>::type q2(q1); + tuple_element<9,type3>::type q3(q1); + } +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr.cc new file mode 100644 index 000000000..b5eba73fd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator(), std::tuple>(); + // test2.operator(), std::pair>(); + // test2.operator(), std::tuple>(); + // test2.operator(), std::tuple>(); + + // test 3 + const int i1(129); + const int i2(6); + constexpr std::tuple p3(i1, i2); + + // test 4 + const int i3(415); + const int i4(550); + const int i5(6414); + constexpr std::tuple p4(i1, i2, i3, i4, i5); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc new file mode 100644 index 000000000..9871f4959 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include // for pair +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int x1=0,x2=0; + const int &z1=x1; + + // Test empty constructor + tuple<> ta __attribute__((unused)); + tuple tb; + // Test construction from values + tuple tc(x1,x2); + tuple td(x1,x2); + tuple te(z1); + x1=1; + x2=1; + VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1); + + // Test identical tuple copy constructor + tuple tf(tc); + tuple tg(td); + tuple th(te); + // Test different tuple copy constructor + tuple ti(tc); + tuple tj(td); + //tuple tk(tc); + tuple tl(tc); + tuple tm(tl); + // Test constructing from a pair + pair pair1(1,1); + const pair pair2(pair1); + tuple tn(pair1); + tuple to(pair1); + tuple tp(pair2); + tuple tq(pair2); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc new file mode 100644 index 000000000..def1b521d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html +std::tuple ts1; +std::tuple tu1(ts1); + +std::tuple ts2; +std::tuple tu2(ts2); + +std::tuple ts3; +std::tuple tu3(ts3); + +std::tuple tm2; +std::tuple tm2_(tm2); + +std::tuple tm3; +std::tuple tm3_(tm3); diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc new file mode 100644 index 000000000..7db57bc70 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +using namespace std; + +// libstdc++/23978 +void test01() +{ + bool test __attribute__((unused)) = true; + + pair p(1, 2); + int x = 0; + int y = 0; + tie(x, y) = p; + VERIFY( x == 1 && y == 2 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc new file mode 100644 index 000000000..1607e4552 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +template + typename std::decay::type copy(T&& x) + { return std::forward(x); } + +template + void + check_tuple_cat(std::tuple t1, std::tuple t2) + { + bool test __attribute__((unused)) = true; + + typedef std::tuple concatenated; + + auto cat1 = std::tuple_cat( t1, t2 ); + auto cat2 = std::tuple_cat(copy(t1), t2 ); + auto cat3 = std::tuple_cat( t1, copy(t2)); + auto cat4 = std::tuple_cat(copy(t1), copy(t2)); + + static_assert( std::is_same::value, "" ); + static_assert( std::is_same::value, "" ); + static_assert( std::is_same::value, "" ); + static_assert( std::is_same::value, "" ); + + VERIFY( cat1 == cat2 ); + VERIFY( cat1 == cat3 ); + VERIFY( cat1 == cat4 ); + } + +// libstdc++/48476 +void test01() +{ + int i = 0; + std::tuple<> t0; + std::tuple t1(i); + std::tuple t2(i, 0); + std::tuple t3(i, 0, 0); + + check_tuple_cat(t0, t0); + check_tuple_cat(t0, t1); + check_tuple_cat(t0, t2); + check_tuple_cat(t0, t3); + + check_tuple_cat(t1, t0); + check_tuple_cat(t1, t1); + check_tuple_cat(t1, t2); + check_tuple_cat(t1, t3); + + check_tuple_cat(t2, t0); + check_tuple_cat(t2, t1); + check_tuple_cat(t2, t2); + check_tuple_cat(t2, t3); + + check_tuple_cat(t3, t0); + check_tuple_cat(t3, t1); + check_tuple_cat(t3, t2); + check_tuple_cat(t3, t3); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc new file mode 100644 index 000000000..bad4ad49c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-04-30 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_as_tuple(); + + VERIFY( std::get<0>(std::forward_as_tuple(-1)) == -1 ); + VERIFY( (std::is_same>::value) ); + + const int i1 = 1; + const int i2 = 2; + const double d1 = 4.0; + auto t1 = std::forward_as_tuple(i1, i2, d1); + VERIFY( (std::is_same>::value) ); + VERIFY( std::get<0>(t1) == i1 ); + VERIFY( std::get<1>(t1) == i2 ); + VERIFY( std::get<2>(t1) == d1 ); + + typedef const int a_type1[3]; + a_type1 a1 = { -1, 1, 2 }; + auto t2 = std::forward_as_tuple(a1); + VERIFY( (std::is_same>::value) ); + VERIFY( std::get<0>(t2)[0] == a1[0] ); + VERIFY( std::get<0>(t2)[1] == a1[1] ); + VERIFY( std::get<0>(t2)[2] == a1[2] ); + + typedef int a_type2[2]; + a_type2 a2 = { 2, -2 }; + volatile int i4 = 1; + auto t3 = std::forward_as_tuple(a2, i4); + VERIFY( (std::is_same>::value) ); + VERIFY( std::get<0>(t3)[0] == a2[0] ); + VERIFY( std::get<0>(t3)[1] == a2[1] ); + VERIFY( std::get<1>(t3) == i4 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc new file mode 100644 index 000000000..7521111fa --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int i=0; + make_tuple(1,2,4.0); + make_tuple(ref(i)) = tuple(1); + VERIFY(i == 1); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc new file mode 100644 index 000000000..a76928979 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int x1 = 0; + int x2 = 0; + int y1 = 0; + int y2 = 0; + tuple ta(1,1); + tuple tc(x1,x2); + tie(y1,y2)=ta; + VERIFY(y1 == 1 && y2 == 1); + tie(y1,y2)=tc; + VERIFY(y1 == 0 && y2 == 0); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc new file mode 100644 index 000000000..538c3e8e1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +int +main() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + int i; + string s; + + tie(i, ignore, s) = make_tuple(42, 3.14, "C++"); + VERIFY( i == 42 ); + VERIFY( s == "C++" ); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc b/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc new file mode 100644 index 000000000..1ec01cfca --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int j=1; + const int k=2; + tuple a(0,j,k); + const tuple b(1,j,k); + VERIFY(get<0>(a)==0 && get<1>(a)==1 && get<2>(a)==2); + get<0>(a)=3; + get<1>(a)=4; + VERIFY(get<0>(a)==3 && get<1>(a)==4); + VERIFY(j==4); + get<1>(b)=5; + VERIFY(get<0>(b)==1 && get<1>(b)==5 && get<2>(b)==2); + VERIFY(j==5); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/moveable.cc b/libstdc++-v3/testsuite/20_util/tuple/moveable.cc new file mode 100644 index 000000000..0fedd83ed --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/moveable.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include +#include +#include + +int main() +{ + bool test __attribute__((unused)) = true; + + std::tuple a(1, 2.0), b; + b = std::move(a); + VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 ); + VERIFY( std::get<0>(a) == 1 && std::get<1>(a) == 2.0 ); + + std::tuple c(std::move(b)); + VERIFY( std::get<0>(c) == 1 && std::get<1>(c) == 2.0 ); + VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 ); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc b/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc new file mode 100644 index 000000000..f08007421 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +struct MoveOnly +{ + MoveOnly () { } + + MoveOnly (MoveOnly&&) { } + + MoveOnly& operator=(MoveOnly&&) + { return *this; } + +private: + MoveOnly(MoveOnly const&); // = delete + MoveOnly& operator=(MoveOnly const&); // = delete +}; + +MoveOnly +make_move_only () +{ return MoveOnly(); } + +// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00046.html +void test01() +{ + typedef std::tuple move_only_tuple; + + move_only_tuple t1(make_move_only()); + move_only_tuple t2(std::move(t1)); + move_only_tuple t3 = std::move(t2); + t1 = std::move(t3); + + typedef std::tuple move_only_tuple2; + + move_only_tuple2 t4(make_move_only(), make_move_only()); + move_only_tuple2 t5(std::move(t4)); + move_only_tuple2 t6 = std::move(t5); + t4 = std::move(t6); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc b/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc new file mode 100644 index 000000000..fd21b9ee5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 801, pair and tuple vs. "passed in registers" +void test_trivial() +{ + // PODType, TType, NType, SLType, LType, NLType, LTypeDerived + typedef std::tuple tuple_type; + // static_assert(std::is_literal_type::value, "! literal"); + static_assert(std::has_trivial_copy_constructor::value, + "! triv copy"); + static_assert(std::has_trivial_destructor::value, + "! triv destructor"); + // static_assert(std::is_standard_layout::value, + // "! standard layout"); + + // Negative + /* + static_assert(std::has_trivial_default_constructor::value, + "! triv default"); + static_assert(std::has_trivial_copy_assign::value, + "! triv assign"); + static_assert(std::is_trivial::value, "! triv"); + static_assert(std::is_pod::value, "! pod"); + */ +} + +int main() +{ + test_trivial(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..22b8f50f5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + + +#include + +template class std::tuple; diff --git a/libstdc++-v3/testsuite/20_util/tuple/swap.cc b/libstdc++-v3/testsuite/20_util/tuple/swap.cc new file mode 100644 index 000000000..613e9c2ff --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/swap.cc @@ -0,0 +1,111 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include +#include +#include + +struct MoveOnly +{ + explicit MoveOnly (int j) : i(j) { } + + MoveOnly (MoveOnly&& m) : i(m.i) { } + + MoveOnly& operator=(MoveOnly&& m) + { i = m.i; return *this; } + + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + + bool operator==(MoveOnly const& m) + { return i == m.i; } + + void swap(MoveOnly& m) + { std::swap(m.i, i); } + + int i; +}; + +void swap(MoveOnly& m1, MoveOnly& m2) +{ m1.swap(m2); } + +MoveOnly +make_move_only (int i) +{ return MoveOnly(i); } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tuple<> t1, t2; + std::swap(t1, t2); + + VERIFY( t1 == t2 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::tuple t1(1), t2(2); + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::tuple t1(1, 1.0f), t2(2, 2.0f); + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); + VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f ); +} + +void test04() +{ + bool test __attribute__((unused)) = true; + + std::tuple + t1(1, 1.0f, make_move_only(1)), + t2(2, 2.0f, make_move_only(2)); + + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); + VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f ); + VERIFY( std::get<2>(t1) == make_move_only(2) + && std::get<2>(t2) == make_move_only(1) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc b/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc new file mode 100644 index 000000000..9344ea082 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include + +using namespace std; + +struct foo +{ }; + +int +main() +{ + // As foo isn't constructible from anything else, this + // lets us check if type is returning foo when it should + foo q1; + tuple_element<0,tuple >::type q2(q1); + tuple_element<2,tuple >::type q3(q1); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc b/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc new file mode 100644 index 000000000..51f4a2db8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + VERIFY(tuple_size >::value == 0); + VERIFY(tuple_size >::value == 1); + VERIFY(tuple_size >::value == 1); + typedef tuple test_tuple1; + VERIFY(tuple_size::value == 3); + VERIFY(tuple_size > >::value == 1); +} diff --git a/libstdc++-v3/testsuite/20_util/typeindex/comparison_operators.cc b/libstdc++-v3/testsuite/20_util/typeindex/comparison_operators.cc new file mode 100644 index 000000000..5ca53967d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/typeindex/comparison_operators.cc @@ -0,0 +1,88 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-22 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +#define TEST3(TI1, TI2, TO1, TO2) \ + VERIFY( (TI1 == TI2) == (TO1 == TO2) ); \ + VERIFY( (TI1 != TI2) == (TO1 != TO2) ); \ + VERIFY( (TI1 < TI2) == (TO1.before(TO2)) ); \ + VERIFY( (TI1 <= TI2) == (!TO2.before(TO1)) ); \ + VERIFY( (TI1 > TI2) == (TO2.before(TO1)) ); \ + VERIFY( (TI1 >= TI2) == (!TO1.before(TO2)) ); + +#define TEST2(TI, TO) \ + TEST3(TI, ti1, TO, to1) \ + TEST3(TI, ti2, TO, to2) \ + TEST3(TI, ti3, TO, to3) \ + TEST3(TI, ti4, TO, to4) \ + TEST3(TI, ti5, TO, to5) \ + TEST3(TI, ti6, TO, to6) \ + TEST3(TI, ti7, TO, to7) + +#define TEST \ + TEST2(ti1, to1) \ + TEST2(ti2, to2) \ + TEST2(ti3, to3) \ + TEST2(ti4, to4) \ + TEST2(ti5, to5) \ + TEST2(ti6, to6) \ + TEST2(ti7, to7) + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + class Abraca { }; + Abraca a1, a2_; + const Abraca a2 = a2_; + + const type_info& to1 = typeid(int); + const type_index ti1(to1); + + const type_info& to2 = typeid(double); + const type_index ti2(to2); + + const type_info& to3 = typeid(Abraca); + const type_index ti3(to3); + + const type_info& to4 = typeid(const Abraca); + const type_index ti4(to4); + + const type_info& to5 = typeid(const Abraca&); + const type_index ti5(to5); + + const type_info& to6 = typeid(a1); + const type_index ti6(to6); + + const type_info& to7 = typeid(a2); + const type_index ti7(to7); + + TEST +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/typeindex/hash.cc b/libstdc++-v3/testsuite/20_util/typeindex/hash.cc new file mode 100644 index 000000000..2468ea693 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/typeindex/hash.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-22 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + class Abraca { }; + Abraca a1, a2_; + const Abraca a2 = a2_; + + const type_index ti1(typeid(int)); + VERIFY( hash()(ti1) == ti1.hash_code() ); + + const type_index ti2(typeid(double)); + VERIFY( hash()(ti2) == ti2.hash_code() ); + + const type_index ti3(typeid(Abraca)); + VERIFY( hash()(ti3) == ti3.hash_code() ); + + const type_index ti4(typeid(const Abraca)); + VERIFY( hash()(ti4) == ti4.hash_code() ); + + const type_index ti5(typeid(const Abraca&)); + VERIFY( hash()(ti5) == ti5.hash_code() ); + + const type_index ti6(typeid(a1)); + VERIFY( hash()(ti6) == ti6.hash_code() ); + + const type_index ti7(typeid(a2)); + VERIFY( hash()(ti7) == ti7.hash_code() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/typeindex/hash_code.cc b/libstdc++-v3/testsuite/20_util/typeindex/hash_code.cc new file mode 100644 index 000000000..f12b6cbb9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/typeindex/hash_code.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-22 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + class Abraca { }; + Abraca a1, a2_; + const Abraca a2 = a2_; + + const type_info& to1 = typeid(int); + const type_index ti1(to1); + VERIFY( ti1.hash_code() == to1.hash_code() ); + + const type_info& to2 = typeid(double); + const type_index ti2(to2); + VERIFY( ti2.hash_code() == to2.hash_code() ); + + const type_info& to3 = typeid(Abraca); + const type_index ti3(to3); + VERIFY( ti3.hash_code() == to3.hash_code() ); + + const type_info& to4 = typeid(const Abraca); + const type_index ti4(to4); + VERIFY( ti4.hash_code() == to4.hash_code() ); + + const type_info& to5 = typeid(const Abraca&); + const type_index ti5(to5); + VERIFY( ti5.hash_code() == to5.hash_code() ); + + const type_info& to6 = typeid(a1); + const type_index ti6(to6); + VERIFY( ti6.hash_code() == to6.hash_code() ); + + const type_info& to7 = typeid(a2); + const type_index ti7(to7); + VERIFY( ti7.hash_code() == to7.hash_code() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/typeindex/name.cc b/libstdc++-v3/testsuite/20_util/typeindex/name.cc new file mode 100644 index 000000000..fa6e6945c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/typeindex/name.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-22 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + class Abraca { }; + Abraca a1, a2_; + const Abraca a2 = a2_; + + const type_info& to1 = typeid(int); + const type_index ti1(to1); + VERIFY( ti1.name() == to1.name() ); + + const type_info& to2 = typeid(double); + const type_index ti2(to2); + VERIFY( ti2.name() == to2.name() ); + + const type_info& to3 = typeid(Abraca); + const type_index ti3(to3); + VERIFY( ti3.name() == to3.name() ); + + const type_info& to4 = typeid(const Abraca); + const type_index ti4(to4); + VERIFY( ti4.name() == to4.name() ); + + const type_info& to5 = typeid(const Abraca&); + const type_index ti5(to5); + VERIFY( ti5.name() == to5.name() ); + + const type_info& to6 = typeid(a1); + const type_index ti6(to6); + VERIFY( ti6.name() == to6.name() ); + + const type_info& to7 = typeid(a2); + const type_index ti7(to7); + VERIFY( ti7.name() == to7.name() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc new file mode 100644 index 000000000..99b412b58 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct Deleter +{ + Deleter() = default; + Deleter(const Deleter&) = default; + Deleter(Deleter&&) = default; + + Deleter& + operator=(const Deleter&) + { + bool test __attribute__((unused)) = true; + VERIFY( true ); + return *this; + } + + Deleter& + operator=(Deleter&&) + { + bool test __attribute__((unused)) = true; + VERIFY( false ); + return *this; + } + + template + void + operator()(T*) const { } +}; + +struct DDeleter : Deleter { }; + +// libstdc++/48635 +void test01() +{ + Deleter d; + + std::unique_ptr p1(nullptr, d), p2(nullptr, d); + p2 = std::move(p1); + + DDeleter dd; + + std::unique_ptr p1t(nullptr, dd); + std::unique_ptr p2t(nullptr, d); + p2t = std::move(p1t); + + std::unique_ptr p1a(nullptr, d), p2a(nullptr, d); + p2a = std::move(p1a); + + std::unique_ptr p1at(nullptr, dd); + std::unique_ptr p2at(nullptr, d); + p2at = std::move(p1at); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc new file mode 100644 index 000000000..1ed53ee2d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include + +struct D; + +struct B +{ + B& operator=(D&) = delete; // { dg-error "declared here" } + + template + void operator()(T*) const {} +}; + +struct D : B { }; + +// libstdc++/48635 +void f() +{ + B b; + D d; + + std::unique_ptr ub(nullptr, b); + std::unique_ptr ud(nullptr, d); + ub = std::move(ud); +// { dg-error "use of deleted function" "" { target *-*-* } 189 } + + std::unique_ptr uba(nullptr, b); + std::unique_ptr uda(nullptr, d); + uba = std::move(uda); +// { dg-error "use of deleted function" "" { target *-*-* } 329 } +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc new file mode 100644 index 000000000..501bad385 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include + +struct base { virtual ~base() {} }; +struct derived : base {}; + +void +test01() +{ + std::unique_ptr p1(new derived); + std::unique_ptr p2(new derived); +// p2 = p1; // should not compile + p2 = std::move(p1); + std::unique_ptr p3(new base); +// p3 = p2; // should not compile + p3 = std::move(p2); +} + +void +test02() +{ + std::unique_ptr p1(new int(420)); + std::unique_ptr p2 = p1; // { dg-error "deleted" } +} + +void +test03() +{ + std::unique_ptr p1(new int[3]); // { dg-error "no match" } + // { dg-error "candidate" "candidate-note" { target *-*-* } 48 } + std::unique_ptr p2 = p1; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc new file mode 100644 index 000000000..75529c969 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include +#include + +struct B { virtual ~B() {} }; +struct D : public B {}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + D *d = new D; + std::unique_ptr p1(d); + std::unique_ptr p2(new D); + p2 = std::move(p1); + + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == d ); + + std::unique_ptr p3(new B); + p3 = std::move(p2); + + VERIFY( p2.get() == 0 ); + VERIFY( p3.get() == d ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc new file mode 100644 index 000000000..b1b878d5d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include +#include + +struct B { virtual ~B() {} }; +struct D : public B {}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + D *d = new D[3]; + std::unique_ptr p1(d); + std::unique_ptr p2; + p2 = std::move(p1); + + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == d ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc new file mode 100644 index 000000000..6f067ee4d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include +#include + +struct A { }; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p(new A); + p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p(new A[2]); + p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc new file mode 100644 index 000000000..e3dfad46f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include + +// libstdc++/42925 (also see GB 99) +void test01() +{ + std::unique_ptr ptr; + if (ptr == 0) + { } + if (0 == ptr) + { } + if (ptr != 0) + { } + if (0 != ptr) + { } +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc new file mode 100644 index 000000000..f4b9838d0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include +#include + +struct A { }; + +// 20.9.10.2.1 unique_ptr constructors [unique.ptr.single.ctor] + +// Construction from auto_ptr +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::auto_ptr a(new A); + std::unique_ptr a2(std::move(a)); + VERIFY( a.get() == nullptr ); + VERIFY( a2.get() != 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc new file mode 100644 index 000000000..76910c3c6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include + +struct A { }; + +// 20.9.10.2.1 unique_ptr constructors [unique.ptr.single.ctor] + +// Construction from const auto_ptr +void +test01() +{ + const std::auto_ptr a(new A); + std::unique_ptr a2(std::move(a)); // { dg-error "no match" } +} +// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc new file mode 100644 index 000000000..fbe9821f9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-final { scan-assembler-not "_ZNSt10unique_ptrIiSt14default_deleteIiEEC2Ev" } } +// { dg-final { scan-assembler-not "_ZNSt10unique_ptrIiSt14default_deleteIiEEC2EDn" } } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; //not literal + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; //not literal + test2.operator(), std::nullptr_t>(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc new file mode 100644 index 000000000..1f515ea53 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include +#include + +struct A { }; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc new file mode 100644 index 000000000..324264b24 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc @@ -0,0 +1,117 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.6.11.2.1 unique_ptr constructors [unique.ptr.single.ctor] + +// Construction from pointer +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::unique_ptr A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr A_from_A(new A); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr A_from_B(new B); + VERIFY( A_from_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); +} + +void +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + A * const A_default = 0; + std::unique_ptr p1(A_default); + VERIFY( p1.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + A * const A_from_A = new A; + std::unique_ptr p2(A_from_A); + VERIFY( p2.get() == A_from_A ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc new file mode 100644 index 000000000..dcd6e92f1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.4.5.1 unique_ptr constructors [unique.ptr.cons] + +// Construction from pointer +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::unique_ptr A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr A_from_A(new A[3]); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc new file mode 100644 index 000000000..2a4a89b40 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct A +{ +}; + +struct B : A +{ + virtual ~B() { } +}; + +// 20.4.5.1 unique_ptr constructors [unique.ptr.cons] + +// Construction from pointer of derived type +void +test01() +{ + std::unique_ptr B_from_A(new A[3]); //{ dg-error "invalid conversion from" } +} + +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc new file mode 100644 index 000000000..7e88eb948 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do run } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10 Template class unique_ptr [unique.ptr] + +#include +#include + +static int count; + +void del(int* p) { ++count; delete p; } +void vdel(int* p) { ++count; delete[] p; } + +void +test01() +{ + bool test __attribute__((unused)) = true; + count = 0; + { + std::unique_ptr p(nullptr, del); + } + VERIFY( count == 0 ); + { + std::unique_ptr p(new int, del); + } + VERIFY( count == 1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + count = 0; + { + std::unique_ptr p(nullptr, vdel); + } + VERIFY( count == 0 ); + { + std::unique_ptr p(new int[1], vdel); + } + VERIFY( count == 1 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc new file mode 100644 index 000000000..e765874c7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include +#include + +using std::unique_ptr; + +// { dg-excess-errors "static assertion failed" } + +void +test01() +{ + unique_ptr p1; // { dg-error "here" } + + unique_ptr p2(nullptr); // { dg-error "here" } + + unique_ptr p3(new int); // { dg-error "here" } +} + +void +test02() +{ + unique_ptr p1; // { dg-error "here" } + + unique_ptr p2(nullptr); // { dg-error "here" } + + unique_ptr p3(new int[1]); // { dg-error "here" } +} + + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc new file mode 100644 index 000000000..53ece26ec --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-11 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + struct T { }; + + std::unique_ptr u0(new T); + std::hash> hu0; + std::hash::pointer> hp0; + + VERIFY( hu0(u0) == hp0(u0.get()) ); + + std::unique_ptr u1(new T[10]); + std::hash> hu1; + std::hash::pointer> hp1; + + VERIFY( hu1(u1) == hp1(u1.get()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc new file mode 100644 index 000000000..6dcf72919 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.9.10.2.5 unique_ptr modifiers [unique.ptr.single.modifiers] + +#include +#include + +struct D +{ + static int count; + + void operator()(int* p) const + { + ++count; + delete p; + } +}; +int D::count = 0; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr up; + up.reset(); + VERIFY( D::count == 0 ); + up.reset(new int); + VERIFY( D::count == 0 ); + up.reset(up.get()); + VERIFY( D::count == 1 ); + up.release(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc new file mode 100644 index 000000000..54948df4b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.7.1 Class template unique_ptr [unique.ptr] + +#include + +// PR libstdc++/48398 + +struct my_deleter +{ + typedef int* pointer; + + void operator()( pointer p ) { delete p; } +}; + +void test01() +{ + std::unique_ptr p( new int() ); + + p.get(); + p.reset(); + +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc new file mode 100644 index 000000000..29bb57d22 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct A +{ +}; + +struct B : A +{ + virtual ~B() { } +}; + +void test01() +{ + std::unique_ptr up; + up.reset(new A[3]); // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..dd308094b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + +#include + +template class std::unique_ptr; +template class std::unique_ptr; diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc new file mode 100644 index 000000000..55f28caaa --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc @@ -0,0 +1,50 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.11 Template class unique_ptr [unique.ptr.single] + +#include +#include + +struct A +{ + void operator()(void*) const { } +}; + +struct B +{ + typedef char* pointer; + void operator()(pointer) const { } +}; + +int main() +{ + typedef std::unique_ptr up; + typedef std::unique_ptr upA; + typedef std::unique_ptr upB; + typedef std::unique_ptr upAr; + typedef std::unique_ptr upBr; + + static_assert( std::is_same< up::pointer, int*>::value, "" ); + static_assert( std::is_same< upA::pointer, int*>::value, "" ); + static_assert( std::is_same< upB::pointer, char*>::value, "" ); + static_assert( std::is_same< upAr::pointer, int*>::value, "" ); + static_assert( std::is_same< upBr::pointer, char*>::value, "" ); +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc new file mode 100644 index 000000000..70bf90905 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include +#include + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.11.5 unqiue_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p1; + std::unique_ptr p2; + + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p1 > p2) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p1; + std::unique_ptr p2(new A); + + VERIFY( p1 != p2 ); + VERIFY( !(p1 == p2) ); + VERIFY( (p1 < p2) || (p1 > p2) ); + VERIFY( ((p1 <= p2) && (p1 != p2)) || ((p1 >= p2) && (p1 != p2)) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc new file mode 100644 index 000000000..ccb429282 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include +#include + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.11.5 unqiue_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p1; + std::unique_ptr p2; + + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p1 > p2) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p1; + std::unique_ptr p2(new A[3]); + + VERIFY( p1 != p2 ); + VERIFY( !(p1 == p2) ); + VERIFY( (p1 < p2) || (p1 > p2) ); + VERIFY( ((p1 <= p2) && (p1 != p2)) || ((p1 >= p2) && (p1 != p2)) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc new file mode 100644 index 000000000..fa0c31173 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct A {}; + +//20.6.11.5 unique_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr p1; + std::unique_ptr p2(new A); + std::unique_ptr p3; + + std::swap(p3, p2); + + VERIFY( p1 != p3 ); + VERIFY( p2 != p3 ); + VERIFY( p1 == p2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..5a43088c4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-09-27 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace std +{ + typedef short test_type; + template struct uses_allocator; +} diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/typedefs.cc new file mode 100644 index 000000000..fad654d59 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-09-27 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +void test01() +{ + // Check for required typedefs + typedef std::uses_allocator test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/value.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/value.cc new file mode 100644 index 000000000..5a7b0a8da --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/value.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-27 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +struct MyAlloc { }; + +struct MyDerivedAlloc +: public MyAlloc { }; + +struct UA { }; + +struct UB { typedef int allocator_type; }; + +struct UC { typedef MyAlloc allocator_type; }; + +struct UD { typedef MyDerivedAlloc allocator_type; }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::uses_allocator; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true))); + + // Negative tests. + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); + VERIFY( (test_relationship(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc new file mode 100644 index 000000000..046fd3c6c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x " } +// { dg-do compile } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.3 Template class weak_ptr [util.smartptr.weak] + +#include + +struct A { }; + +// 20.8.13.3.6 weak_ptr comparison [util.smartptr.weak.cmp] (removed) + +int +test01() +{ + std::weak_ptr p1; + p1 < p1; // { dg-error "no match" } + // { dg-error "candidate" "candidate note" { target *-*-* } 33 } + return 0; +} + +int +main() +{ + test01(); + return 0; +} + +// { dg-warning "note" "" { target *-*-* } 358 } +// { dg-warning "note" "" { target *-*-* } 1086 } +// { dg-warning "note" "" { target *-*-* } 468 } +// { dg-warning "note" "" { target *-*-* } 586 } +// { dg-warning "note" "" { target *-*-* } 1049 } +// { dg-warning "note" "" { target *-*-* } 1055 } +// { dg-warning "note" "" { target *-*-* } 341 } +// { dg-warning "note" "" { target *-*-* } 291 } +// { dg-warning "note" "" { target *-*-* } 207 } diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc new file mode 100644 index 000000000..6e74dd35d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-final { scan-assembler-not "_ZNSt8weak_ptrIiEC2Ev" } } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test; //not literal + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc new file mode 100644 index 000000000..ccaed290e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc @@ -0,0 +1,36 @@ +// 2006-09-24 Paolo Carlini + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.3 Template class weak_ptr [util.smartptr.weak] + +#include +#include + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +int main() +{ + using __gnu_test::check_ret_type; + using std::weak_ptr; + using std::shared_ptr; + + weak_ptr wp; + check_ret_type >(wp.lock()); +} diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc new file mode 100644 index 000000000..1081f93d3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.13.3 Template class weak_ptr [util.smartptr.weak] + +#include +#include + +struct A { }; +struct B { }; + +// 20.6.6.3.5 weak_ptr observers [util.smartptr.weak.obs] + +int +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty weak_ptrs compare equivalent + std::weak_ptr p1; + std::weak_ptr p2; + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); + + std::shared_ptr p3; + VERIFY( !p1.owner_before(p3) && !p3.owner_before(p1) ); + + return 0; +} + + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr a0; + std::weak_ptr w0(a0); + + std::shared_ptr a1(new A); + std::weak_ptr w1(a1); + VERIFY( !a1.owner_before(w1) && !w1.owner_before(a1) ); + + VERIFY( w1.owner_before(w0) || w0.owner_before(w1) ); + VERIFY( !(w1.owner_before(w0) && w0.owner_before(w1)) ); + + VERIFY( w1.owner_before(a0) || a0.owner_before(w1) ); + VERIFY( !(w1.owner_before(a0) && a0.owner_before(w1)) ); + + std::shared_ptr b1(new B); + VERIFY( w1.owner_before(b1) || b1.owner_before(w1) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..ebfc94351 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +using namespace __gnu_test; +using std::weak_ptr; +template class weak_ptr; +template class weak_ptr; +template class weak_ptr; +template class weak_ptr; diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..db49600b8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include +#include + +// Check the _S_single lock policy can be instantiated. For a thread-enabled +// library this checks the templates can be instantiated for non-default +// lock policy, for a single-threaded lib this is redundant but harmless. +using namespace __gnu_test; +using std::__weak_ptr; +using std::_S_single; +template class __weak_ptr; +template class __weak_ptr; +template class __weak_ptr; +template class __weak_ptr; -- cgit v1.2.3