Commit Graph

4375 Commits

Author SHA1 Message Date
Jonathan Wakely 4c7399e992 Fix test failure due to Networking TS headers using mutexes
Only include the Networking headers for targets with Gthreads, so that
the uses of std::mutex and std::condition_variable don't cause errors.

	* testsuite/experimental/names.cc: Only include Networking TS headers
	on targets with the necessary Gthreads support.

From-SVN: r271437
2019-05-20 21:21:15 +01:00
Marek Polacek be9e458d8b CWG 2094 - volatile scalars are trivially copyable.
PR c++/85679
	* tree.c (trivially_copyable_p): Don't check CP_TYPE_VOLATILE_P for
	scalar types.

	* g++.dg/ext/is_trivially_constructible1.C: Change the expected result
	for volatile int.
	* g++.dg/ext/is_trivially_copyable.C: New test.

	* testsuite/20_util/is_trivially_copyable/value.cc: Change the expected
	result for volatile int.

From-SVN: r271435
2019-05-20 19:10:57 +00:00
Jonathan Wakely 7f67becc98 Fix failing tests for use of non-reserved names
Defining 'ptr' fails on Solaris because it's used in <netdb.h>.

Including the Filesystem TS header fails if the TS support wasn't
enabled by configure.

	* testsuite/17_intro/names.cc: Do not check 'ptr' on Solaris.
	* testsuite/experimental/names.cc: Include <experimental/filesystem>
	conditionally.

From-SVN: r271421
2019-05-20 15:38:21 +01:00
Jonathan Wakely 58487c21b6 PR c++/90532 Ensure __is_constructible(T[]) is false
An array of an unknown bound is an incomplete type, so no object of such
a type can be constructed. This means __is_constructible should always
be false for an array of unknown bound.

This patch also changes the std::is_default_constructible trait to use
std::is_constructible, which now gives the right answer for arrays of
unknown bound.

gcc/cp:

	PR c++/90532 Ensure __is_constructible(T[]) is false
	* method.c (is_xible_helper): Return error_mark_node for construction
	of an array of unknown bound.

gcc/testsuite:

	PR c++/90532 Ensure __is_constructible(T[]) is false
	* g++.dg/ext/90532.C: New test.

libstdc++-v3:

	PR c++/90532 Ensure __is_constructible(T[]) is false
	* include/std/type_traits (__do_is_default_constructible_impl)
	(__is_default_constructible_atom, __is_default_constructible_safe):
	Remove.
	(is_default_constructible): Use is_constructible.
	* testsuite/20_util/is_constructible/value.cc: Check int[] case.
	* testsuite/20_util/is_default_constructible/value.cc: Likewise.
	* testsuite/20_util/is_trivially_constructible/value.cc: Likewise.
	* testsuite/20_util/is_trivially_default_constructible/value.cc:
	Likewise.

From-SVN: r271412
2019-05-20 12:32:51 +01:00
Jonathan Wakely eb530cab9a Fix test bug with mismatched alignment in allocate/deallocate
* testsuite/experimental/memory_resource/new_delete_resource.cc: Fix
	test by passing correct alignment to deallocate function.

From-SVN: r271408
2019-05-20 12:14:56 +01:00
Martin Sebor a9c697b883 trans.c (check_inlining_for_nested_subprog): Quote reserved names.
gcc/ada/ChangeLog:

        * gcc-interface/trans.c (check_inlining_for_nested_subprog): Quote
        reserved names.

gcc/brig/ChangeLog:

        * brigfrontend/brig-control-handler.cc
        (brig_directive_control_handler::operator): Remove trailing newline
        from a diagnostic.
        * brigfrontend/brig-module-handler.cc
        (brig_directive_module_handler::operator): Remove a duplicated space
        from a diagnostic.

gcc/c/ChangeLog:

        * c-decl.c (start_decl): Quote keywords, operators, and
        types in diagnostics.
        (finish_decl): Same.
        * c-parser.c (c_parser_asm_statement): Same.
        (c_parser_conditional_expression): Same.
        (c_parser_transaction_cancel): Same.
        * c-typeck.c (c_common_type): Same.
        (build_conditional_expr): Same.
        (digest_init): Same.
        (process_init_element): Same.
        (build_binary_op): Same.

gcc/c-family/ChangeLog:

        * c-attribs.c (handle_no_sanitize_attribute): Quote identifiers,
        keywords, operators, and types in diagnostics.
        (handle_scalar_storage_order_attribute): Same.
        (handle_mode_attribute): Same.
        (handle_visibility_attribute): Same.
        (handle_assume_aligned_attribute): Same.
        (handle_no_split_stack_attribute): Same.
        * c-common.c (shorten_compare): Same.
        (c_common_truthvalue_conversion): Same.
        (cb_get_source_date_epoch): Same.
        * c-lex.c (cb_def_pragma): Quote keywords, operators, and types
        in diagnostics.
        (interpret_float): Same.
        * c-omp.c (c_finish_omp_for): Same.
        * c-opts.c (c_common_post_options): Same.
        * c-pch.c (c_common_pch_pragma): Same.
        * c-pragma.c (pop_alignment): Same.
        (handle_pragma_pack): Same.
        (apply_pragma_weak): Same.
        (handle_pragma_weak): Same.
        (handle_pragma_scalar_storage_order): Same.
        (handle_pragma_redefine_extname): Same.
        (add_to_renaming_pragma_list): Same.
        (maybe_apply_renaming_pragma): Same.
        (push_visibility): Same.
        (handle_pragma_visibility): Same.
        (handle_pragma_optimize): Same.
        (handle_pragma_message): Same.
        * c-warn.c (warn_for_omitted_condop): Same.
        (lvalue_error): Same.

gcc/cp/ChangeLog:

        * call.c (print_z_candidate): Wrap diagnostic text in a gettext
        macro.  Adjust.
        (print_z_candidates): Same.
        (build_conditional_expr_1): Quote keywords, operators, and types
        in diagnostics.
        (build_op_delete_call): Same.
        (maybe_print_user_conv_context): Wrap diagnostic text in a gettext
        macro.
        (convert_like_real): Same.
        (convert_arg_to_ellipsis): Quote keywords, operators, and types
        in diagnostics.
        (build_over_call): Same.
        (joust): Break up an overlong line.  Wrap diagnostic text in a gettext
        macro.
        * constexpr.c (cxx_eval_check_shift_p): Spell out >= in English.
        (cxx_eval_constant_expression): Quote keywords, operators, and types
        in diagnostics.
        (potential_constant_expression_1): Same.
        * cp-gimplify.c (cp_genericize_r): Same.
        * cvt.c (maybe_warn_nodiscard): Quote keywords, operators, and types
        in diagnostics.
        (type_promotes_to): Same.
        * decl.c (check_previous_goto_1): Same.
        (check_goto): Same.
        (start_decl): Same.
        (cp_finish_decl): Avoid parenthesizing a sentence for consistency.
        (grok_op_properties): Quote keywords, operators, and types
        in diagnostics.
        * decl2.c (grokfield): Same.
        (coerce_delete_type): Same.
        * except.c (is_admissible_throw_operand_or_catch_parameter): Same.
        * friend.c (do_friend): Quote C++ tokens.
        * init.c (build_new_1): Quote keywords, operators, and types
        in diagnostics.
        (build_vec_delete_1): Same.
        (build_delete): Same.
        * lex.c (parse_strconst_pragma): Same.
        (handle_pragma_implementation): Same.
        (unqualified_fn_lookup_error): Same.
        * mangle.c (write_type): Same.
        * method.c (defaulted_late_check): Avoid two consecutive punctuators.
        * name-lookup.c (cp_binding_level_debug): Remove a trailing newline.
        (pop_everything): Same.
        * parser.c (cp_lexer_start_debugging): Quote a macro name.
        in a diagnostic
        (cp_lexer_stop_debugging): Same.
        (cp_parser_userdef_numeric_literal): Quote a C++ header name
        in a diagnostic.
        (cp_parser_nested_name_specifier_opt): Quote keywords, operators,
        and types in diagnostics.
        (cp_parser_question_colon_clause): Same.
        (cp_parser_asm_definition): Same.
        (cp_parser_init_declarator): Same.
        (cp_parser_template_declaration_after_parameters): Avoid capitalizing
        a sentence in a diagnostic.
        (cp_parser_omp_declare_reduction): Quote keywords, operators, and types
        in diagnostics.
        (cp_parser_transaction): Same.
        * pt.c (maybe_process_partial_specialization): Replace second call
        to permerror with inform for consistency with other uses.
        (expand_integer_pack): Quote keywords, operators, and types
        in diagnostics.
        * rtti.c (get_typeid): Quote keywords, operators, and types
        in diagnostics.
        (build_dynamic_cast_1): Same.
        * semantics.c (finish_asm_stmt): Same.
        (finish_label_decl): Same.
        (finish_bases): Same.
        (finish_offsetof): Same.
        (cp_check_omp_declare_reduction): Same.
        (finish_decltype_type): Same.
        * tree.c (handle_init_priority_attribute): Same.  Add detail
        to diagnostics.
        (maybe_warn_zero_as_null_pointer_constant): Same.
        * typeck.c (cp_build_binary_op): Quote keywords, operators, and types
        in diagnostics.
        (cp_build_unary_op): Same.
        (check_for_casting_away_constness): Same.
        (build_static_cast): Same.
        (build_const_cast_1): Same.
        (maybe_warn_about_returning_address_of_local): Same.
        (check_return_expr): Same.
        * typeck2.c (abstract_virtuals_error_sfinae): Same.
        (digest_init_r): Replace a tab with spaces in a diagnostic.
        (build_functional_cast): Quote keywords, operators, and types
        in diagnostics.

gcc/d/ChangeLog:

        * d-builtins.cc (d_init_builtins): Quote keywords, operators,
        and types in diagnostics.
        * d-codegen.cc (get_array_length): Same.  Replace can't with cannot.
        * d-convert.cc (convert_expr): Same.
        * d-frontend.cc (getTypeInfoType): Quote an option name in
        a diagnostic.
        * d-lang.cc (d_handle_option): Same.
        (d_parse_file): Same.
        * decl.cc: Remove a trailing period from a diagnostic.
        * expr.cc: Use a directive for an apostrophe.
        * toir.cc: Quote keywords, operators, and types in diagnostics.
        * typeinfo.cc (build_typeinfo): Quote an option name in a diagnostic.

gcc/fortran/ChangeLog:

	* gfortranspec.c (append_arg): Spell out the word "argument."

gcc/ChangeLog:

        * config/i386/i386-expand.c (get_element_number): Quote keywords
        and other internal names in diagnostics.  Adjust other diagnostic
        formatting issues noted by -Wformat-diag.
        * config/i386/i386-features.c
        (ix86_mangle_function_version_assembler_name): Same.
        * config/i386/i386-options.c (ix86_handle_abi_attribute): Same.
        * config/i386/i386.c (ix86_function_type_abi): Same.
        (ix86_function_ms_hook_prologue): Same.
        (classify_argument): Same.
        (ix86_expand_prologue): Same.
        (ix86_md_asm_adjust): Same.
        (ix86_memmodel_check): Same.

gcc/ChangeLog:

        * builtins.c (expand_builtin_atomic_always_lock_free): Quote
        identifiers, keywords, operators, and types in diagnostics.  Correct
        quoting, spelling, and sentence capitalization issues.
        (expand_builtin_atomic_is_lock_free): Same.
        (fold_builtin_next_arg): Same.
        * cfgexpand.c (expand_one_var): Same.
        (tree_conflicts_with_clobbers_p): Same.
        (expand_asm_stmt): Same.
        (verify_loop_structure): Same.
        * cgraphunit.c (process_function_and_variable_attributes): Same.
        * collect-utils.c (collect_execute): Same.
        * collect2.c (maybe_run_lto_and_relink): Same.
        (is_lto_object_file): Same.
        (scan_prog_file): Same.
        * convert.c (convert_to_real_1): Same.
        * dwarf2out.c (dwarf2out_begin_prologue): Same.
        * except.c (verify_eh_tree): Same.
        * gcc.c (execute): Same.
        (eval_spec_function): Same.
        (run_attempt): Same.
        (driver::set_up_specs): Same.
        (compare_debug_auxbase_opt_spec_function): Same.
        * gcov-tool.c (unlink_gcda_file): Same.
        (do_merge): Same.
        (do_rewrite): Same.
        * gcse.c (gcse_or_cprop_is_too_expensive): Same.
        * gimplify.c (gimplify_asm_expr): Same.
        (gimplify_adjust_omp_clauses): Same.
        * hsa-gen.c (gen_hsa_addr_insns): Same.
        (gen_hsa_insns_for_load): Same.
        (gen_hsa_cmp_insn_from_gimple): Same.
        (gen_hsa_insns_for_operation_assignment): Same.
        (gen_get_level): Same.
        (gen_hsa_alloca): Same.
        (omp_simple_builtin::generate): Same.
        (gen_hsa_atomic_for_builtin): Same.
        (gen_hsa_insns_for_call): Same.
        * input.c (dump_location_info): Same.
        * ipa-devirt.c (compare_virtual_tables): Same.
        * ira.c (ira_setup_eliminable_regset): Same.
        * lra-assigns.c (lra_assign): Same.
        * lra-constraints.c (lra_constraints): Same.
        * lto-streamer-in.c (lto_input_mode_table): Same.
        * lto-wrapper.c (get_options_from_collect_gcc_options): Same.
        (merge_and_complain): Same.
        (compile_offload_image): Same.
        (compile_images_for_offload_targets): Same.
        (debug_objcopy): Same.
        (run_gcc): Same.
        (main): Same.
        * opts.c (print_specific_help): Same.
        (parse_no_sanitize_attribute): Same.
        (print_help): Same.
        (handle_param): Same.
        * plugin.c (add_new_plugin): Same.
        (parse_plugin_arg_opt): Same.
        (try_init_one_plugin): Same.
        * print-rtl.c (debug_bb_n_slim): Quote identifiers, keywords,
        operators, and types in diagnostics.  Correct quoting and spelling
        issues.
        * read-rtl-function.c (parse_edge_flag_token): Same.
        (function_reader::parse_enum_value): Same.
        * reg-stack.c (check_asm_stack_operands): Same.
        * regcprop.c (validate_value_data): Same.
        * sched-rgn.c (make_pass_sched_fusion): Same.
        * stmt.c (check_unique_operand_names): Same.
        * targhooks.c (default_target_option_pragma_parse): Same.
        * tlink.c (recompile_files): Same.
        * toplev.c (process_options): Same.
        (do_compile): Same.
        * trans-mem.c (diagnose_tm_1): Same.
        (ipa_tm_scan_irr_block): Same.
        (ipa_tm_diagnose_transaction): Same.
        * tree-cfg.c (verify_address): Same.  Use get_tree_code_name to
        format a tree code name in a diagnostic.
        (verify_types_in_gimple_min_lval): Same.
        (verify_types_in_gimple_reference): Same.
        (verify_gimple_call): Same.
        (verify_gimple_assign_unary): Same.
        (verify_gimple_assign_binary): Same.
        (verify_gimple_assign_ternary): Same.
        (verify_gimple_assign_single): Same.
        (verify_gimple_switch): Same.
        (verify_gimple_label): Same.
        (verify_gimple_phi): Same.
        (verify_gimple_in_seq): Same.
        (verify_eh_throw_stmt_node): Same.
        (collect_subblocks): Same.
        (gimple_verify_flow_info): Same.
        (do_warn_unused_result): Same.
        * tree-inline.c (expand_call_inline): Same.
        * tree-into-ssa.c (update_ssa): Same.
        * tree.c (tree_int_cst_elt_check_failed): Same.
        (tree_vec_elt_check_failed): Same.
        (omp_clause_operand_check_failed): Same.
        (verify_type_variant): Same.
        (verify_type): Same.
        * value-prof.c (verify_histograms): Same.
        * varasm.c (assemble_start_function): Same.

gcc/lto/ChangeLog:

        * lto-dump.c (lto_main): Same.
        * lto.c (stream_out): Same.

gcc/objc/ChangeLog:

        * objc-act.c (objc_begin_catch_clause): Quote keywords and options
        in diagnostics.
        (objc_build_throw_stmt): Same.
        (objc_finish_message_expr): Same.
        (get_super_receiver): Same.
        * objc-next-runtime-abi-01.c (objc_next_runtime_abi_01_init): Spell
        out "less than" in English./
        * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Spell
        out "greater" in English.

gcc/testsuite/ChangeLog:

        * c-c++-common/Wbool-operation-1.c: Adjust text of expected diagnostics.
        * c-c++-common/Wvarargs-2.c: Same.
        * c-c++-common/Wvarargs.c: Same.
        * c-c++-common/pr51768.c: Same.
        * c-c++-common/tm/inline-asm.c: Same.
        * c-c++-common/tm/safe-1.c: Same.
        * g++.dg/asm-qual-1.C: Same.
        * g++.dg/asm-qual-3.C: Same.
        * g++.dg/conversion/dynamic1.C: Same.
        * g++.dg/cpp0x/constexpr-89599.C: Same.
        * g++.dg/cpp0x/constexpr-cast.C: Same.
        * g++.dg/cpp0x/constexpr-shift1.C: Same.
        * g++.dg/cpp0x/lambda/lambda-conv11.C: Same.
        * g++.dg/cpp0x/nullptr04.C: Same.
        * g++.dg/cpp0x/static_assert12.C: Same.
        * g++.dg/cpp0x/static_assert8.C: Same.
        * g++.dg/cpp1y/lambda-conv1.C: Same.
        * g++.dg/cpp1y/pr79393-3.C: Same.
        * g++.dg/cpp1y/static_assert1.C: Same.
        * g++.dg/cpp1z/constexpr-if4.C: Same.
        * g++.dg/cpp1z/constexpr-if5.C: Same.
        * g++.dg/cpp1z/constexpr-if9.C: Same.
        * g++.dg/eh/goto2.C: Same.
        * g++.dg/eh/goto3.C: Same.
        * g++.dg/expr/static_cast8.C: Same.
        * g++.dg/ext/flexary5.C: Same.
        * g++.dg/ext/utf-array-short-wchar.C: Same.
        * g++.dg/ext/utf-array.C: Same.
        * g++.dg/ext/utf8-2.C: Same.
        * g++.dg/gomp/loop-4.C: Same.
        * g++.dg/gomp/macro-4.C: Same.
        * g++.dg/gomp/udr-1.C: Same.
        * g++.dg/init/initializer-string-too-long.C: Same.
        * g++.dg/other/offsetof9.C: Same.
        * g++.dg/ubsan/pr63956.C: Same.
        * g++.dg/warn/Wbool-operation-1.C: Same.
        * g++.dg/warn/Wtype-limits-Wextra.C: Same.
        * g++.dg/warn/Wtype-limits.C: Same.
        * g++.dg/wrappers/pr88680.C: Same.
        * g++.old-deja/g++.mike/eh55.C: Same.
        * gcc.dg/Wsign-compare-1.c: Same.
        * gcc.dg/Wtype-limits-Wextra.c: Same.
        * gcc.dg/Wtype-limits.c: Same.
        * gcc.dg/Wunknownprag.c: Same.
        * gcc.dg/Wunsuffixed-float-constants-1.c: Same.
        * gcc.dg/asm-6.c: Same.
        * gcc.dg/asm-qual-1.c: Same.
        * gcc.dg/cast-1.c: Same.
        * gcc.dg/cast-2.c: Same.
        * gcc.dg/cast-3.c: Same.
        * gcc.dg/cpp/source_date_epoch-2.c: Same.
        * gcc.dg/debug/pr85252.c: Same.
        * gcc.dg/dfp/cast-bad.c: Same.
        * gcc.dg/format/gcc_diag-1.c: Same.
        * gcc.dg/format/gcc_diag-11.c: Same.New test.
        * gcc.dg/gcc_diag-11.c: Same.New test.
        * gcc.dg/gnu-cond-expr-2.c: Same.
        * gcc.dg/gnu-cond-expr-3.c: Same.
        * gcc.dg/gomp/macro-4.c: Same.
        * gcc.dg/init-bad-1.c: Same.
        * gcc.dg/init-bad-2.c: Same.
        * gcc.dg/init-bad-3.c: Same.
        * gcc.dg/pr27528.c: Same.
        * gcc.dg/pr48552-1.c: Same.
        * gcc.dg/pr48552-2.c: Same.
        * gcc.dg/pr59846.c: Same.
        * gcc.dg/pr61096-1.c: Same.
        * gcc.dg/pr8788-1.c: Same.
        * gcc.dg/pr90082.c: Same.
        * gcc.dg/simd-2.c: Same.
        * gcc.dg/spellcheck-params-2.c: Same.
        * gcc.dg/spellcheck-params.c: Same.
        * gcc.dg/strlenopt-49.c: Same.
        * gcc.dg/tm/pr52141.c: Same.
        * gcc.dg/torture/pr51106-1.c: Same.
        * gcc.dg/torture/pr51106-2.c: Same.
        * gcc.dg/utf-array-short-wchar.c: Same.
        * gcc.dg/utf-array.c: Same.
        * gcc.dg/utf8-2.c: Same.
        * gcc.dg/warn-sprintf-no-nul.c: Same.
        * gcc.target/i386/asm-flag-0.c: Same.
        * gcc.target/i386/inline_error.c: Same.
        * gcc.target/i386/pr30848.c: Same.
        * gcc.target/i386/pr39082-1.c: Same.
        * gcc.target/i386/pr39678.c: Same.
        * gcc.target/i386/pr57756.c: Same.
        * gcc.target/i386/pr68843-1.c: Same.
        * gcc.target/i386/pr79804.c: Same.
        * gcc.target/i386/pr82673.c: Same.
        * obj-c++.dg/class-protocol-1.mm: Same.
        * obj-c++.dg/exceptions-3.mm: Same.
        * obj-c++.dg/exceptions-4.mm: Same.
        * obj-c++.dg/exceptions-5.mm: Same.
        * obj-c++.dg/exceptions-6.mm: Same.
        * obj-c++.dg/method-12.mm: Same.
        * obj-c++.dg/method-13.mm: Same.
        * obj-c++.dg/method-6.mm: Same.
        * obj-c++.dg/method-7.mm: Same.
        * obj-c++.dg/method-9.mm: Same.
        * obj-c++.dg/method-lookup-1.mm: Same.
        * obj-c++.dg/proto-lossage-4.mm: Same.
        * obj-c++.dg/protocol-qualifier-2.mm: Same.
        * objc.dg/call-super-2.m: Same.
        * objc.dg/class-protocol-1.m: Same.
        * objc.dg/desig-init-1.m: Same.
        * objc.dg/exceptions-3.m: Same.
        * objc.dg/exceptions-4.m: Same.
        * objc.dg/exceptions-5.m: Same.
        * objc.dg/exceptions-6.m: Same.
        * objc.dg/method-19.m: Same.
        * objc.dg/method-2.m: Same.
        * objc.dg/method-5.m: Same.
        * objc.dg/method-6.m: Same.
        * objc.dg/method-7.m: Same.
        * objc.dg/method-lookup-1.m: Same.
        * objc.dg/proto-hier-1.m: Same.
        * objc.dg/proto-lossage-4.m: Same.

From-SVN: r271338
2019-05-17 11:55:43 -06:00
François Dumont 6f1becb660 2019-05-17 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_deque.h
	(_Deque_iterator<>::__ptr_to): Remove, use std::__ptr_rebind.
	(_Deque_base(_Deque_base&&, const allocator_type&)): New.
	(_Deque_base::_Deque_impl_data): New.
	(_Deque_base::_Deque_impl): Inherit latter.
	(_Deque_base::_Deque_impl::_M_swap_data): Move...
	(_Deque_base::_Deque_impl_data::_M_swap_data): ... here.
	(_Deque_base::_Deque_impl()): Add noexcept qualification.
	(_Deque_base::_Deque_impl(_Deque_impl&&, _Tp_alloc_type&&)): New.
	(_Deque_base::_Deque_impl::_M_get_Tp_allocator()): Remove static_cast.
	(deque<>::deque()): Default.
	(deque<>::deque(deque&&)): Default.
	(deque<>::deque(deque&&, const allocator_type&, false_type)): New.
	(deque<>::deque(deque&&, const allocator_type&, true_type)): New.
	(deque<>::deque(deque&&, const allocator_type&)): Delegate to latters.
	(deque<>::deque<_It>(_It, _It, const allocator_type&)): Use
	_M_range_initialize.
	(deque<>::assign<_It>(_It, _It)): Use _M_assign_aux.
	(deque<>::resize(size_type, const value_type&)): Share a single
	implementation.
	(deque<>::insert<_It>(const_iterator, _It, _It)): Use
	_M_range_insert_aux.
	[__cplusplus >= 201103L](_M_initialize_dispatch): Remove.
	[__cplusplus >= 201103L](_M_assign_dispatch): Remove.
	[__cplusplus >= 201103L](_M_insert_dispatch): Remove.
	* testsuite/23_containers/deque/allocator/default_init.cc: New.

From-SVN: r271330
2019-05-17 16:27:54 +00:00
Jonathan Wakely ac781bc880 Fix std::variant test for ILP32 targets
* testsuite/20_util/variant/compile.cc: Fix narrowing test for ILP32
	targets. Add more cases from P0608R3.
	* testsuite/20_util/variant/run.cc: Add more cases from P0608R3.

From-SVN: r271325
2019-05-17 15:13:43 +01:00
Jonathan Wakely 593cda3e61 Fix uses of non-reserved names for template parameters
* include/bits/random.h (seed_seq::param): Fix non-reserved name.
	* include/experimental/type_traits (is_detected_exact)
	(is_detected_exact_v): Likewise.
	* include/pstl/execution_defs.h (is_execution_policy)
	(is_execution_policy_v, __enable_if_execution_policy): Likewise.
	* include/pstl/execution_impl.h (__policy_traits): Likewise.
	* testsuite/17_intro/names.cc: Check for more non-reserved names.
	* testsuite/experimental/names.cc: New test.

From-SVN: r271324
2019-05-17 15:13:40 +01:00
Jonathan Wakely e625ccc21a PR libstdc++/85965 move is_invocable assertions again
This is another attempt to reduce how often the assertions are
evaluated, so that code which doesn't try to use the function objects
doesn't need them to be invocable.

For _Rb_tree we access the _M_key_compare object directly, so can't put
the assertions in an accessor function for it. However, every invocation
of _M_key_compare is accompanied by a use of _S_key, so the assertions
can be put in there.  For _Hashtable there are member functions that are
consistently used to obtain a hash code or test for equality, so the
assertions can go in those members.

	PR libstdc++/85965
	* include/bits/hashtable.h (_Hashtable::~_Hashtable()): Remove static
	assertions from the destructor.
	* include/bits/hashtable_policy.h (_Hash_code_base::_M_hash_code):
	Move static_assert for hash function to here.
	(_Hash_table_base::_M_equals): Move static_assert for equality
	predicate to here.
	* include/bits/stl_tree.h (_Rb_tree::_S_value(_Const_Link_type)):
	Remove.
	(_Rb_tree::_S_key(_Const_Link_type)): Move assertions here. Access
	the value directly instead of calling _S_value.
	(_Rb_tree::_S_value(_Const_Base_ptr)): Remove.
	(_Rb_tree::_S_key(_Const_Base_ptr)): Do downcast and forward to
	_S_key(_Const_Link_type).
	* testsuite/23_containers/set/85965.cc: Check construction,
	destruction, assignment and size() do not trigger the assertions.
	* testsuite/23_containers/unordered_set/85965.cc: Likewise.
	* testsuite/23_containers/map/48101_neg.cc: Call find and adjust
	expected errors.
	* testsuite/23_containers/multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/multiset/48101_neg.cc: Likewise.
	* testsuite/23_containers/set/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_map/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_set/48101_neg.cc: Likewise.

From-SVN: r271323
2019-05-17 15:13:32 +01:00
François Dumont 935469daaa Move from state of allocators (LWG2593)
2019-05-17  François Dumont  <fdumont@gcc.gnu.org>

	Move from state of allocators (LWG2593)
	* include/bits/stl_deque.h
	(_Deque_base(_Deque_base&&, false_type)): Remove.
	(_Deque_base(_Deque_base&&, true_type)): Remove.
	(_Deque_base(_Deque_base&&)): Adapt.
	(_Deque_base::_M_move_impl()): Remove.
	* testsuite/util/testsuite_allocator.h
	(propagating_allocator(propagating_allocator&&)): Preserve move from
	state.
	* testsuite/23_containers/deque/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/forward_list/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/list/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/map/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/multimap/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/multiset/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/set/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/unordered_map/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_set/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/vector/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/vector/bool/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/21_strings/basic_string/allocator/char/move_assign.cc
	(test02): Adapt.
	* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
	(test02): Adapt.

From-SVN: r271309
2019-05-17 04:55:37 +00:00
Jonathan Wakely d069df01ed Implement sane variant converting constructor (P0608R3)
* include/std/variant (__overload_set): Remove.
	(_Arr): New helper.
	(_Build_FUN): New class template to define a single FUN overload,
	with specializations to prevent unwanted conversions, as per P0608R3.
	(_Build_FUNs): New class template to build an overload set of FUN.
	(_FUN_type): New alias template to perform overload resolution.
	(__accepted_type): Use integer_constant base for failure case. Use
	_FUN_type for successful case.
	(variant::__accepted_index): Use _Tp instead of _Tp&&.
	(variant::variant(_Tp&&)): Likewise.
	(variant::operator=(_Tp&&)): Likewise.

From-SVN: r271296
2019-05-16 21:30:35 +01:00
Jonathan Wakely ff8b2a0acb Fix NullablePointer test utility
* testsuite/util/testsuite_allocator.h (NullablePointer::operator bool):
	Fix return value.

From-SVN: r271189
2019-05-14 21:01:28 +01:00
Rainer Orth ccd1242eec Remove obsolete Solaris 10 support
libstdc++-v3:
	* config/os/solaris/solaris2.10: Move to ...
	* config/os/solaris: ... this.
	* configure.host (os_include_dir): Adapt.
	(abi_baseline_pair): Remove Solaris 10 handling.
	* config/abi/post/i386-solaris2.10: Remove.
	* config/abi/post/sparc-solaris2.10: Remove.
	* config/abi/post/i386-solaris2.11: Rename to ...
	* config/abi/post/i386-solaris: ... this.
	* config/abi/post/sparc-solaris2.11: Rename to ...
	* config/abi/post/sparc-solaris: ... this.

	* libsupc++/new_opa.cc [_GLIBCXX_HAVE_MEMALIGN] [__sun]: Remove
	workaround.

	* testsuite/ext/enc_filebuf/char/13598.cc: Remove *-*-solaris2.10
	xfail.

	libsanitizer:
	* configure.ac (have_dl_iterate_phdr): Remove *-*-solaris2.10*
	handling.
	* configure: Regenerate.

	libgcc:
	* config.host: Simplify various *-*-solaris2.1[0-9]* to
	*-*-solaris2*.
	* configure.ac: Likewise.
	* configure: Regenerate.

	* config/i386/sol2-unwind.h (x86_fallback_frame_state): Remove
	Solaris 10 and Solaris 11 < snv_125 handling.

	libbacktrace:
	* configure.ac (have_dl_iterate_phdr): Remove *-*-solaris2.10*
	handling.
	* configure: Regenerate.

	gcc/testsuite:
	* gcc.dg/atomic/c11-atomic-exec-4.c: Simplify triplet to
	*-*-solaris2*.
	* gcc.dg/atomic/c11-atomic-exec-5.c: Likewise.
	* gcc.dg/c99-math-double-1.c: Likewise.
	* gcc.dg/c99-math-float-1.c: Likewise.
	* gcc.dg/c99-math-long-double-1.c: Likewise.
	* gcc.misc-tests/linkage.exp: Simplify triplet to
	x86_64-*-solaris2*.

	* gcc.target/i386/mcount_pic.c: Remove *-*-solaris2.10* && !gld
	xfail.
	* gcc.target/i386/pr63620.c: Likewise.

	* lib/target-supports.exp (check_sse_os_support_available): Remove
	Solaris 9/x86 workaround.

	gcc:
	* config.gcc: Move *-*-solaris2.10* from obsolete configurations
	to unsupported ones.
	Simplify x86_64-*-solaris2.1[0-9]* to x86_64-*-solaris2*.
	* config.host: Likewise.
	* config/i386/sol2.h (ASM_COMMENT_START): Remove.
	* config/sparc/driver-sparc.c (host_detect_local_cpu) [__sun__ &&
	__svr4__]: Remove "brand" fallback.
	[!KSTAT_DATA_STRING]: Remove.
	* configure.ac (gcc_cv_ld_hidden): Simplify *-*-solaris2.1[0-9]*
	to *-*-solaris2*.
	(comdat_group): Likewise.
	(set_have_as_tls): Likewise.
	(gcc_cv_target_dl_iterate_phdr): Likewise.
	(gcc_cv_as_shf_merge): Remove Solaris 10/x86 workaround.
	(gcc_cv_ld_aligned_shf_merge): Remove Solaris 10/SPARC workaround.
	* configure: Regenerate.
	* doc/install.texi: Simplify Solaris target triplets.
	(Specific, i?86-*-solaris2*): Remove Solaris 10 references.
	(Specific, *-*-solaris2*): Document Solaris 10 removal.
	Remove Solaris 10 references.
	Remove obsolete Solaris bug reference.
	(Specific, sparc-sun-solaris2.10): Remove.

From-SVN: r271183
2019-05-14 17:17:23 +00:00
Nina Dinka Ranns a73d2fa852 nonesuch is insufficiently useless (lwg2996)
2019-05-14  Nina Dinka Ranns  <dinka.ranns@gmail.com>

	nonesuch is insufficiently useless (lwg2996)
	* include/std/type_traits (struct __nonesuch): Added private base
	class to make __nonesuch not an aggregate and removed deleted default
	constructor.
	* include/bits/stl_pair.h (struct __nonesuch_no_braces): Removed.
	(operator=(const pair&)): Use __nonesuch instead of
	__nonesuch_no_braces.
	(operator=(pair&&)): Likewise
	* include/std/tuple (operator=(const tuple&)): Use __nonesuch instead
	of __nonesuch_no_braces.
	(operator=(tuple&&)): Likewise
	* include/experimental/type_traits (struct nonesuch): Added private
	base class to make nonesuch not an aggregate and removed deleted
	default constructor.
	* testsuite/20_util/nonesuch/nonesuch.cc: New.
	* testsuite/experimental/type_traits/nonesuch.cc: New.

From-SVN: r271175
2019-05-14 16:48:27 +01:00
Jonathan Wakely 78c2855df6 Define std::__invoke_r for INVOKE<R>
* include/bits/invoke.h (__invoke_r): Define new function implementing
	the INVOKE<R> pseudo-function.
	* testsuite/20_util/function_objects/invoke/1.cc: Add more tests.
	* testsuite/20_util/function_objects/invoke/2.cc: New test.

From-SVN: r271173
2019-05-14 16:25:01 +01:00
Jonathan Wakely ce9f305e44 Add __is_nothrow_convertible to fix std::is_nothrow_invocable_r
The definition of is_nothrow_invocable in terms of is_convertible and
is_nothrow_constructible is incorrect, because a type could have an
explicit constructor that means is_nothrow_constructible is true, but
implicit conversions could use a different constructor that is
potentially-throwing.

Fix it by adding a C++11 version of C++20's is_nothrow_convertible that
only considers implicit conversions.

	* include/std/type_traits (__is_nt_convertible_helper): Define it
	unconditionally, not only for C++20.
	(__is_nothrow_convertible): Define internal trait for use in C++11.
	(__is_nt_invocable_impl: Fix by using __is_nothrow_convertible.
	(is_invocable_r_v, is_nothrow_invocable_r_v): Add missing parameter.
	* testsuite/20_util/is_nothrow_convertible/value_ext.cc: New test.
	* testsuite/20_util/is_nothrow_convertible/value.cc: Check with type
	that has nothrow explicit conversion but potentially-throwing implicit
	conversion.
	* testsuite/20_util/is_nothrow_invocable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_invocable/value_ext.cc: Fix helper
	function to only consider implicit conversions.
	* testsuite/20_util/tuple/cons/noexcept_specs.cc: Add comment.

From-SVN: r271171
2019-05-14 15:39:58 +01:00
Jonathan Wakely 8db7a05fd7 PR libstdc++/69724 avoid temporary in std::thread construction
The std::thread constructor creates (and then moves) an unnecessary
temporary copy of each argument. Optimize it to only make the one copy
that is required.

	PR libstdc++/69724
	* include/std/thread (thread::_State_impl, thread::_S_make_state):
	Replace single _Callable parameter with variadic _Args pack, to
	forward them directly to the tuple of decayed copies.
	* testsuite/30_threads/thread/cons/69724.cc: New test.

From-SVN: r271166
2019-05-14 13:01:15 +01:00
Nina Dinka Ranns db33efde17 Inconsistency wrt Allocators in basic_string assignment (LWG2579)
2019-05-14  Nina Dinka Ranns  <dinka.ranns@gmail.com>

	Inconsistency wrt Allocators in basic_string assignment (LWG2579)
	* include/bits/basic_string.h: (operator=(const basic_string&):
	Move allocator decision to assign.
	(assign(const basic_string&)): Move allocator decision here.
	* testsuite/21_strings/basic_string/allocator/char/copy_assign.cc:
	Add tests.
	* testsuite/21_strings/basic_string/allocator/wchar_t/copy_assign.cc:
	Add tests.

From-SVN: r271165
2019-05-14 12:48:31 +01:00
Jonathan Wakely c688848d6a Fix indentation in testsuite utility header
* testsuite/util/testsuite_allocator.h (memory_resource)
	(default_resource_mgr): Fix indentation.

From-SVN: r271161
2019-05-14 12:17:27 +01:00
Jonathan Wakely 066f9ea279 Add __gnu_test::NullablePointer utility to testsuite
* testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc:
	Use operator-> to access raw pointer member.
	* testsuite/23_containers/vector/59829.cc: Likewise.
	* testsuite/23_containers/vector/bool/80893.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Use NullablePointer.
	* testsuite/util/testsuite_allocator.h (NullablePointer): New utility
	for tests.
	(PointerBase, PointerBase_void): Derive from NullablePointer and use
	its constructors and equality operators. Change converting
	constructors to use operator-> to access private member of the other
	pointer type.
	(PointerBase_void::operator->()): Add, for access to private member.
	(operator-(PointerBase, PointerBase)): Change to hidden friend.
	(operator==(PointerBase, PointerBase)): Remove.
	(operator!=(PointerBase, PointerBase)): Remove.

From-SVN: r271160
2019-05-14 12:17:23 +01:00
Jonathan Wakely e25f488d60 Fix unique_ptr pretty printer for empty classes
The printer was confused when unique_ptr<T,D>::pointer is an empty
class, or the deleter is not empty. Instead of assuming the tuple has a
single _M_head_impl member manually inspect the tuple base classes to
get the first element.

	* python/libstdcxx/v6/printers.py (UniquePointerPrinter.__init__): Do
	not assume field called _M_head_impl is the first tuple element.
	* testsuite/libstdc++-prettyprinters/compat.cc: Make tuple
	implementation more accurate.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Check unique_ptr with
	empty pointer type and non-empty deleter.

From-SVN: r271159
2019-05-14 12:17:18 +01:00
Jonathan Wakely 1b18663e0f LWG 2899 - Make is_move_constructible correct for unique_ptr
* include/bits/unique_ptr.h (__uniq_ptr_impl): Add move constructor,
	move assignment operator.
	(__uniq_ptr_impl::release(), __uniq_ptr_impl::reset(pointer)): Add.
	(__uniq_ptr_data): New class template with conditionally deleted
	special members.
	(unique_ptr, unique_ptr<T[], D>): Change type of data member from
	__uniq_ptr_impl<T, D> to __uniq_ptr_data<T, D>. Define move
	constructor and move assignment operator as defaulted.
	(unique_ptr::release(), unique_ptr<T[], D>::release()): Forward to
	__uniq_ptr_impl::release().
	(unique_ptr::reset(pointer), unique_ptr<T[], D>::reset<U>(U)): Forward
	to __uniq_ptr_impl::reset(pointer).
	* python/libstdcxx/v6/printers.py (UniquePointerPrinter.__init__):
	Check for new __uniq_ptr_data type.
	* testsuite/20_util/unique_ptr/dr2899.cc: New test.

From-SVN: r271158
2019-05-14 12:17:11 +01:00
Jonathan Wakely bceb07e358 PR libstdc++/90454.cc path construction from void*
Make the filesystem::path constructors SFINAE away for void* arguments,
instead of giving an error due to iterator_traits<void*>::reference.

	PR libstdc++/90454.cc path construction from void*
	* include/bits/fs_path.h (path::_Path): Use remove_pointer so that
	pointers to void are rejected as well as void.
	* include/experimental/bits/fs_path.h (path::_Path): Likewise.
	* testsuite/27_io/filesystem/path/construct/80762.cc: Also check
	pointers to void.
	* testsuite/experimental/filesystem/path/construct/80762.cc: Likewise.

From-SVN: r271134
2019-05-13 21:12:06 +01:00
Jonathan Wakely 544be2beb1 Remove Profile Mode, deprecated since GCC 7.1
The Profile Mode extension is not used by anybody, nor maintained by
anybody. The containers do not support the full API specified in recent
standards, and so enabling Profile Mode is not source compatible with
much modern C++ code. The heuristics that would check the profile
information and make useful suggestions never materialized, so it isn't
useful.

It should be removed.

	Remove Profile Mode, deprecated since 7.1.0
	* doc/Makefile.am: Remove XML file for profile mode docs.
	* doc/Makefile.in: Regenerate.
	* doc/xml/authors.xml: Remove authors of profile mode docs.
	* doc/xml/manual/appendix_contributing.xml: Remove mention of profile
	mode.
	* doc/xml/manual/debug.xml: Likewise.
	* doc/xml/manual/evolution.xml: Document removal of profile mode.
	* doc/xml/manual/profile_mode.xml: Remove profile mode docs.
	* doc/xml/manual/spine.xml: Remove profile mode author credit.
	* doc/xml/manual/test.xml: Remove docs for dg-require-profile-mode
	directive.
	* doc/xml/manual/using.xml: Remove docs for profile mode headers and
	macro.
	* doc/html/*: Regenerate.
	* include/Makefile.am: Remove profile mode headers.
	* include/Makefile.in: Regenerate.
	* include/bits/c++config (std::__profile): Remove namespace.
	[_GLIBCXX_PROFILE]: Remove checks for macro.
	* include/profile/array: Remove.
	* include/profile/base.h: Remove.
	* include/profile/bitset: Remove.
	* include/profile/deque: Remove.
	* include/profile/forward_list: Remove.
	* include/profile/impl/profiler.h: Remove.
	* include/profile/impl/profiler_algos.h: Remove.
	* include/profile/impl/profiler_container_size.h: Remove.
	* include/profile/impl/profiler_hash_func.h: Remove.
	* include/profile/impl/profiler_hashtable_size.h: Remove.
	* include/profile/impl/profiler_list_to_slist.h: Remove.
	* include/profile/impl/profiler_list_to_vector.h: Remove.
	* include/profile/impl/profiler_map_to_unordered_map.h: Remove.
	* include/profile/impl/profiler_node.h: Remove.
	* include/profile/impl/profiler_state.h: Remove.
	* include/profile/impl/profiler_trace.h: Remove.
	* include/profile/impl/profiler_vector_size.h: Remove.
	* include/profile/impl/profiler_vector_to_list.h: Remove.
	* include/profile/iterator_tracker.h: Remove.
	* include/profile/list: Remove.
	* include/profile/map: Remove.
	* include/profile/map.h: Remove.
	* include/profile/multimap.h: Remove.
	* include/profile/multiset.h: Remove.
	* include/profile/ordered_base.h: Remove.
	* include/profile/set: Remove.
	* include/profile/set.h: Remove.
	* include/profile/unordered_base.h: Remove.
	* include/profile/unordered_map: Remove.
	* include/profile/unordered_set: Remove.
	* include/profile/vector: Remove.
	* scripts/run_doxygen: Do not process profile mode headers.
	* testsuite/23_containers/array/element_access/60497.cc: Don't use
	profile mode type.
	* testsuite/23_containers/array/specialized_algorithms/swap_cxx17.cc:
	Remove dg-skip-if for profile mode.
	* testsuite/23_containers/forward_list/capacity/1.cc: Remove
	preprocessor check for profile mode.
	* testsuite/23_containers/list/capacity/29134.cc: Likewise.
	* testsuite/23_containers/map/modifiers/extract.cc: Remove dg-skip-if
	for profile mode.
	* testsuite/23_containers/map/modifiers/insert_or_assign/1.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/try_emplace/1.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/multiset/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/set/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/unordered_map/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/capacity/29134.cc: Remove
	preprocessor check for profile mode.
	* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc:
	Remove dg-skip-if for profile mode.
	* testsuite/25_algorithms/binary_search/partitioned.cc: Likewise.
	* testsuite/25_algorithms/equal_range/partitioned.cc: Likewise.
	* testsuite/25_algorithms/lexicographical_compare/71545.cc: Likewise.
	* testsuite/25_algorithms/lower_bound/partitioned.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/partitioned.cc: Likewise.
	* testsuite/Makefile.am: Remove profile_flags variable and
	* testsuite/Makefile.am: Remove profile_flags variable and
	check-profile target.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/ext/profile/all.cc: Remove.
	* testsuite/ext/profile/mutex_extensions_neg.cc: Remove.
	* testsuite/ext/profile/profiler_algos.cc: Remove.
	* testsuite/ext/profile/replace_new.cc: Remove.
	* testsuite/ext/throw_allocator/deallocate_global.cc: Remove
	preprocessor check for profile mode.
	* testsuite/ext/throw_allocator/deallocate_local.cc: Likewise.
	* testsuite/lib/libstdc++.exp (check_v3_target_profile_mode): Remove.
	(check_v3_target_normal_mode): Do not check for profile mode macro.
	* testsuite/libstdc++-prettyprinters/80276.cc: Remove dg-skip-if for
	profile mode.
	* testsuite/libstdc++-prettyprinters/compat.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/debug.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/debug_cxx11.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/whatis2.cc: Likewise.

From-SVN: r271120
2019-05-13 11:50:21 +01:00
Jonathan Wakely 0d09ca2550 Remove array_allocator extension, deprecated since 4.9.0
This type is not a conforming allocator, because it cannot be reliably
rebound to allocate for a different type. The result of the rebind
transformation still uses the same underlying std::tr1::array<T, 1>
array, which may not be correctly aligned or even have elements the
right size for the value_type of the rebound allocator.

It has been deprecated for several years and should now be removed.

	* doc/xml/manual/allocator.xml: Remove documentation for
	array_allocator.
	* doc/xml/manual/evolution.xml: Document array_allocator removal.
	* doc/xml/manual/using.xml: Remove header from documentation.
	* include/Makefile.am: Remove <ext/array_allocator.h> header.
	* include/Makefile.in: Regenerate.
	* include/ext/array_allocator.h: Remove.
	* include/precompiled/extc++.h: Do not include removed header.
	* testsuite/ext/array_allocator/1.cc: Remove.
	* testsuite/ext/array_allocator/2.cc: Remove.
	* testsuite/ext/array_allocator/26875.cc: Remove.
	* testsuite/ext/array_allocator/3.cc: Remove.
	* testsuite/ext/array_allocator/check_deallocate_null.cc: Remove.
	* testsuite/ext/array_allocator/check_delete.cc: Remove.
	* testsuite/ext/array_allocator/check_new.cc: Remove.
	* testsuite/ext/array_allocator/variadic_construct.cc: Remove.
	* testsuite/ext/headers.cc: Do not include removed header.

From-SVN: r271119
2019-05-13 11:49:58 +01:00
Jonathan Wakely 1a1e427caa PR libstdc++/81266 fix std:🧵:native_handle_type test
The test uses remove_pointer because in most cases native_handle_type is
a pointer to the actual type that the C++ class contains. However, for
std::thread, native_handle_type is the same type as the type contained
in std::thread, and so remove_pointer is not needed. On targets where
pthread_t is a pointer type remove_pointer<native_handle_type> is not a
no-op, instead it transforms pthread_t and causes the test to fail.

The fix is to not apply remove_pointer when testing std::thread.

	PR libstdc++/81266
	* testsuite/util/thread/all.h: Do not use remove_pointer for
	std:🧵:native_handle_type.

From-SVN: r271080
2019-05-10 22:41:23 +01:00
Jonathan Wakely 7fb65a8759 PR libstdc++/90388 fix std::hash<unique_ptr<T,D>> bugs
A disabled specialization should not be callable, so move the function
call operator into a new base class which correctly implements the
disabled hash semantics. For the versioned namespace configuration do
not derive from __poison_hash in the enabled case, as the empty base
class serves no purpose but potentially increases the object size. For
the default configuration that base class must be kept, to preserve
layout.

An enabled specialization should not be unconditionally noexcept,
because the underlying hash object might throw.

	PR libstdc++/90388
	* include/bits/unique_ptr.h (default_delete, default_delete<T[]>):
	Use _Require for constraints.
	(operator>(nullptr_t, const unique_ptr<T,D>&)): Implement exactly as
	per the standard.
	(__uniq_ptr_hash): New base class with conditionally-disabled call
	operator.
	(hash<unique_ptr<T,D>>): Derive from __uniq_ptr_hash.
	* testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line.
	* testsuite/20_util/unique_ptr/hash/90388.cc: New test.

From-SVN: r271078
2019-05-10 22:41:16 +01:00
François Dumont 857c72026e re PR libstdc++/90277 (Debug Mode test failures)
2019-05-08  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/90277
	* testsuite/23_containers/unordered_multiset/insert/24061-multiset.cc
	(test01): Reserve for number of insertions to avoid rehash during test.
	* testsuite/23_containers/unordered_multimap/insert/24061-multimap.cc
	(test01): Likewise.
	* testsuite/23_containers/unordered_multimap/insert/24061-multimap.cc
	(test01): Likewise.
	(test02): Likewise.
	(test03): Likewise.

From-SVN: r271011
2019-05-08 13:03:32 +00:00
Jonathan Wakely c34d3fd306 Improve API docs for <chrono> and <ratio>
* doc/doxygen/doxygroups.cc (std::literals): Add documentation for
	inline namespace.
	* include/std/chrono: Improve docs.
	* include/std/ratio: Do not document implementation details.
	* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Adjust dg-error
	line numbers.
	* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.

From-SVN: r270988
2019-05-07 23:46:53 +01:00
Jonathan Wakely f61a12b395 PR libstdc++/89102 implement new common_type rules (P0435R1, P0548R1)
This change ensures that std::common_type<> is a complete type (LWG
2408), and that std::common_type<T>, std::common_type<cv T1, cv T2>, and
std::common_type<T1, T2, R...> will use program-defined specializations
for std::common_type<T1, T2> (LWG 2465).

The implementation of common_type<T1, T2, R...> is changed to use
void_t, and the specializations for duration and time_point are modified
to also use void_t instead of depending on implementation details of
common_type.

	PR libstdc++/89102
	* doc/xml/manual/intro.xml: Document DR 2408 and 2465 changes.
	* include/std/chrono (__duration_common_type_wrapper): Replace with ...
	(__duration_common_type): New helper.
	(common_type<chrono::duration<R1, P2>, chrono::duration<R2, P2>>): Use
	__duration_common_type.
	(__timepoint_common_type_wrapper): Replace with ...
	(__timepoint_common_type): New helper.
	(common_type<chrono::time_point<C, D2>, chrono::time_point<C, D2>>):
	Use __time_point_common_type.
	* include/std/type_traits (common_type<>): Define, as per LWG 2408.
	(__common_type_impl): If either argument is transformed by decay,
	use the common_type of the decayed types.
	(__common_type_impl<_Tp, _Up, _Tp, _Up>): If the types are already
	decayed, use __do_common_type_impl to get the common_type.
	(common_type<_Tp>): Use common_type<_Tp, _Tp>.
	(__do_member_type_wrapper, __member_type_wrapper)
	(__expanded_common_type_wrapper): Remove.
	(__common_type_pack, __common_type_fold): New helpers.
	(common_type<_Tp, _Up, _Vp...>): Use new helpers instead of
	__member_type_wrapper and __expanded_common_type_wrapper.
	* testsuite/20_util/common_type/requirements/explicit_instantiation.cc:
	Test zero-length template argument list.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc:
	Test single argument cases and argument types that should decay.
	* testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc:
	Adjust expected error.
	* testsuite/20_util/duration/literals/range_neg.cc: Use zero for
	dg-error lineno.
	* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise.
	* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise.

From-SVN: r270987
2019-05-07 23:46:39 +01:00
Nina Dinka Ranns f4e678ef74 Make allocator propagation more consistent for operator+(basic_string) (P1165R1)
2019-05-01  Nina Dinka Ranns  <dinka.ranns@gmail.com>

	Make allocator propagation more consistent for
	operator+(basic_string) (P1165R1)
	* include/bits/basic_string.h
	(operator+(basic_string&&, basic_string&&): Changed resulting
	allocator to always be the one from the first parameter.
	* include/bits/basic_string.tcc
	(operator+(const _CharT*, const basic_string&)): Changed
	resulting allocator to be SOCCC on the second parameter's allocator.
	(operator+(_CharT, const basic_string&)): Likewise.
	* testsuite/21_strings/basic_string/allocator/char/operator_plus.cc:
	New.
	* testsuite/21_strings/basic_string/allocator/wchar_t/operator_plus.cc:
	New.

From-SVN: r270953
2019-05-07 16:30:46 +01:00
Jonathan Wakely 99f1295989 Add test for std::hash<std::error_code>
Copied from 19_diagnostics/error_condition/hash.cc added recently.

	* testsuite/19_diagnostics/error_code/hash.cc: New test.

From-SVN: r270951
2019-05-07 16:30:29 +01:00
François Dumont 3997383be1 printers.py (add_one_template_type_printer): Add type printer for container types in std::__debug namespace.
2019-05-06  François Dumont  <fdumont@gcc.gnu.org>

	* python/libstdcxx/v6/printers.py (add_one_template_type_printer):
	Add type printer for container types in std::__debug namespace.
	* testsuite/lib/gdb-test.exp (whatis-regexp-test): New.
	(gdb-tests): Use distinct parameters for the type of test and use of
	regex.
	(gdb-test): Check for regex test even if 'whatis' test.
	* testsuite/libstdc++-prettyprinters/80276.cc: Adapt for _GLIBCXX_DEBUG
	mode.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/whatis2.cc: Likewise.

From-SVN: r270893
2019-05-06 05:33:23 +00:00
Jonathan Wakely 854a5c7722 PR libstdc++/90299 make filesystem::absolute overloads consistent
In this implementation it is an error to pass the empty path to absolute,
because the empty path doesn't represent any file in the filesystem so
the function cannot meet its postcondition.

Currently the absolute(const path&, error_code&) overload reports an
error for the empty path, but using errc::no_such_file_or_directory, and
the other overload does not report an error. This patch makes them
consistntly report an errc::invalid_argument error for the empty path.

	PR libstdc++/90299
	* src/c++17/fs_ops.cc (absolute(const path&)): Report an error if the
	argument is an empty path.
	(absolute(const path&, error_code&)): Use invalid_argument as error
	code instead of no_such_file_or_directory.
	* testsuite/27_io/filesystem/operations/absolute.cc: Check handling
	of non-existent paths and empty paths with both overloads of absolute.

From-SVN: r270874
2019-05-04 15:35:33 +01:00
Jonathan Wakely fe6fb0d159 Fix std::hash<std::error_condition>
The hash value should be based on the identity (i.e. address) of the
error_category member, not its object representation (i.e. underlying
bytes).

	* include/std/system_error (error_code): Remove friend declaration
	for hash<error_code>.
	(hash<error_code>::operator()): Use public member functions to access
	value and category.
	(hash<error_condition>::operator()): Use address of category, not
	its object representation.
	* src/c++11/compatibility-c++0x.cc (hash<error_code>::operator()):
	Use public member functions to access value and category.
	* testsuite/19_diagnostics/error_condition/hash.cc: New test.

From-SVN: r270872
2019-05-04 15:35:25 +01:00
François Dumont de6f5f5765 hashtable.h (_Hashtable<>::rehash): Review comment.
2019-05-04  François Dumont  <fdumont@gcc.gnu.org>

	* include/bits/hashtable.h (_Hashtable<>::rehash): Review comment.
	* include/bits/hashtable_policy.h
	(_Prime_rehash_policy::_M_bkt_for_elements): Use __builtin_ceill.
	(_Power2_rehash_policy::_M_bkt_for_elements): Likewise.
	(_Power2_rehash_policy::_M_next_bkt): Enforce returning a result not
	smaller than input value rather than always greater. Preserve
	_M_next_resize if called with 0 input. Use __builtin_floorl.
	(_Power2_rehash_policy::_M_need_rehash): Rehash only if number of
	elements + number of insertions is greater than _M_next_resize. Start
	with 11 buckets if not told otherwise. Use __builtin_floorl.
	(_Rehash_base<>::reserve): Use rehash policy _M_bkt_for_elements.
	* src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy::_M_next_bkt):
	Preserve _M_next_resize if called with 0 input. Use __builtin_floorl.
	(_Prime_rehash_policy::_M_need_rehash): Start with 11 buckets if not
	told otherwise. Use __builtin_floorl.
	* testsuite/23_containers/unordered_set/hash_policy/71181.cc: Adapt test
	to also validate _Power2_rehash_policy.
	* testsuite/23_containers/unordered_set/hash_policy/power2_rehash.cc:
	Adapt.

From-SVN: r270868
2019-05-04 07:38:46 +00:00
Jonathan Wakely e339291fc1 Fix new testcase to not require std::copysign
Use __builtin_copysign{,f,l} when std::copysign isn't available.

	PR libstdc++/61761
	* testsuite/26_numerics/complex/proj.cc: Don't assume <cmath> defines
	std::copysign.

From-SVN: r270859
2019-05-03 20:25:05 +01:00
Jonathan Wakely b752e2c926 Remove redundant __constexpr_addressof function
The std::__addressof function is always constexpr, even in C++14, so we
can just use that.

	* include/experimental/bits/lfts_config.h: Improve doc markup.
	* include/experimental/optional: Improve docs.
	(_Has_addressof_mem, _Has_addressof_free, _Has_addressof)
	(__constexpr_addressof): Remove.
	(optional::operator->()): Use std::__addressof().
	* include/std/optional (optional::operator->()): Adjust whitespace.
	* testsuite/experimental/optional/constexpr/observers/2.cc: Check
	that operator-> is still constexpr with overloaded operator&. Change
	to compile-only test.
	* testsuite/experimental/optional/constexpr/observers/3.cc: Change to
	compile-only test.

From-SVN: r270826
2019-05-02 22:23:35 +01:00
Jonathan Wakely 1ababc8bd5 Improve docs for Library Fundamentals TS
* doc/doxygen/doxygroups.cc: Move description of experimental group
	here.
	* include/experimental/algorithm: Add to libfund-ts doc group.
	* include/experimental/any: Likewise. Do not document implementation
	details.
	* include/experimental/array: Add to libfund-ts doc group.
	* include/experimental/bits/lfts_config.h: Define libfund-ts doc group
	for Library Fundamentals.
	* include/experimental/chrono: Add to libfund-ts doc group.
	* include/experimental/deque: Likewise.
	* include/experimental/forward_list: Likewise.
	* include/experimental/functional: Likewise.
	* include/experimental/iterator: Likewise.
	* include/experimental/list: Likewise.
	* include/experimental/map: Likewise.
	* include/experimental/memory: Likewise.
	* include/experimental/memory_resource: Likewise. Improve docs.
	details.
	* include/experimental/numeric: Add to libfund-ts doc group.
	* include/experimental/optional: Likewise.
	* include/experimental/propagate_const: Likewise.
	* include/experimental/random: Likewise.
	* include/experimental/ratio: Likewise.
	* include/experimental/regex: Likewise.
	* include/experimental/set: Likewise.
	* include/experimental/source_location: Likewise.
	* include/experimental/string: Likewise.
	* include/experimental/string_view: Likewise.
	* include/experimental/system_error: Likewise.
	* include/experimental/tuple: Likewise.
	* include/experimental/type_traits: Likewise.
	* include/experimental/unordered_map: Likewise.
	* include/experimental/unordered_set: Likewise.
	* include/experimental/utility: Likewise.
	* include/experimental/vector: Likewise.
	* testsuite/experimental/any/misc/any_cast_neg.cc: Adjust dg-error.
	* testsuite/experimental/array/neg.cc: Adjust dg-error.
	* testsuite/experimental/propagate_const/assignment/move_neg.cc:
	Likewise.
	* testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements2.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements3.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements4.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements5.cc: Likewise.

From-SVN: r270809
2019-05-02 16:46:29 +01:00
Jonathan Wakely 4f75543dc4 PR libstdc++/61761 fix std::proj for targets without C99 cproj
The current generic implementation of __complex_proj used when cproj is
not available calculates the wrong projection, giving a different result
than given by C99's cproj.

When C99 cproj is not available but isinf and copysign are, use those to
give correct results for float, double and long double. Otherwise, and
for other specializations of std::complex, just use a generic version
that returns its argument, and so doesn't support infinities.

We might want to consider adding additional overloads of __complex_proj
to support extended types such as _Float64x, _Float128 etc.

	PR libstdc++/61761
	* include/std/complex (__complex_proj): Return parameter unchanged.
	[_GLIBCXX_USE_C99_COMPLEX] (__complex_proj): Change overloads for
	floating-point types to take std::complex arguments.
	[_GLIBCXX_USE_C99_MATH_TR1] (__complex_proj): Add overloads for
	floating-point types.
	* testsuite/26_numerics/complex/proj.cc: New test.

From-SVN: r270759
2019-05-01 01:08:36 +01:00
Jonathan Wakely 95767c6597 Fix filesystem::path tests
The root_path.cc test had some debugging macros left in accidentally, so
didn't FAIL correctly if an assertion failed.

The string-char8_t.cc tests didn't compile on Windows.

	* testsuite/27_io/filesystem/path/decompose/root_path.cc: Remove
	macros accidentally left in.
	* testsuite/27_io/filesystem/path/native/string-char8_t.cc: Remove
	unnecessary -lstdc++fs option. Fix test for mingw.
	* testsuite/experimental/filesystem/path/native/string-char8_t.cc:
	Fix test for mingw.

From-SVN: r270685
2019-04-30 11:39:59 +01:00
Jonathan Wakely 846541dd15 PR libstdc++/87982 Fix generate_n and fill_n use of _Size parameter
The standard only requires that _Size can be converted to an integral
type, not that it can be used for arithmetic. Add a new set of
__size_to_integer helper functions to do the conversion (which will be
ambiguous if there is no one conversion that is better than any others).

Also add tests for DR 426 which requires these algorithms and search_n
to handle negative values of n.

	PR libstdc++/87982
	* include/bits/stl_algo.h (generate_n): Convert _Size parameter to
	an integral type.
	* include/bits/stl_algobase.h (__size_to_integer): New overloaded
	functions to convert a value to an integral type.
	(__fill_n_a, __fill_n_a): Assert that __n is already an integral type.
	(fill_n): Convert _Size parameter to an integral type.
	* testsuite/25_algorithms/fill_n/dr426.cc: New test.
	* testsuite/25_algorithms/generate_n/87982.cc: New test.
	* testsuite/25_algorithms/generate_n/dr426.cc: New test.

From-SVN: r270646
2019-04-29 13:12:43 +01:00
Nina Dinka Ranns ec087ba34e Adding noexcept-specification on tuple constructors (LWG 2899)
2019-04-28 Nina Dinka Ranns <dinka.ranns@gmail.com>

* libstdc++-v3/include/std/tuple:
(tuple()): Add noexcept-specification.
(tuple(const _Elements&...)): Likewise
(tuple(_UElements&&...)): Likewise
(tuple(const tuple<_UElements...>&)): Likewise
(tuple(tuple<_UElements...>&&)): Likewise
(tuple(const _T1&, const _T2&)): Likewise
(tuple(_U1&&, _U2&&)): Likewise
(tuple(const tuple<_U1, _U2>&): Likewise
(tuple(tuple<_U1, _U2>&&): Likewise
(tuple(const pair<_U1, _U2>&): Likewise
(tuple(pair<_U1, _U2>&&): Likewise
* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc: New

From-SVN: r270632
2019-04-29 00:17:50 +03:00
Jonathan Wakely 53e6927367 Fix tests that fail with _GLIBCXX_USE_CXX11_ABI=0
The pmr::string typedef isn't available for the old COW string, so some
tests that use it were failing.

	* testsuite/20_util/variant/run.cc: Use a new Hashable type to test
	hashing, because pmr::string depends on _GLIBCXX_USE_CXX11_ABI==1.
	* testsuite/21_strings/basic_string/hash/hash.cc
	[!_GLIBCXX_USE_CXX11_ABI]: Don't test pmr strings.
	* testsuite/21_strings/basic_string/hash/hash_char8_t.cc
	[!_GLIBCXX_USE_CXX11_ABI]: Likewise.

From-SVN: r270604
2019-04-26 16:02:02 +01:00
Jonathan Wakely 3addb7b937 Tweak C++2a uses-allocator construction utilities
The 20_util/scoped_allocator/69293_neg.cc test was failing in C++2a mode
because the expected static_assert text wasn't matched. The code is
still ill-formed in C++2a, but uses the new __uses_alloc_args function
and so fails a different static_assert. This patch adds the same string
to the new static_assert, so the test passes.

Now that G++ allows concepts to be declared without 'bool' we can use
the correct C++2a syntax for the _Std_pair concept used to constrain the
uses-allocator construction utilities.

Also add a new test to verify that pmr::polymorphic_allocator correctly
performs recursive uses-allocator construction for nested pairs in
C++2a.

	* include/std/memory (__uses_alloc_args): Add string-literal to
	static_assert, to match the one in __uses_alloc.
	[__cpp_concepts] (_Std_pair): Use C++2a syntax for concept.
	* testsuite/20_util/polymorphic_allocator/construct_c++2a.cc: Check
	for recursive uses-allocator construction of nested pairs.
	* testsuite/20_util/scoped_allocator/construct_pair_c++2a.cc:: Add
	comment.

From-SVN: r270600
2019-04-26 14:15:54 +01:00
Jonathan Wakely ee2f721c2f PR libstdc++/90239 use uses_allocator_construction_args in <scoped_allocator>
PR libstdc++/90239
	* doc/xml/manual/status_cxx2020.xml: Amend P0591R4 status.
	* include/std/scoped_allocator [__cplusplus > 201703L]
	(scoped_allocator_adaptor::construct): Define in terms of
	uses_allocator_construction_args, as per P0591R4.
	* testsuite/20_util/scoped_allocator/construct_pair_c++2a.cc: New test.
	* testsuite/util/testsuite_allocator.h: Remove name of unused
	parameter.

From-SVN: r270588
2019-04-25 23:43:15 +01:00
Jonathan Wakely f90b16c429 Make filesystem::path comparison operators hidden friends (LWG 3065)
This change revealed two testsuite bugs where some string comparisons
only compiled by converting the strings to filesystem::path objects.

	* include/bits/fs_path.h (operator<, operator<=, operator>)
	(operator>=, operator==, operator!=): Make hidden friends, as per
	LWG 3065.
	* testsuite/27_io/filesystem/path/native/string-char8_t.cc: Fix
	string type in test.
	* testsuite/27_io/filesystem/path/native/string.cc: Likewise.

From-SVN: r270558
2019-04-24 22:35:26 +01:00
Jonathan Wakely fb8b3e2993 Fix basic_string_view typedefs and enforce preconditions
The basic_string_view::pointer and basic_string_view::reference typedefs
are supposed to refer to the non-const value type.

In previous standards having traits_type::char_type different to
value_type was simply undefined, but in the C++2a draft it's ill-formed,
as changed by P1148R0. For std::basic_string and iostreams we might
want to only enforce this conditionally for __cplusplus > 201703L but
for std::basic_string_view we don't have backwards compatibility
concerns. Also add assertions to verify the _CharT argument is a
"char-like" type (non-array, trivial, standard layout type).

Also remove the non-standard basic_string_view::_M_check and
basic_string_view::_M_limit member functions, replacing them with
non-member functions that will still exist even if basic_string_view is
specialized by the program.

	* include/experimental/string_view (basic_string_view::pointer)
	(basic_string_view::reference): Fix to refer to non-const value_type.
	* include/bits/basic_string.h (basic_string): Use __sv_check and
	__sv_limit instead of basic_string_view::_M_check and
	basic_string_view::_M_limit.
	* include/std/string_view (__sv_check, __sv_limit): New
	helper functions to replace basic_string_view::_M_check and
	basic_string_view::_M_limit.
	(basic_string_view): Add static assertions to enforce ill-formed
	requirement for traits_type::char_type from P1148R0, and to enforce
	required properties of char-like types.
	(basic_string_view::pointer, basic_string_view::reference): Fix to
	refer to non-const value_type.
	(basic_string_view::operator[], basic_string_view::at)
	(basic_string_view::front, basic_string_view::back)
	(basic_string_view::data): Use const_reference and const_pointer
	typedefs for return types.
	(basic_string_view::_M_check, basic_string_view::_M_limit): Remove.
	(hash<wstring_view>): Fix argument_type typedef.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/
	char/1.cc: Fix expected return type of basic_string_view::data().
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/
	wchar_t/1.cc: Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/
	char/1.cc: Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/
	wchar_t/1.cc: Likewise.
	* testsuite/21_strings/basic_string_view/requirements/traits_neg.cc:
	New test.
	* testsuite/21_strings/basic_string_view/requirements/typedefs.cc:
	Check reference and pointer typedefs.
	* testsuite/experimental/string_view/requirements/typedefs.cc:
	Likewise.
	* testsuite/experimental/string_view/modifiers/remove_prefix/char/1.cc:
	Fix expected return type of basic_string_view::data().
	* testsuite/experimental/string_view/modifiers/remove_prefix/wchar_t/
	1.cc: Likewise.
	* testsuite/experimental/string_view/modifiers/remove_suffix/char/1.cc:
	Likewise.
	* testsuite/experimental/string_view/modifiers/remove_suffix/wchar_t/
	1.cc: Likewise.

From-SVN: r270548
2019-04-24 16:17:53 +01:00
Jonathan Wakely 92750002ef PR libstdc++/90220 Fix std::any_cast for array types
Although the std::any constructors use decay_t to determine the type of
the contained value, std::any_cast should use the un-decayed type (and
so always fail for function and array types that decay to pointers).

Using remove_cv_t is correct, because the condition for std::any_cast
to return non-null is operand.type() == typeid(T) and typeid ignores
top-level cv-qualifiers.

	PR libstdc++/90220
	* include/std/any (__any_caster): Use remove_cv_t instead of decay_t.
	Avoid a runtime check for types that can never be stored in std::any.
	* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
	array types.

From-SVN: r270547
2019-04-24 16:17:43 +01:00
Jonathan Wakely f9bfdfa202 PR libstdc++/90220 Fix std::any_cast for function pointers
PR libstdc++/90220 (partial)
	* include/std/any (any_cast<T>(any*), any_cast<T>(const any*)): Do
	not attempt ill-formed static_cast to pointers to non-object types.
	* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
	function types.

From-SVN: r270538
2019-04-24 10:46:07 +01:00
Jonathan Wakely e0657c24ae Avoid -Wcatch-value warning in testsuite
* testsuite/20_util/variant/run.cc: Catch exception by reference to
	prevent -Wcatch-value warning.

From-SVN: r270527
2019-04-24 00:17:52 +01:00
Jonathan Wakely 86a57ce103 Implement LWG 2904 for std::variant assignment
* include/std/variant (__variant_construct): Use template parameter
	type instead of equivalent decltype-specifier.
	(_Move_ctor_base<false, Types...>::_Move_ctor_base(_Move_ctor_base&&)):
	Replace forward with move.
	(_Move_ctor_base<false, Types...>::_M_destructive_move)
	(_Move_ctor_base<false, Types...>::_M_destructive_copy)
	(_Move_ctor_base<true, Types...>::_M_destructive_move)
	(_Move_ctor_base<true, Types...>::_M_destructive_copy): Only set the
	index after construction succeeds.
	(_Copy_assign_base<false, Types...>::operator=): Remove redundant
	if-constexpr checks that are always true. Use __remove_cvref_t instead
	of remove_reference so that is_nothrow_move_constructible check
	doesn't use a const rvalue parameter. In the potentially-throwing case
	construct a temporary and move assign it, as per LWG 2904.
	(_Move_assign_base<false, Types...>::operator=): Remove redundant
	if-constexpr checks that are always true. Use emplace as per LWG 2904.
	(variant::operator=(T&&)): Only use emplace conditionally, otherwise
	construct a temporary and move assign from it, as per LWG 2904.
	* testsuite/20_util/variant/exception_safety.cc: Check that
	assignment operators have strong exception safety guarantee.

From-SVN: r270525
2019-04-24 00:01:12 +01:00
Jonathan Wakely 038bc9bfd6 Implement correct std::variant triviality rules from P0602R4
The std::variant move assignment operator should not be trivial if the
variant is not trivially move constructible.

	* include/std/variant (__detail::__variant::_Traits): Make
	_S_trivial_copy_assign depend on _S_trivial_copy_ctor and make
	_S_trivial_move_assign depend on _S_trivial_move_ctor, as per
	P0602R4.
	(__detail::__variant::_Copy_assign_alias): Only depend on
	_S_trivial_copy_assign, which subsumes _S_trivial_copy_ctor now.
	* testsuite/20_util/variant/compile.cc: Correct checks for trivial
	move assignment operators.

From-SVN: r270510
2019-04-23 13:48:28 +01:00
Jonathan Wakely 06715e1cfb PR libstdc++/90165 constrain variant(T&&) constructor
Also refactor some constraints slightly to be more readable.

	PR libstdc++/90165
	* include/std/variant (variant::__not_self): New helper for the
	is_same_v<remove_cvref_t<T>, variant>==false constraints.
	(variant::__to_type_impl): Remove.
	(variant::__to_type): Add default argument to check pack size, instead
	of using __to_type_impl.
	(variant::__accepted_type): Add default argument using __not_self.
	(variant::__is_in_place_tag, variant::__not_in_place_tag): New helpers
	for variant(T&&) constructor constraint.
	(variant::variant(T&&)): Use __not_in_place_tag in constraints.
	Extract __accepted_type into a named template parameter for reuse in
	other constraints and in the exception specification.
	(variant::variant(in_place_type_t<T>, Args&&...))
	(variant::variant(in_place_type_t<T>, initializer_list<U>, Args&&...))
	(variant::variant(in_place_index_t<T>, Args&&...))
	(variant::variant(in_place_index_t<T>, initializer_list<U>, Args&&...))
	(variant::operator=T&&)): Remove redundant && from trait arguments.
	* testsuite/20_util/variant/compile.cc: Check variant(T&&) constructor
	isn't used for in_place_type or in_place_index arguments.

From-SVN: r270509
2019-04-23 13:48:18 +01:00
Jonathan Wakely 82e8c3da74 Corrections for C++2a std::unwrap_reference traits
The P0318R1 paper added to the C++2a draft recently was not the latest
version of the paper, and should have included these changes. These
changes will be made to the working draft via a Defect Report, so I'm
applying them to libstdc++ now.

	* include/std/type_traits (unwrap_reference_t): Define for C++2a.
	(unwrap_ref_decay): Remove inheritance from unwrap_reference.
	* testsuite/20_util/unwrap_reference/1.cc: Adjust test to use alias.

From-SVN: r270506
2019-04-23 11:27:14 +01:00
Jonathan Wakely 47a468bdbe Fix std::variant regression caused by never-valueless optimization
A regression was introduced by the recent changes to provide the strong
exception safety guarantee for "never valueless" types that have O(1),
non-throwing move assignment. The problematic code is:

  else if constexpr (__detail::__variant::_Never_valueless_alt<type>())
    {
      // This construction might throw:
      variant __tmp(in_place_index<_Np>, __il,
                    std::forward<_Args>(__args)...);
      // But _Never_valueless_alt<type> means this won't:
      *this = std::move(__tmp);
    }

When the variant is not assignable, the assignment is ill-formed, so
should not be attempted. When the variant has a copy assignment operator
but not a move assignment operator, the assignment performs a copy
assignment and that could throw, so should not be attempted.

The solution is to only take that branch when the variant has a move
assignment operator, which is determined by the _Traits::_S_move_assign
constant. When that is false the strong exception safety guarantee is
not possible, and so the __never_valueless function should also depend
on _S_move_assign.

While testing the fixes for this I noticed that the partial
specialization _Never_valueless_alt<basic_string<C,T,A>> incorrectly
assumed that is_nothrow_move_constructible<basic_string<C,T,A>> is
always true, but that's wrong for fully-dynamic COW strings. Fix the
partial specialization, and improve the comment describing
_Never_valueless_alt to be clear it depends on move construction as well
as move assignment.

Finally, I also observed that _Variant_storage<false, T...>::_M_valid()
was not taking advantage of the __never_valueless<T...>() function to
avoid a runtime check. Only the _Variant_storage<true, T...>::_M_valid()
function was using __never_valueless. That is also fixed.

	PR libstdc++/87431
	* include/bits/basic_string.h (_Never_valueless_alt): Make partial
	specialization also depend on is_nothrow_move_constructible.
	* include/std/variant (__detail::__variant::__never_valueless()):
	Only true if the variant would have a move assignment operator.
	(__detail::__variant::_Variant_storage<false, T...>::_M_valid()):
	Check __never_valueless<T...>().
	(variant::emplace): Only perform non-throwing move assignments
	for never-valueless alternatives if the variant has a move assignment
	operator.
	* testsuite/20_util/variant/compile.cc: Check that never-valueless
	types can be emplaced into non-assignable variants.
	* testsuite/20_util/variant/run.cc: Check that never-valueless types
	don't get copied when emplaced into non-assignable variants.

From-SVN: r270502
2019-04-23 10:55:33 +01:00
Iain Sandoe 375eb99a55 libstdc++-v3 Skip tests on Darwin8-10.
These earlier Darwin versions have “FP_≈” inside a
comment in architecture/{ppc,i386}/math.h, which is
included by math.h which causes the tests to fail.

The intent of the tests (i.e. to ensure that the
library itself does not emit non-ascii) is covered
by other platforms, including later Darwin editions.

2019-04-21  Iain Sandoe  <iain@sandoe.co.uk>

	* testsuite/17_intro/headers/c++1998/charset.cc: Skip for Darwin8
	to Darwin10.
	* testsuite/17_intro/headers/c++2011/charset.cc: Likewise.
	* testsuite/17_intro/headers/c++2014/charset.cc: Likewise.
	* testsuite/17_intro/headers/c++2017/charset.cc: Likewise.
	* testsuite/17_intro/headers/c++2020/charset.cc: Likewise.

From-SVN: r270479
2019-04-21 08:14:47 +00:00
Jason Merrill 5a58e967b5 PR c++/90047 - ICE with enable_if alias template.
In order to make alias templates useful for SFINAE we instantiate them under
the prevailing 'complain' argument, so an error encountered while
instantiating during SFINAE context is silent.  The problem in this PR comes
when we later look up the erroneous instantiation and don't give an error at
that point.  Fixed by not adding an erroneous instantiation to the hash
table, so we instantiate it again when needed and get the error.  This
required changes to a number of tests, which previously said "substitution
failed:" with no explanation of what the failure was; now we properly
explain.

	* pt.c (tsubst_decl) [TYPE_DECL]: Don't put an erroneous decl in the
	hash table when we're in SFINAE context.

From-SVN: r270433
2019-04-17 23:32:24 -04:00
Jonathan Wakely 8c7100650e PR libstdc++/90105 make forward_list::sort stable
While testing the fix I also discovered that operator== assumes the
elements are comparable with operator!= which is not required.

	PR libstdc++/90105
	* include/bits/forward_list.h (operator==): Do not use operator!= to
	compare elements.
	(forward_list<T, A>::sort(Comp)): When elements are equal take the one
	earlier in the list, so that sort is stable.
	* testsuite/23_containers/forward_list/operations/90105.cc: New test.
	* testsuite/23_containers/forward_list/comparable.cc: Test with
	types that meet the minimum EqualityComparable and LessThanComparable
	requirements. Remove irrelevant comment.

From-SVN: r270427
2019-04-17 22:47:20 +01:00
Jonathan Wakely 5f00d0d5c2 Fix condition for std::variant to be copy constructible
The standard says the std::variant copy constructor is defined as
deleted unless all alternative types are copy constructible, but we were
making it also depend on move constructible. Fix the condition and
enhance the tests to check the semantics with pathological copy-only
types (i.e. supporting copying but having deleted moves).

The enhanced tests revealed a regression in copy assignment for
non-trivial alternative types, where the assignment would not be
performed because the condition in the _Copy_assign_base visitor is
false: is_same_v<remove_reference_t<T&>, remove_reference_t<const T&>>.

	* include/std/variant (__detail::__variant::_Traits::_S_copy_assign):
	Do not depend on whether all alternative types are move constructible.
	(__detail::__variant::_Copy_assign_base::operator=): Remove cv-quals
	from the operand when deciding whether to perform the assignment.
	* testsuite/20_util/variant/compile.cc (DeletedMoves): Define type
	with deleted move constructor and deleted move assignment operator.
	(default_ctor, copy_ctor, move_ctor, copy_assign, move_assign): Check
	behaviour of variants with DeletedMoves as an alternative.
	* testsuite/20_util/variant/run.cc (DeletedMoves): Define same type.
	(move_ctor, move_assign): Check that moving a variant with a
	DeletedMoves alternative falls back to copying instead of moving.

From-SVN: r270425
2019-04-17 20:27:27 +01:00
Jonathan Wakely 990666d05a Remove unnecessary string literals from static_assert in C++17 tests
The string literal is optional in C++17 and all these are empty so add
no value.

	* testsuite/20_util/variant/compile.cc: Remove empty string literals
	from static_assert declarations.

From-SVN: r270424
2019-04-17 20:27:23 +01:00
Jonathan Wakely 9d3e662d29 Fix tests for std::variant to match original intention
* testsuite/20_util/variant/compile.cc (MoveCtorOnly): Fix type to
	actually match its name.
	(MoveCtorAndSwapOnly): Define new type that adds swap to MoveCtorOnly.
	(test_swap()): Fix result for MoveCtorOnly and check
	MoveCtorAndSwapOnly.

From-SVN: r270423
2019-04-17 20:27:19 +01:00
Jonathan Wakely 02c9b9ccff Add constexpr to std::optional::value_or(U&&)&&
In C++1z drafts up to N4606 the constexpr keyword was missing from the
detailed description of this function, despite being shown in the class
synopsis.  That was fixed editorially for N4618, but our implementation
was not corrected to match.

	* include/std/optional (optional::value_or(U&&) &&): Add missing
	constexpr specifier.
	* testsuite/20_util/optional/constexpr/observers/4.cc: Check value_or
	for disengaged optionals and rvalue optionals.
	* testsuite/20_util/optional/observers/4.cc: Likewise.

From-SVN: r270409
2019-04-17 14:13:30 +01:00
Jonathan Wakely 9cadd6bd4d Fix typo in effective-target check
* testsuite/lib/libstdc++.exp (check_v3_target_parallel_mode): Fix
	typo.

From-SVN: r270259
2019-04-10 15:46:03 +01:00
Jonathan Wakely 4a3f7992d2 PR libstdc++/89851 Add testcase for std::variant equality
Add a test for the regression introduced with r269422 and fixed with
r270056.

	PR libstdc++/89851
	* testsuite/20_util/variant/89851.cc: New test.

From-SVN: r270249
2019-04-10 11:43:39 +01:00
Jonathan Wakely 9d89b73c06 Add comments and style fixes to <variant>
* include/std/variant: Adjust whitespace. Add comments.
	(_Multi_array): Leave primary template undefined.
	(_Multi_array<_Tp>): Define partial specialization for base case of
	recursion.
	(__gen_vtable_impl, __gen_vtable): Remove redundant && from type
	which is always a reference.
	(__gen_vtable::_S_apply()): Remove function, inline body into
	default member initializer.
	* testsuite/20_util/variant/visit.cc: Test with noncopyable types.

From-SVN: r270238
2019-04-09 19:50:48 +01:00
Jonathan Wakely 8701cb5e0d Fix std::visit to support arbitrary callables
The __visitor_result_type helper didn't use std::invoke and so didn't
compile when the visitor was a pointer-to-member rather than a function
object. Use std::invoke_result instead.

	* include/std/variant (__variant_idx_cookie): Add member type.
	(__visitor_result_type): Remove.
	(__do_visit): Use invoke_result instead of __visitor_result_type.
	* testsuite/20_util/variant/visit.cc: New test.

From-SVN: r270237
2019-04-09 19:50:43 +01:00
Jonathan Wakely bc203bf0da PR libstdc++/90008 remove unused capture from variant rel ops
PR libstdc++/90008
	* include/std/variant (_VARIANT_RELATION_FUNCTION_TEMPLATE): Remove
	unused capture.
	* testsuite/20_util/variant/90008.cc: New test.

From-SVN: r270236
2019-04-09 19:50:39 +01:00
Ville Voutilainen 3d01c7c2f2 Fix visit<R> for variant.
* include/std/variant (__do_visit): Add a template parameter
for enforcing same return types for visit.
(__gen_vtable_impl): Likewise.
(_S_apply_single_alt): Adjust.
(__visit_invoke_impl): New. Handle casting to void.
(__do_visit_invoke): New. Enforces same return types.
(__do_visit_invoke_r): New. Converts return types.
(__visit_invoke): Adjust.
(__gen_vtable):  Add a template parameter for enforcing
same return types for visit.
* testsuite/20_util/variant/visit_r.cc: Add a test for a visitor with
different return types.
* testsuite/20_util/variant/visit_neg.cc: New. Ensures that
visitors with different return types don't accidentally
compile with regular visitation.

From-SVN: r270216
2019-04-08 22:45:48 +03:00
Christophe Lyon 66d8ee9ce0 [testsuite,libstdc++-v3] Fix 27_io/filesystem/iterators/caching.cc
2019-04-08  Christophe Lyon  <christophe.lyon@linaro.org>

	* testsuite/27_io/filesystem/iterators/caching.cc: Add
	dg-require-filesystem-ts.

From-SVN: r270199
2019-04-08 09:17:30 +02:00
Jonathan Wakely 199b20e3cb Implement std::visit<R> for C++2a (P0655R1)
* doc/xml/manual/status_cxx2020.xml: Update status.
	* include/std/variant (visit<R>): Define for C++2a (P0655R1).
	* testsuite/20_util/variant/visit_r.cc: New test.

From-SVN: r270176
2019-04-05 19:06:02 +01:00
Jonathan Wakely 67087c7e53 PR libstdc++/89986 export directory_iterator::increment
PR libstdc++/89986
	* config/abi/pre/gnu.ver: Add missing exports.
	* testsuite/27_io/filesystem/iterators/directory_iterator.cc: Test
	increment member.

From-SVN: r270174
2019-04-05 17:56:27 +01:00
Jonathan Wakely c7dde4a90a Share all recursive_directory_iterator state [LWG 2708]
Implement the proposed resolution of LWG 2708 by moving the _M_options
and _M_pending members out of the recursive_directory_iterator into the
shared _Dir_stack object. Because _Dir_stack is an opaque type, the
member functions that access the _M_options and _M_pending variables
cannot be inline. Move them into the library.

As a drive-by fix, add noexcept to the non-throwing member functions of
recursive_directory_iterator.

	* config/abi/pre/gnu.ver: Export new symbols.
	* include/bits/fs_dir.h (recursive_directory_iterator::options())
	(recursive_directory_iterator::recursion_pending())
	(recursive_directory_iterator::disable_recursion_pending()): Remove
	inline definitions. Make noexcept.
	(recursive_directory_iterator::depth())
	(recursive_directory_iterator::operator*())
	(recursive_directory_iterator::operator->()): Make noexcept.
	(recursive_directory_iterator::_M_options)
	(recursive_directory_iterator::_M_pending): Remove data members.
	* src/c++17/fs_path.cc (_Dir_stack): Add constructor and data members.
	(recursive_directory_iterator::recursive_directory_iterator): Remove
	ctor-initializer. Use new constructor for _Dir_stack.
	(recursive_directory_iterator::options())
	(recursive_directory_iterator::recursion_pending())
	(recursive_directory_iterator::disable_recursion_pending()): Add
	non-inline definitions.
	(recursive_directory_iterator::depth()): Make noexcept.
	(recursive_directory_iterator::increment(error_code&))
	(recursive_directory_iterator::pop(error_code&)): Adjust to new
	location of options and recursion_pending members.
	* testsuite/27_io/filesystem/iterators/recursion_pending.cc: New test.
	* testsuite/util/testsuite_fs.h (__gnu_test::scoped_file): Add
	user-declared move constructor and assignment operator, to make the
	type move-only.

From-SVN: r270173
2019-04-05 17:56:23 +01:00
Jonathan Wakely 5ed5c0da8b Fix directory_iterator handling of DT_UNKNOWN
We need to handle DT_UNKNOWN earlier, not only during directory
recursion, so that the cached file_type value in the directory_entry
won't be used.

	* src/c++17/fs_dir.cc (_Dir::advance(bool, error_code&)): Handle
	d_type == DT_UNKNOWN immediately.
	(_Dir::should_recurse(bool, error_code&)): Remove file_type::unknown
	handling here.
	* testsuite/27_io/filesystem/iterators/caching.cc: New test.

From-SVN: r270172
2019-04-05 17:56:18 +01:00
Jonathan Wakely d96f11a272 Make filesystem::path safe for self assignment
The standard says "If *this and p are the same object, has no effect."
Previously we ended up clearing the path.

	* include/bits/fs_path.h (path::operator=(path&&)): Check for self
	assignment.
	* src/c++17/fs_path.cc (path::operator=(const path&)): Likewise.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Test self
	assignment.

From-SVN: r270171
2019-04-05 17:56:14 +01:00
Jonathan Wakely 10f26de915 PR libstdc++/87431 re-adjust never-valueless optimizations
Avoid creating arbitrarily large objects on the stack when emplacing
trivially copyable objects into a variant. Currently we provide the
strong exception-safety guarantee for all trivially copyable types, by
constructing a second variant and then doing a non-throwing move
assignment from the temporary. This patch restricts that behaviour to
trivially copyable types that are no larger than 256 bytes. For larger
types the object will be emplaced directly into the variant, and if its
initialization throws then the variant becomes valueless.

Also implement Antony Polukhin's suggestion to whitelist specific types
that are not trivially copyable but can be efficiently move-assigned.
Emplacing those types will never cause a variant to become valueless.
The whitelisted types are: std::shared_ptr, std::weak_ptr,
std::unique_ptr, std::function, and std::any. Additionally,
std::basic_string, std::vector, and __gnu_debug::vector are whitelisted
if their allocator traits give them a non-throwing move assignment
operator. Specifically, this means std::string is whitelisted, but
std::pmr::string is not.

As part of this patch, additional if-constexpr branches are added for
the cases where the initialization is known to be non-throwing (so the
overhead of the try-catch block can be avoided) and where a scalar is
being produced by a potentially-throwing conversion operator (so that
the overhead of constructing and move-assigning a variant is avoided).
These changes should have no semantic effect, just better codegen.

	PR libstdc++/87431 (again)
	* include/bits/basic_string.h (__variant::_Never_valueless_alt):
	Define partial specialization for basic_string.
	* include/bits/shared_ptr.h (_Never_valueless_alt): Likewise for
	shared_ptr and weak_ptr.
	* include/bits/std_function.h (_Never_valueless_alt): Likewise for
	function.
	* include/bits/stl_vector.h (_Never_valueless_alt): Likewise for
	vector.
	* include/bits/unique_ptr.h (_Never_valueless_alt): Likewise for
	unique_ptr.
	* include/debug/vector (_Never_valueless_alt): Likewise for debug
	vector.
	* include/std/any (_Never_valueless_alt): Define explicit
	specialization for any.
	* include/std/variant (_Never_valueless_alt): Define primary template.
	(__never_valueless): Use _Never_valueless_alt instead of
	is_trivially_copyable.
	(variant::emplace<N>(Args&&...)): Add special case for non-throwing
	initializations to avoid try-catch overhead. Add special case for
	scalars produced by potentially-throwing conversions. Use
	_Never_valueless_alt instead of is_trivially_copyable for the
	remaining strong exception-safety cases.
	(variant::emplace<N>(initializer_list<U>, Args&&...)): Likewise.
	* testsuite/20_util/variant/87431.cc: Run both test functions.
	* testsuite/20_util/variant/exception_safety.cc: New test.
	* testsuite/20_util/variant/run.cc: Use pmr::string instead of string,
	so the variant becomes valueless.

From-SVN: r270170
2019-04-05 17:56:09 +01:00
Jonathan Wakely 0cb78ef4bc Define std::hash specializations for C++17 PMR strings
These hash specializations should have been added when the pmr::string
and related typedefs were added.

	* include/std/string (__hash_string_base): New class template defining
	operator() for hashing strings.
	(hash<pmr::string>, hash<pmr::u8string>, hash<pmr::u16string>)
	(hash<pmr::u32string>, hash<pmr::wstring>): Define for C++17.
	* testsuite/21_strings/basic_string/hash/hash.cc: New test.
	* testsuite/21_strings/basic_string/hash/hash_char8_t.cc: New test.

From-SVN: r270116
2019-04-03 10:47:47 +01:00
Jonathan Wakely 7ac205673c PR libstdc++/85965 delay static assertions until types are complete
The static assertions added for PR libstdc++/48101 were at class scope
and so were evaluated too eagerly, when it might not be possible to
determine whether the function objects are invocable with the key types.
The problematic cases are where the key type is not known to be
convertible to the argument type(s) of the function object until later,
after a type has been completed. Specifically, if the key type is a
pointer to a derived class and the function object's argument type is a
pointer to a base class, then the derived-to-base conversion is only
valid once the derived type is complete.

By moving the static assertions to the destructor they will only be
evaluated when the destructor is instantiated, at which point whether
the key type can be passed to the function object should be knowable.
The ideal place to do the checks would be only when the function objects
are actually invoked, but that would mean adding the checks in numerous
places, so the destructor is used instead.

The tests need to be adjusted because the "required from here" line is
now the location of the destructor, not the point of instantiation in
the test file. For the map and multimap tests which check two
specializations, the dg-error matching the assertion text matches both
cases. Also check the diagnostic output for the template arguments, to
ensure both specializations trigger the assertion.

	PR libstdc++/85965
	* include/bits/hashtable.h (_Hashtable): Move static assertions to
	destructor so they are not evaluated until the _Key type is complete.
	* include/bits/stl_tree.h (_Rb_tree): Likewise.
	* testsuite/23_containers/set/85965.cc: New test.
	* testsuite/23_containers/unordered_set/85965.cc: New test.
	* testsuite/23_containers/map/48101_neg.cc: Replace "here" errors
	with regexp matching the corresponding _Rb_tree specialization.
	* testsuite/23_containers/multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/multiset/48101_neg.cc: Remove "here" error.
	* testsuite/23_containers/set/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_map/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/48101_neg.cc: Likewise.
	* testsuite/23_containers/unordered_set/48101_neg.cc: Likewise.

From-SVN: r269949
2019-03-26 15:28:48 +00:00
Thomas Rodgers 061f457868 Integrate C++17 parallel algorithms
This is the Intel implementation of the C++17 parallel
algorithms, which has been donated to both GCC and LLVM. The upstream
project is at -

	https://reviews.llvm.org/source/pstl/

The new files in the include/pstl sub-directory are covered by the
LICENSE.txt in that sub-directory, as are the tests in
testsuite/**/pstl/*

	* include/Makefile.am (std_header): Add ${std_srcdir}/execution.
	(pstl_srcdir, pstl_builddir, pstl_headers): New variables.
	(allstamped): Add stamp-pstl.
	(install-headers): Add ptsl_builddir.
	* include/Makefile.in: Regenerate.
	* include/bits/c++config: Add pstl configuration.
	* include/pstl/LICENSE.txt: New file.
	* include/pstl/algorithm_fwd.h: New file.
	* include/pstl/algorithm_impl.h: New file.
	* include/pstl/execution_defs.h: New file.
	* include/pstl/execution_impl.h: New file.
	* include/pstl/glue_algorithm_defs.h: New file.
	* include/pstl/glue_algorithm_impl.h: New file.
	* include/pstl/glue_execution_defs.h: New file.
	* include/pstl/glue_memory_defs.h: New file.
	* include/pstl/glue_memory_impl.h: New file.
	* include/pstl/glue_numeric_defs.h: New file.
	* include/pstl/glue_numeric_impl.h: New file.
	* include/pstl/memory_impl.h: New file.
	* include/pstl/numeric_fwd.h: New file.
	* include/pstl/numeric_impl.h: New file.
	* include/pstl/parallel_backend.h: New file.
	* include/pstl/parallel_backend_tbb.h: New file.
	* include/pstl/parallel_backend_utils.h: New file.
	* include/pstl/parallel_impl.h: New file.
	* include/pstl/pstl_config.h: New file.
	* include/pstl/unseq_backend_simd.h: New file.
	* include/pstl/utils.h: New file.
	* include/std/algorithm: Include parallel algorithm implementations.
	* include/std/execution: New file.
	* include/std/memory: Include parallel algorithm implementations.
	* include/std/numeric: Include parallel algorithm implementations.
	* include/std/version: Add parallel algorithms feature test macro.
	* testsuite/util/pstl/pstl_test_config.h: New file.
	* testsuite/util/pstl/test_utils.h: New file.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc: New file.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc: New file.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: New file.
	* testsuite/25_algorithms/pstl/alg_merge/merge.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/fill.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/generate.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/swap_ranges.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/transform_unary.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc: New file.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/adjacent_find.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/for_each.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/includes.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/is_sorted.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/minmax_element.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/set.cc: New file.
	* testsuite/25_algorithms/pstl/alg_sorting/sort.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/reduce.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/scan.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc: New file.
	* testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: New file.
	* testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc: New file.
	* testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc: New file.
	* testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_merge/merge.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/fill.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/generate.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/remove_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/replace.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/swap_ranges.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/transform_unary.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/adjacent_find.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/for_each.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/includes.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/is_sorted.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/minmax_element.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/set.cc: New file.
	* testsuite/testsuite/25_algorithms/pstl/alg_sorting/sort.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/reduce.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/scan.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc: New file.
	* testsuite/testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: New file.

From-SVN: r269863
2019-03-21 23:48:49 +00:00
Jonathan Wakely e2186cd88e In C++17 <math.h> should not put special functions in global namespace
IS 29124 8.2 [sf.mathh] says that <math.h> should add the names of the
special functions to the global namespace.  However, C++17 Annex D
[depr.c.headers] excludes those functions explicitly, so they should not
be placed in the global namespace unconditionally for C++17.

Only add them to the global namespace when IS 29124 is explicitly
requested via the __STDCPP_WANT_MATH_SPEC_FUNCS__ macro.

	* include/c_compatibility/math.h [!__STDCPP_WANT_MATH_SPEC_FUNCS__]
	(assoc_laguerre, assoc_laguerref, assoc_laguerrel, assoc_legendre)
	(assoc_legendref, assoc_legendrel, beta, betaf, betal, comp_ellint_1)
	(comp_ellint_1f, comp_ellint_1l, comp_ellint_2, comp_ellint_2f)
	(comp_ellint_2l, comp_ellint_3, comp_ellint_3f, comp_ellint_3l)
	(cyl_bessel_i, cyl_bessel_if, cyl_bessel_il, cyl_bessel_j)
	(cyl_bessel_jf, cyl_bessel_jl, cyl_bessel_k, cyl_bessel_kf)
	(cyl_bessel_kl, cyl_neumann, cyl_neumannf, cyl_neumannl, ellint_1)
	(ellint_1f, ellint_1l, ellint_2, ellint_2f, ellint_2l, ellint_3)
	(ellint_3f, ellint_3l, expint, expintf, expintl, hermite, hermitef)
	(hermitel, laguerre, laguerref, laguerrel, legendre, legendref)
	(legendrel, riemann_zeta, riemann_zetaf, riemann_zetal, sph_bessel)
	(sph_besself, sph_bessell, sph_legendre, sph_legendref, sph_legendrel)
	(sph_neumann, sph_neumannf, sph_neumannl): Only add using-declarations
	when the special functions IS is enabled, not for C++17.
	* testsuite/26_numerics/headers/cmath/functions_global_c++17.cc:
	Replace with ...
	* testsuite/26_numerics/headers/cmath/functions_global.cc: New test,
	without checks for special functions in C++17.
	* testsuite/26_numerics/headers/cmath/special_functions_global.cc:
	New test.

From-SVN: r269837
2019-03-21 14:03:56 +00:00
John David Anglin 2ff656f421 re PR libstdc++/89461 (FAIL: experimental/net/timer/waitable/cons.cc)
PR libstdc++/89461
	* testsuite/lib/libstdc++.exp: Locate libatomic.
	* testsuite/lib/dg-options.exp (add_options_for_libatomic): New.
	* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc: Add
	libatomic options.
	* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise.
	* testsuite/experimental/net/timer/waitable/cons.cc: Likewise.
	* testsuite/experimental/net/timer/waitable/dest.cc: Likewise.
	* testsuite/experimental/net/timer/waitable/ops.cc: Likewise.

From-SVN: r269628
2019-03-12 23:13:36 +00:00
Jason Merrill c7e936dbc7 PR c++/86521 - wrong overload resolution with ref-qualifiers.
Here we were wrongly treating binding a const lvalue ref to an xvalue as
direct binding, which is wrong under [dcl.init.ref] and [over.match.ref].

	* call.c (build_user_type_conversion_1): Don't use a conversion to a
	reference of the wrong rvalueness for direct binding.

From-SVN: r269602
2019-03-11 23:19:22 -04:00
Jonathan Wakely 355d4eb36a Change test to use const variables instead of macros
This is C++ so there's no reason to use macros here.

	* testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc: Use
	const variables instead of macros.

From-SVN: r269585
2019-03-11 13:46:09 +00:00
Jonathan Wakely 1a823c9ae9 PR libstdc++/89629 fix _Hash_bytes for lengths > INT_MAX
PR libstdc++/89629
	* libsupc++/hash_bytes.cc [__SIZEOF_SIZE_T__ == 8] (_Hash_bytes):
	Use correct type for len_aligned.
	* testsuite/20_util/hash/89629.cc: New test.

From-SVN: r269584
2019-03-11 13:46:05 +00:00
François Dumont 20a4550ce0 re PR libstdc++/89608 (Undetected iterator invalidations on unordered containers in debug mode)
2019-03-08  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/89608
	* include/debug/unordered_map (unordered_map<>::_M_check_rehashed):
	Invalidate all iterators in case of rehash.
	(unordered_multimap<>::_M_check_rehashed): Likewise.
	* include/debug/unordered_set
	(unordered_set<>::_M_check_rehashed): Likewise.
	(unordered_multiset<>::_M_check_rehashed): Likewise.
	* testsuite/23_containers/unordered_set/debug/89608_neg.cc: New.

From-SVN: r269478
2019-03-08 05:37:50 +00:00
Jonathan Wakely e0f7051e44 Fix new test to run as well as compile
* testsuite/20_util/function_objects/bind_front/1.cc: Change from
	compile test to run. Fix typo.

From-SVN: r269457
2019-03-07 14:35:22 +00:00
Jonathan Wakely 9ae2a7c399 P0356R5 Simplified partial function application
* include/std/functional [C++20] (_Bind_front, _Bind_front_t): Define
	helpers for bind_front.
	(bind_front, __cpp_lib_bind_front): Define.
	* testsuite/20_util/function_objects/bind_front/1.cc: New test.

From-SVN: r269455
2019-03-07 14:15:53 +00:00
Jonathan Wakely 4661094069 Add feature test macro for bounded array traits
* include/std/type_traits (__cpp_lib_bounded_array_traits): Define.
	* include/std/version (__cpp_lib_bounded_array_traits): Likewise.
	* testsuite/20_util/is_bounded_array/value.cc: Check for macro.
	* testsuite/20_util/is_unbounded_array/value.cc: Likewise.

From-SVN: r269426
2019-03-06 15:31:06 +00:00
Edward Smith-Rowland f29a1ef2d8 PR libstdc++/86655 - std::assoc_legendre should not constrain
2019-03-06  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/86655 - std::assoc_legendre should not constrain
	the value of m (or x).
	* include/tr1/legendre_function.tcc (__assoc_legendre_p,
	__sph_legendre): If degree > order Don't throw, return 0.
	(__legendre_p, __assoc_legendre_p): Don't constrain x either.
	* testsuite/special_functions/02_assoc_legendre/pr86655.cc: New test.
	* testsuite/special_functions/20_sph_legendre/pr86655.cc: New test.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	02_assoc_legendre/pr86655.cc: New test.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	22_sph_legendre/pr86655.cc: New test.

From-SVN: r269423
2019-03-06 13:38:32 +00:00
Ville Voutilainen 669a6fdcb4 Rewrite variant, also PR libstdc++/85517
* include/std/variant (__do_visit): New.
(__variant_cast): Likewise.
(__variant_cookie): Likewise.
(__erased_*): Remove.
(_Variant_storage::_S_vtable): Likewise.
(_Variant_storage::__M_reset_impl): Adjust to use __do_visit.
(_Variant_storage::__M_reset): Adjust.
(__variant_construct): New.
(_Copy_ctor_base(const _Copy_ctor_base&)): Adjust to use
__variant_construct.
(_Move_ctor_base(_Move_ctor_base&&)): Likewise.
(_Move_ctor_base::__M_destructive_copy): New.
(_Move_ctor_base::__M_destructive_move): Adjust to use
__variant_construct.
(_Copy_assign_base::operator=): Adjust to use __do_visit.
(_Copy_assign_alias): Adjust to check both copy assignment
and copy construction for triviality.
(_Move_assign_base::operator=): Adjust to use __do_visit.
(_Multi_array): Add support for visitors that accept and return
a __variant_cookie.
(__gen_vtable_impl::_S_apply_all_alts): Likewise.
(__gen_vtable_impl::_S_apply_single_alt): Likewise.
(__gen_vtable_impl::__element_by_index_or_cookie): New. Generate
a __variant_cookie temporary for a variant that is valueless and..
(__gen_vtable_impl::__visit_invoke): ..adjust here.
(__gen_vtable::_Array_type): Conditionally make space for
the __variant_cookie visitor case.
(__variant_construct_by_index): New.
(get_if): Adjust to use std::addressof.
(relops): Adjust to use __do_visit.
(variant): Add __variant_cast and __variant_construct_by_index
as friends.
(variant::emplace): Use _M_reset() and __variant_construct_by_index
instead of self-destruction.
(variant::swap): Adjust to use __do_visit.
(visit): Reimplement in terms of __do_visit.
(__variant_hash_call_base_impl::operator()): Adjust to use __do_visit.
* testsuite/20_util/variant/compile.cc: Adjust.
* testsuite/20_util/variant/run.cc: Likewise.

From-SVN: r269422
2019-03-06 14:56:05 +02:00
Jonathan Wakely 99447f700d Add L suffix to __cpp_lib_char8_t value
* include/bits/c++config.h (_cpp_lib_char8_t): Add L suffix to
	constant.
	* testsuite/experimental/feat-char8_t.cc: Likewise.

From-SVN: r269421
2019-03-06 12:13:19 +00:00
Jonathan Wakely 28d85efbfb Add C++20 Traits for [Un]bounded Arrays (P1357R1)
* include/std/type_traits [C++20] (is_bounded_array)
	 (is_unbounded_array, is_bounded_array_v, is_unbounded_array_v):
	 Define.
	 * testsuite/20_util/is_bounded_array/requirements/
	 explicit_instantiation.cc: New test.
	 * testsuite/20_util/is_bounded_array/requirements/typedefs.cc: New
	 test.
	 * testsuite/20_util/is_bounded_array/value.cc: New test.
	 * testsuite/20_util/is_unbounded_array/requirements/
	 explicit_instantiation.cc: New test.
	 * testsuite/20_util/is_unbounded_array/requirements/typedefs.cc: New
	 * test.
	 * testsuite/20_util/is_unbounded_array/value.cc: New test.

From-SVN: r269420
2019-03-06 12:13:14 +00:00
Jonathan Wakely d80f04d61e Constexpr in std::pointer_traits (P1006R1)
* include/bits/ptr_traits.h [C++20] (pointer_traits<T*>::pointer_to):
	Add constexpr.
	* testsuite/20_util/pointer_traits/pointer_to_constexpr.cc: New test.

From-SVN: r269418
2019-03-06 11:32:42 +00:00
Jonathan Wakely 243874426d Define midpoint and lerp functions for C++20 (P0811R3)
The implementation of midpoint used for integral types is due to Howard
Hinnant and avoids a branch for int and larger types (but not for chars
and shorts).

The midpoint and lerp functions for floating point types come straight
from the P0811R3 proposal, with no attempt at optimization.

	* include/c_compatibility/math.h [C++20] (lerp): Add using
	declaration.
	* include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define.
	(__lerp): Define function template to implement lerp.
	(lerp(float, float, float), lerp(double, double, double))
	(lerp(long double, long double, long double)): Define for C++20.
	* include/std/numeric [C++20] (__cpp_lib_interpolate): Define.
	(midpoint(T, T), midpoint(T*, T*)): Define.
	* include/std::version [C++20] (__cpp_lib_interpolate): Define.
	* testsuite/26_numerics/lerp.cc: New test.
	* testsuite/26_numerics/midpoint/floating.cc: New test.
	* testsuite/26_numerics/midpoint/integral.cc: New test.
	* testsuite/26_numerics/midpoint/pointer.cc: New test.

From-SVN: r269398
2019-03-05 18:37:24 +00:00
Edward Smith-Rowland 94014ee95b PR libstdc++/88996 Implement P0439R0
2019-03-04  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libstdc++/88996 Implement P0439R0
	Make std::memory_order a scoped enumeration.
	* include/bits/atomic_base.h: For C++20 make memory_order a scoped enum,
	add variables for the old enumerators.  Adjust calls.
	* testsuite/29_atomics/headers/atomic/types_std_c++2a.cc: New test.
	* testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc: New test.

From-SVN: r269372
2019-03-04 20:11:14 +00:00
Jonathan Wakely 7ac40f3d27 Remove redundant dg-do directive from test
* testsuite/26_numerics/bit/bitops.rot/rotl.cc: Remove bogus dg-do
	directive.

From-SVN: r269365
2019-03-04 13:18:47 +00:00
Jonathan Wakely 0e31827300 Implement polymorphic_allocator<byte> for C++20 (P0339R6)
* include/std/memory_resource (polymorphic_allocator): Add default
	template argument for C++20.
	(polymorphic_allocator::allocate_bytes)
	(polymorphic_allocator::deallocate_bytes)
	(polymorphic_allocator::allocate_object)
	(polymorphic_allocator::deallocate_object)
	(polymorphic_allocator::new_object)
	(polymorphic_allocator::delete_object): New member functions for
	C++20.
	* testsuite/20_util/polymorphic_allocator/allocate_object.cc: New
	test.

From-SVN: r269362
2019-03-04 12:21:06 +00:00
Jonathan Wakely c5effe9673 Fix test memory_resource to work without sized deallocation
The checking memory_resource in the testsuite assumes sized deallocation
is supported, which might not be true for other compilers.

	* testsuite/util/testsuite_allocator.h (__gnu_test::memory_resource)
	[!__cpp_sized_deallocation]: Do not pass size to operator delete.

From-SVN: r269312
2019-03-01 13:50:41 +00:00
Jonathan Wakely 987bbe48bb C++2a Utility functions to implement uses-allocator construction (P0591R4)
* include/std/memory (uses_allocator_construction_args): New set of
	overloaded functions.
	(make_obj_using_allocator, uninitialized_construct_using_allocator):
	New functions.
	* include/std/memory_resource (polymorphic_allocator::construct)
	[__cplusplus > 201703l]: Replace all overloads with a single function
	using uses_allocator_construction_args.
	* testsuite/20_util/polymorphic_allocator/construct_c++2a.cc: New
	test.
	* testsuite/20_util/uses_allocator/make_obj.cc: New test.

From-SVN: r269311
2019-03-01 13:50:36 +00:00