aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constraint.cc
AgeCommit message (Collapse)AuthorFilesLines
2024-09-05c++: Add missing auto_diagnostic_groupsNathaniel Shead1-10/+11
This patch goes through all .cc files in gcc/cp and adds in any auto_diagnostic_groups that seem to be missing by looking for any 'inform' calls that aren't grouped with their respective error/warning. Now with SARIF output support this seems to be a bit more important. The patch isn't complete; I've tried to also track helper functions used for diagnostics to group them, but some may have been missed. Additionally there are a few functions that are definitely missing groupings but I wasn't able to see an obvious way to add them without potentially grouping together unrelated messages. This list includes: - lazy_load_{binding,pendings} "during load of {binding,pendings} for" - cp_finish_decomp "in initialization of structured binding variable" - require_deduced_type "using __builtin_source_location" - convert_nontype_argument "in template argument for type %qT" - coerce_template_params "so any instantiation with a non-empty parameter pack" - tsubst_default_argument "when instantiating default argument" - invalid_nontype_parm_type_p "invalid template non-type parameter" gcc/cp/ChangeLog: * class.cc (add_method): Add missing auto_diagnostic_group. (handle_using_decl): Likewise. (maybe_warn_about_overly_private_class): Likewise. (check_field_decl): Likewise. (check_field_decls): Likewise. (resolve_address_of_overloaded_function): Likewise. (note_name_declared_in_class): Likewise. * constraint.cc (associate_classtype_constraints): Likewise. (diagnose_trait_expr): Clean up whitespace. * coroutines.cc (find_coro_traits_template_decl): Add missing auto_diagnostic_group. (coro_promise_type_found_p): Likewise. (coro_diagnose_throwing_fn): Likewise. * cvt.cc (build_expr_type_conversion): Likewise. * decl.cc (validate_constexpr_redeclaration): Likewise. (duplicate_function_template_decls): Likewise. (duplicate_decls): Likewise. (lookup_label_1): Likewise. (check_previous_goto_1): Likewise. (check_goto_1): Likewise. (make_typename_type): Likewise. (make_unbound_class_template): Likewise. (check_tag_decl): Likewise. (start_decl): Likewise. (maybe_commonize_var): Likewise. (check_for_uninitialized_const_var): Likewise. (reshape_init_class): Likewise. (check_initializer): Likewise. (cp_finish_decl): Likewise. (find_decomp_class_base): Likewise. (cp_finish_decomp): Likewise. (expand_static_init): Likewise. (grokfndecl): Likewise. (grokdeclarator): Likewise. (check_elaborated_type_specifier): Likewise. (lookup_and_check_tag): Likewise. (xref_tag): Likewise. (cxx_simulate_enum_decl): Likewise. (finish_function): Likewise. * decl2.cc (check_classfn): Likewise. (record_mangling): Likewise. (mark_used): Likewise. * error.cc (qualified_name_lookup_error): Likewise. * except.cc (build_throw): Likewise. * init.cc (get_nsdmi): Likewise. (diagnose_uninitialized_cst_or_ref_member_1): Likewise. (warn_placement_new_too_small): Likewise. (build_new_1): Likewise. (build_vec_delete_1): Likewise. (build_delete): Likewise. * lambda.cc (add_capture): Likewise. (add_default_capture): Likewise. * lex.cc (unqualified_fn_lookup_error): Likewise. * method.cc (synthesize_method): Likewise. (defaulted_late_check): Likewise. * module.cc (trees_in::is_matching_decl): Likewise. (trees_in::read_enum_def): Likewise. (module_state::check_not_purview): Likewise. (module_state::deferred_macro): Likewise. (module_state::read_config): Likewise. (module_state::check_read): Likewise. (declare_module): Likewise. (init_modules): Likewise. * name-lookup.cc (diagnose_name_conflict): Likewise. (lookup_using_decl): Likewise. (set_decl_namespace): Likewise. (finish_using_directive): Likewise. (push_namespace): Likewise. (add_imported_namespace): Likewise. * parser.cc (cp_parser_check_for_definition_in_return_type): Likewise. (cp_parser_userdef_numeric_literal): Likewise. (cp_parser_nested_name_specifier_opt): Likewise. (cp_parser_new_expression): Likewise. (cp_parser_binary_expression): Likewise. (cp_parser_lambda_introducer): Likewise. (cp_parser_module_declaration): Likewise. (cp_parser_import_declaration): Likewise, removing gotos to support this. (cp_parser_declaration): Add missing auto_diagnostic_group. (cp_parser_decl_specifier_seq): Likewise. (cp_parser_template_id): Likewise. (cp_parser_template_name): Likewise. (cp_parser_explicit_specialization): Likewise. (cp_parser_placeholder_type_specifier): Likewise. (cp_parser_elaborated_type_specifier): Likewise. (cp_parser_enum_specifier): Likewise. (cp_parser_asm_definition): Likewise. (cp_parser_init_declarator): Likewise. (cp_parser_direct_declarator): Likewise. (cp_parser_class_head): Likewise. (cp_parser_member_declaration): Likewise. (cp_parser_lookup_name): Likewise. (cp_parser_explicit_template_declaration): Likewise. (cp_parser_check_class_key): Likewise. * pt.cc (maybe_process_partial_specialization): Likewise. (determine_specialization): Likewise. (check_for_bare_parameter_packs): Likewise. (check_template_shadow): Likewise. (process_partial_specialization): Likewise. (push_template_decl): Likewise. (redeclare_class_template): Likewise. (convert_nontype_argument_function): Likewise. (check_valid_ptrmem_cst_expr): Likewise. (convert_nontype_argument): Likewise. (convert_template_argument): Likewise. (coerce_template_parms): Likewise. (tsubst_qualified_id): Likewise. (tsubst_expr): Likewise. (most_specialized_partial_spec): Likewise. (do_class_deduction): Likewise. (do_auto_deduction): Likewise. * search.cc (lookup_member): Likewise. * semantics.cc (finish_non_static_data_member): Likewise. (process_outer_var_ref): Likewise. (finish_id_expression_1): Likewise. (finish_offsetof): Likewise. (omp_reduction_lookup): Likewise. (finish_omp_clauses): Likewise. * tree.cc (check_abi_tag_redeclaration): Likewise. (check_abi_tag_args): Likewise. * typeck.cc (invalid_nonstatic_memfn_p): Likewise. (complain_about_unrecognized_member): Likewise. (finish_class_member_access_expr): Likewise. (error_args_num): Likewise. (warn_for_null_address): Likewise. (cp_build_binary_op): Likewise. (build_x_unary_op): Likewise. (cp_build_unary_op): Likewise. (build_static_cast): Likewise. (cp_build_modify_expr): Likewise. (get_delta_difference): Likewise. (convert_for_assignment): Widen scope of auto_diagnostic_group. (check_return_expr): Add missing auto_diagnostic_group. * typeck2.cc (cxx_incomplete_type_diagnostic): Likewise. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Marek Polacek <polacek@redhat.com>
2024-08-05c++: remove function/var concepts codeMarek Polacek1-328/+18
This patch removes vestigial Concepts TS code as discussed in <https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657937.html>. In particular, it removes code related to function/variable concepts. That includes variable_concept_p and function_concept_p, which then cascades into removing DECL_DECLARED_CONCEPT_P etc. So I think we no longer need to say "standard concept" since there are no non-standard ones anymore. I've added two new errors saying that "variable/function concepts are no longer supported". gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_constant_expression): Don't call unpack_concept_check. Add a concept_check_p assert. Remove function_concept_p code. * constraint.cc (check_constraint_atom): Remove function concepts code. (unpack_concept_check): Remove. (get_concept_check_template): Remove Concepts TS code. (resolve_function_concept_overload): Remove. (resolve_function_concept_check): Remove. (resolve_concept_check): Remove Concepts TS code. (get_returned_expression): Remove. (get_variable_initializer): Remove. (get_concept_definition): Remove Concepts TS code. (normalize_concept_check): Likewise. (build_function_check): Remove. (build_variable_check): Remove. (build_standard_check): Use concept_definition_p instead of standard_concept_p. (build_concept_check): Remove variable_concept_p/function_concept_p code. (build_concept_id): Simplify. (build_type_constraint): Likewise. (placeholder_extract_concept_and_args): Likewise. (satisfy_nondeclaration_constraints): Likewise. (check_function_concept): Remove. (get_constraint_error_location): Remove Concepts TS code. * cp-tree.h (DECL_DECLARED_CONCEPT_P): Remove. (check_function_concept): Remove. (unpack_concept_check): Remove. (standard_concept_p): Remove. (variable_concept_p): Remove. (function_concept_p): Remove. (concept_definition_p): Simplify. (concept_check_p): Don't check for CALL_EXPR. * decl.cc (check_concept_refinement): Remove. (duplicate_decls): Remove check_concept_refinement code. (is_concept_var): Remove. (cp_finish_decl): Remove is_concept_var. (check_concept_fn): Remove. (grokfndecl): Give an error about function concepts not being supported anymore. Remove unused code. (grokvardecl): Give an error about variable concepts not being supported anymore. (finish_function): Remove DECL_DECLARED_CONCEPT_P code. * decl2.cc (min_vis_expr_r): Use concept_definition_p instead of standard_concept_p. (maybe_instantiate_decl): Remove DECL_DECLARED_CONCEPT_P check. (mark_used): Likewise. * error.cc (dump_simple_decl): Use concept_definition_p instead of standard_concept_p. (dump_function_decl): Remove DECL_DECLARED_CONCEPT_P code. (print_concept_check_info): Don't call unpack_concept_check. Simplify. * mangle.cc (write_type_constraint): Likewise. * parser.cc (cp_parser_nested_name_specifier_opt): Remove function_concept_p code. Only check concept_definition_p, not variable_concept_p/standard_concept_p. (add_debug_begin_stmt): Remove DECL_DECLARED_CONCEPT_P code. (cp_parser_template_declaration_after_parameters): Remove a stale comment. * pt.cc (check_explicit_specialization): Remove DECL_DECLARED_CONCEPT_P code. (process_partial_specialization): Remove variable_concept_p code. (lookup_template_variable): Likewise. (tsubst_expr) <case CALL_EXPR>: Remove Concepts TS code and simplify. (do_decl_instantiation): Remove DECL_DECLARED_CONCEPT_P code. (instantiate_decl): Likewise. (placeholder_type_constraint_dependent_p): Don't call unpack_concept_check. Add a concept_check_p assert. (convert_generic_types_to_packs): Likewise. * semantics.cc (finish_call_expr): Remove Concepts TS code and simplify. gcc/testsuite/ChangeLog: * g++.dg/concepts/decl-diagnose.C: Adjust dg-error. * g++.dg/concepts/fn-concept2.C: Likewise. * g++.dg/concepts/pr71128.C: Likewise. * g++.dg/concepts/var-concept6.C: Likewise. * g++.dg/cpp2a/concepts.C: Likewise.
2024-07-24c++: Mostly concepts related formatting fixesJakub Jelinek1-101/+102
When playing with P2963R3, while reading and/or modifying code I've fixed various comment or code formatting issues (and in 3 spots also comment wording), but including that in the WIP P2963R3 patch made that patch totally unreadable because these changes were 4 times the size of the actual code changes. So, here it is separated to a pure formatting + comment wording patch. 2024-07-24 Jakub Jelinek <jakub@redhat.com> * constraint.cc (subst_info::quiet, subst_info::noisy): Formatting fixes. (known_non_bool_p): Comment formatting fixes. (unpack_concept_check): Likewise. (resolve_function_concept_overload): Likewise. (resolve_function_concept_check): Likewise. (resolve_concept_check): Likewise. (deduce_constrained_parameter): Likewise. (finish_type_constraints): Likewise. (get_returned_expression): Likewise. (get_variable_initializer): Likewise. (norm_info::update_context, norm_info::ctx_params): Formatting fixes. (norm_info::context): Comment formatting fixes. (normalize_logical_operation): Likewise. Formatting fix. (normalize_concept_check): Comment formatting fixes. (normalize_atom): Likewise. (normalize_expression): Likewise. (get_normalized_constraints_from_info): Likewise. (get_normalized_constraints_from_decl): Likewise. Formatting fixes. (atomic_constraints_identical_p): Comment formatting fixes. (constraints_equivalent_p): Formatting fixes. (inchash::add_constraint): Likewise. (associate_classtype_constraints): Comment formatting fixes. (get_constraints): Likewise. (set_constraints): Likewise. (build_concept_check_arguments): Likewise. (build_function_check): Likewise. (build_concept_check): Likewise. (finish_shorthand_constraint): Likewise. (get_shorthand_constraints): Likewise. (check_constraint_variables): Likewise. (tsubst_constraint_variables): Likewise. (tsubst_requires_expr): Likewise. (get_mapped_args): Likewise. Formatting fixes. (satisfy_atom): Comment formatting fixes. (satisfy_constraint_r): Comment wording and formatting fixes. (satisfy_normalized_constraints): Comment formatting fixes. (satisfy_declaration_constraints): Likewise. (evaluate_concept_check): Likewise. (finish_requires_expr): Likewise. (finish_compound_requirement): Likewise. (check_function_concept): Likewise. (equivalently_constrained): Likewise. (more_constrained): Likewise. (diagnose_atomic_constraint): Likewise. * cp-tree.h (TREE_LANG_FLAG_0): Fix a comment error, FOLD_EXPR_MODIFY_P instead of FOLD_EXPR_MODOP_P. (DECL_MAIN_FREESTANDING_P, DECL_MAIN_P): Comment formatting fixes. (enum cpp0x_warn_str): Likewise. (enum composite_pointer_operation): Likewise. (enum expr_list_kind): Likewise. (enum impl_conv_rhs): Likewise. (enum impl_conv_void): Likewise. (struct deferred_access_check): Likewise. (ATOMIC_CONSTR_EXPR): Likewise. (FUNCTION_REF_QUALIFIED): Likewise. (DECL_DEPENDENT_P): Likewise. (FOLD_EXPR_MODIFY_P): Likewise. (FOLD_EXPR_OP_RAW): Likewise. (FOLD_EXPR_PACK): Likewise. (FOLD_EXPR_INIT): Likewise. (TYPE_WAS_UNNAMED): Likewise. (class cp_unevaluated): Likewise. (struct ovl_op_info_t assertion): Likewise. (cp_declarator::function::requires_clause): Likewise. (variable_template_p): Likewise. (concept_definition_p): Likewise. * logic.cc (clause::clause): Likewise. (clause::replace): Likewise. (clause::insert): Likewise. Formatting fixes. (struct formula): Comment formatting fixes. (formula::branch): Likewise. (debug): Formatting fixes. (dnf_size_r): Comment formatting fixes. (cnf_size_r): Likewise. (dnf_size): Likewise. (cnf_size): Likewise. (branch_clause): Likewise. (decompose_term): Likewise. Formatting fixes. (struct subsumption_entry): Comment formatting fixes. (subsumption_cache): Likewise. (save_subsumption): Likewise. Formatting fixes. (subsumes_constraints_nonnull): Formatting fixes.
2024-07-23c++: normalizing ttp constraints [PR115656]Patrick Palka1-4/+5
Here we normalize the constraint same_as<T, bool> for the first time during ttp coercion of B / UU, specifically constraint subsumption checking. During this normalization the set of in-scope template parameters i.e. current_template_parms is empty, which we rely on during normalization of the ttp constraints since we pass in_decl=NULL_TREE to norm_info. And this tricks the satisfaction cache into thinking that the satisfaction value of same_as<T, bool> is independent of its template parameters, and we incorrectly conflate the satisfaction value with T = bool vs T = long and accept the specialization A<long, B>. Since is_compatible_template_arg rewrites the ttp's constraints to be in terms of the argument template's parameters, and since it's the only caller of weakly_subsumes, the latter funcion can instead pass in_decl=tmpl to avoid relying on current_template_parms. This patch implements this, and in turns renames weakly_subsumes to ttp_subsumes to reflect that this predicate is now hardcoded for this one caller. PR c++/115656 gcc/cp/ChangeLog: * constraint.cc (weakly_subsumes): Pass in_decl=tmpl to get_normalized_constraints_from_info. Rename to ... (ttp_subsumes): ... this. * cp-tree.h (weakly_subsumes): Rename to ... (ttp_subsumes): ... this. * pt.cc (is_compatible_template_arg): Adjust after renaming. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-ttp7.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-07-18c++: Hash placeholder constraint in ctp_hasherSeyed Sajad Kahani1-2/+2
This patch addresses a difference between the hash function and the equality function for canonical types of template parameters (ctp_hasher). The equality function uses comptypes (typeck.cc) (with COMPARE_STRUCTURAL) and checks constraint equality for two auto nodes (typeck.cc:1586), while the hash function ignores it (pt.cc:4528). This leads to hash collisions that can be avoided by using `hash_placeholder_constraint` (constraint.cc:1150). Note that due to the proper handling of hash collisions (hash-table.h:1059), there is no test case that can distinguish the current implementation from the proposed one. * constraint.cc (hash_placeholder_constraint): Rename to iterative_hash_placeholder_constraint. (iterative_hash_placeholder_constraint): Rename from hash_placeholder_constraint and add the initial val argument. * cp-tree.h (hash_placeholder_constraint): Rename to iterative_hash_placeholder_constraint. (iterative_hash_placeholder_constraint): Renamed from hash_placeholder_constraint and add the initial val argument. * pt.cc (struct ctp_hasher): Updated to use iterative_hash_placeholder_constraint in the case of a valid placeholder constraint. (auto_hash::hash): Reflect the renaming of hash_placeholder_constraint to iterative_hash_placeholder_constraint.
2024-07-10c++: remove Concepts TS codeMarek Polacek1-282/+0
In GCC 14 we deprecated Concepts TS and discussed removing the code in GCC 15. This patch removes Concepts TS code from the front end, including support for template-introductions, as in: template<typename T> concept C = true; C{T} void foo (T); // write template<C T> void foo (T); The biggest part of this patch is adjusting the testsuite. We don't want to lose coverage so I've converted most of -fconcepts-ts tests to C++20. That means they no longer have to be c++17_only. Mostly this meant turning "concept bool" into "concept" and turning function concepts into C++20 concepts. I've added missing "auto"s where required, but "auto"s in template-argument-lists are not supported anymore so I've removed some of the tests; some of them are still present to verify we don't crash on such autos. I've also added () around "requires" expressions. I plan to add a porting_to.html entry with a few hints. I've rebased and tested the patch after the recent r15-1103. gcc/c-family/ChangeLog: * c-cppbuiltin.cc (c_cpp_builtins): Remove flag_concepts_ts code. * c-opts.cc (c_common_post_options): Likewise. * c.opt: Remove -fconcepts-ts. * c.opt.urls: Regenerate. gcc/cp/ChangeLog: * constraint.cc (deduce_concept_introduction, get_deduced_wildcard, get_introduction_prototype, introduce_type_template_parameter, introduce_template_template_parameter, introduce_nontype_template_parameter, build_introduced_template_parameter, introduce_template_parameter, introduce_template_parameter_pack, introduce_template_parameter, introduce_template_parameters, process_introduction_parms, check_introduction_list, finish_template_introduction): Remove. (finish_shorthand_constraint): Remove a Concepts TS comment. * cp-tree.h (check_auto_in_tmpl_args, finish_template_introduction): Remove. * decl.cc (function_requirements_equivalent_p): Remove pre-C++20 code. (grokfndecl): Don't check flag_concepts_ts. (grokvardecl): Don't check that concept have type bool. * parser.cc (cp_parser_decl_specifier_seq): Don't check flag_concepts_ts. (cp_parser_introduction_list): Remove. (cp_parser_template_id): Remove dead code. (cp_parser_simple_type_specifier): Don't check flag_concepts_ts. (cp_parser_placeholder_type_specifier): Require require auto or decltype(auto) even pre-C++20. Don't check flag_concepts_ts. (cp_parser_type_id_1): Don't check flag_concepts_ts. (cp_parser_template_type_arg): Likewise. (cp_parser_requires_clause_opt): Remove flag_concepts_ts code. (cp_parser_compound_requirement): Don't check flag_concepts_ts. (cp_parser_template_introduction): Remove. (cp_parser_template_declaration_after_export): Don't call cp_parser_template_introduction. * pt.cc (template_heads_equivalent_p): Remove pre-C++20 code. (find_parameter_pack_data): Remove type_pack_expansion_p. (find_parameter_packs_r): Remove flag_concepts_ts code. Remove type_pack_expansion_p code. (uses_parameter_packs): Remove type_pack_expansion_p code. (make_pack_expansion): Likewise. (check_for_bare_parameter_packs): Likewise. (fixed_parameter_pack_p): Likewise. (tsubst_qualified_id): Remove dead code. (extract_autos_r): Remove. (extract_autos): Remove. (do_auto_deduction): Remove flag_concepts_ts code. (type_uses_auto): Likewise. (check_auto_in_tmpl_args): Remove. gcc/ChangeLog: * doc/invoke.texi: Mention that -fconcepts-ts was removed. libstdc++-v3/ChangeLog: * testsuite/std/ranges/access/101782.cc: Don't compile with -fconcepts-ts. gcc/testsuite/ChangeLog: * g++.dg/concepts/auto3.C: Compile with -fconcepts. Run in C++17 and up. Add dg-error. * g++.dg/concepts/auto5.C: Likewise. * g++.dg/concepts/auto7.C: Compile with -fconcepts. Add dg-error. * g++.dg/concepts/auto8a.C: Compile with -fconcepts. * g++.dg/concepts/class-deduction1.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/concepts/class5.C: Likewise. * g++.dg/concepts/class6.C: Likewise. * g++.dg/concepts/debug1.C: Likewise. * g++.dg/concepts/decl-diagnose.C: Compile with -fconcepts. Run in C++17 and up. Add dg-error. * g++.dg/concepts/deduction-constraint1.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/concepts/diagnostic1.C: Likewise. * g++.dg/concepts/dr1430.C: Likewise. * g++.dg/concepts/equiv.C: Likewise. * g++.dg/concepts/equiv2.C: Likewise. * g++.dg/concepts/expression.C: Likewise. * g++.dg/concepts/expression2.C: Likewise. * g++.dg/concepts/expression3.C: Likewise. * g++.dg/concepts/fn-concept2.C: Compile with -fconcepts. Run in C++17 and up. Remove code. Add dg-prune-output. * g++.dg/concepts/fn-concept3.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/concepts/fn1.C: Likewise. * g++.dg/concepts/fn10.C: Likewise. * g++.dg/concepts/fn2.C: Likewise. * g++.dg/concepts/fn3.C: Likewise. * g++.dg/concepts/fn4.C: Likewise. * g++.dg/concepts/fn5.C: Likewise. * g++.dg/concepts/fn6.C: Likewise. * g++.dg/concepts/fn7.C: Compile with -fconcepts. Add dg-error. * g++.dg/concepts/fn8.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/concepts/fn9.C: Likewise. * g++.dg/concepts/generic-fn-err.C: Likewise. * g++.dg/concepts/generic-fn.C: Likewise. * g++.dg/concepts/inherit-ctor1.C: Likewise. * g++.dg/concepts/inherit-ctor3.C: Likewise. * g++.dg/concepts/intro1.C: Likewise. * g++.dg/concepts/locations1.C: Compile with -fconcepts. Run in C++17 and up. Add dg-prune-output. * g++.dg/concepts/partial-concept-id1.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/concepts/partial-concept-id2.C: Likewise. * g++.dg/concepts/partial-spec5.C: Likewise. * g++.dg/concepts/placeholder2.C: Likewise. * g++.dg/concepts/placeholder3.C: Likewise. * g++.dg/concepts/placeholder4.C: Likewise. * g++.dg/concepts/placeholder5.C: Likewise. * g++.dg/concepts/placeholder6.C: Likewise. * g++.dg/concepts/pr65634.C: Likewise. * g++.dg/concepts/pr65636.C: Likewise. * g++.dg/concepts/pr65681.C: Likewise. * g++.dg/concepts/pr65848.C: Likewise. * g++.dg/concepts/pr67249.C: Likewise. * g++.dg/concepts/pr67595.C: Likewise. * g++.dg/concepts/pr68434.C: Likewise. * g++.dg/concepts/pr71127.C: Likewise. * g++.dg/concepts/pr71128.C: Compile with -fconcepts. Run in C++17 and up. Add dg-error. * g++.dg/concepts/pr71131.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/concepts/pr71385.C: Likewise. * g++.dg/concepts/pr85065.C: Likewise. * g++.dg/concepts/pr92804-2.C: Compile with -fconcepts. Convert to C++20. * g++.dg/concepts/template-parm11.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/concepts/template-parm12.C: Likewise. * g++.dg/concepts/template-parm2.C: Likewise. * g++.dg/concepts/template-parm3.C: Likewise. * g++.dg/concepts/template-parm4.C: Likewise. * g++.dg/concepts/template-template-parm1.C: Likewise. * g++.dg/concepts/var-concept1.C: Likewise. * g++.dg/concepts/var-concept2.C: Likewise. * g++.dg/concepts/var-concept3.C: Likewise. * g++.dg/concepts/var-concept4.C: Likewise. * g++.dg/concepts/var-concept5.C: Likewise. * g++.dg/concepts/var-concept6.C: Likewise. * g++.dg/concepts/var-concept7.C: Likewise. * g++.dg/concepts/var-templ1.C: Run in C++17 and up. * g++.dg/concepts/var-templ2.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/concepts/var-templ3.C: Likewise. * g++.dg/concepts/variadic1.C: Likewise. * g++.dg/concepts/variadic2.C: Likewise. * g++.dg/concepts/variadic3.C: Likewise. * g++.dg/concepts/variadic4.C: Likewise. * g++.dg/cpp2a/concepts-pr65575.C: Likewise. * g++.dg/cpp2a/concepts-pr66091.C: Likewise. * g++.dg/cpp2a/concepts-pr67148.C: Compile with -fconcepts. Convert to C++20. * g++.dg/cpp2a/concepts-pr67225-1.C: Likewise. * g++.dg/cpp2a/concepts-pr67225-2.C: Likewise. * g++.dg/cpp2a/concepts-pr67225-3.C: Likewise. * g++.dg/cpp2a/concepts-pr67225-4.C: Likewise. * g++.dg/cpp2a/concepts-pr67225-5.C: Likewise. * g++.dg/cpp2a/concepts-pr67319.C: Likewise. * g++.dg/cpp2a/concepts-pr67427.C: Likewise. * g++.dg/cpp2a/concepts-pr67654.C: Likewise. * g++.dg/cpp2a/concepts-pr67658.C: Likewise. * g++.dg/cpp2a/concepts-pr67684.C: Likewise. * g++.dg/cpp2a/concepts-pr67697.C: Likewise. * g++.dg/cpp2a/concepts-pr67719.C: Likewise. * g++.dg/cpp2a/concepts-pr67774.C: Likewise. * g++.dg/cpp2a/concepts-pr67825.C: Likewise. * g++.dg/cpp2a/concepts-pr67860.C: Likewise. * g++.dg/cpp2a/concepts-pr67862.C: Likewise. * g++.dg/cpp2a/concepts-pr67969.C: Likewise. * g++.dg/cpp2a/concepts-pr68093-2.C: Likewise. * g++.dg/cpp2a/concepts-pr68372.C: Likewise. * g++.dg/cpp2a/concepts-pr68812.C: Likewise. * g++.dg/cpp2a/concepts-pr69235.C: Likewise. * g++.dg/cpp2a/concepts-pr78752-2.C: Likewise. * g++.dg/cpp2a/concepts-pr78752.C: Likewise. * g++.dg/cpp2a/concepts-pr79759.C: Likewise. * g++.dg/cpp2a/concepts-pr80746.C: Likewise. * g++.dg/cpp2a/concepts-pr80773.C: Likewise. * g++.dg/cpp2a/concepts-pr82507.C: Likewise. * g++.dg/cpp2a/concepts-pr82740.C: Likewise. * g++.dg/cpp2a/concepts-pr84980.C: Compile with -fconcepts. Run in C++17 and up. Convert to C++20. * g++.dg/cpp2a/concepts-pr85265.C: Likewise. * g++.dg/cpp2a/concepts-pr85808.C: Compile with -fconcepts. Convert to C++20. * g++.dg/cpp2a/concepts-pr86269.C: Likewise. * g++.dg/cpp2a/concepts-pr87441.C: Likewise. * g++.dg/cpp2a/concepts-requires5.C: Compile with -fconcepts. Adjust dg-error. Add same_as. * g++.dg/cpp2a/nontype-class50a.C: Compile with -fconcepts. * g++.dg/concepts/auto1.C: Removed. * g++.dg/concepts/auto4.C: Removed. * g++.dg/concepts/auto6.C: Removed. * g++.dg/concepts/fn-concept1.C: Removed. * g++.dg/concepts/intro2.C: Removed. * g++.dg/concepts/intro3.C: Removed. * g++.dg/concepts/intro4.C: Removed. * g++.dg/concepts/intro5.C: Removed. * g++.dg/concepts/intro6.C: Removed. * g++.dg/concepts/intro7.C: Removed. * g++.dg/cpp2a/concepts-ts1.C: Removed. * g++.dg/cpp2a/concepts-ts2.C: Removed. * g++.dg/cpp2a/concepts-ts3.C: Removed. * g++.dg/cpp2a/concepts-ts4.C: Removed. * g++.dg/cpp2a/concepts-ts5.C: Removed. * g++.dg/cpp2a/concepts-ts6.C: Removed.
2024-05-13c++: replace tf_norm with a local flagPatrick Palka1-20/+20
The tf_norm flag controlling whether to build diagnostic information during constraint normalization doesn't need to be a global tsubst flag, and is confusingly named. This patch replaces it with a boolean flag local to normalization. gcc/cp/ChangeLog: * constraint.cc (norm_info::norm_info): Take a bool instead of tsubst_flags_t. (norm_info::generate_diagnostics): Turn this predicate function into a bool data member. (normalize_logical_operation): Adjust after norm_info changes. (normalize_concept_check): Likewise. (normalize_atom): Likewise. (get_normalized_constraints_from_info): Likewise. (normalize_concept_definition): Likewise. (normalize_constraint_expression): Likewise. (normalize_placeholder_type_constraints): Likewise. (satisfy_nondeclaration_constraints): Likewise. * cp-tree.h (enum tsubst_flags): Remove tf_norm. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-10c++: Implement __is_nothrow_invocable built-in traitKen Matsui1-0/+6
This patch implements built-in trait for std::is_nothrow_invocable. gcc/cp/ChangeLog: * cp-trait.def: Define __is_nothrow_invocable. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_NOTHROW_INVOCABLE. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_nothrow_invocable. * g++.dg/ext/is_nothrow_invocable.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-10c++: Implement __is_invocable built-in traitKen Matsui1-0/+6
This patch implements built-in trait for std::is_invocable. gcc/cp/ChangeLog: * cp-trait.def: Define __is_invocable. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_INVOCABLE. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. * cp-tree.h (build_invoke): New function. * method.cc (build_invoke): New function. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_invocable. * g++.dg/ext/is_invocable1.C: New test. * g++.dg/ext/is_invocable2.C: New test. * g++.dg/ext/is_invocable3.C: New test. * g++.dg/ext/is_invocable4.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Patrick Palka <ppalka@redhat.com> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-10c++: Implement __array_rank built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::rank. gcc/cp/ChangeLog: * cp-trait.def: Define __array_rank. * constraint.cc (diagnose_trait_expr): Handle CPTK_RANK. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __array_rank. * g++.dg/ext/rank.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-10c++: Implement __is_unbounded_array built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_unbounded_array. gcc/cp/ChangeLog: * cp-trait.def: Define __is_unbounded_array. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_UNBOUNDED_ARRAY. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_unbounded_array. * g++.dg/ext/is_unbounded_array.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-03c++: Implement __is_pointer built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_pointer. gcc/cp/ChangeLog: * cp-trait.def: Define __is_pointer. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_POINTER. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_pointer. Arrange the order lexically around __is_pointer. * g++.dg/ext/is_pointer.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-03c++: Implement __is_volatile built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_volatile. gcc/cp/ChangeLog: * cp-trait.def: Define __is_volatile. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_VOLATILE. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_volatile. * g++.dg/ext/is_volatile.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-05-03c++: Implement __is_const built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_const. gcc/cp/ChangeLog: * cp-trait.def: Define __is_const. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_CONST. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_const. * g++.dg/ext/is_const.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org> Reviewed-by: Jason Merrill <jason@redhat.com>
2024-04-11c++: build_extra_args recapturing local specs [PR114303]Patrick Palka1-0/+1
r13-6452-g341e6cd8d603a3 made build_extra_args walk evaluated contexts first so that we prefer processing a local specialization in an evaluated context even if its first use is in an unevaluated context. But this means we need to avoid walking a tree that already has extra args/specs saved because the list of saved specs appears to be an evaluated context which we'll now walk first. It seems then that we should be calculating the saved specs from scratch each time, rather than potentially walking the saved specs list from an earlier partial instantiation when calling build_extra_args a second time around. PR c++/114303 gcc/cp/ChangeLog: * constraint.cc (tsubst_requires_expr): Clear REQUIRES_EXPR_EXTRA_ARGS before calling build_extra_args. * pt.cc (tree_extra_args): Define. (extract_locals_r): Assert *_EXTRA_ARGS is empty. (tsubst_stmt) <case IF_STMT>: Clear IF_SCOPE on the new IF_STMT. Call build_extra_args on the new IF_STMT instead of t which might already have IF_STMT_EXTRA_ARGS. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-if-lambda6.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-02-19c++: compound-requirement partial substitution [PR113966]Patrick Palka1-2/+3
When partially substituting a requires-expr, we don't want to perform any additional checks beyond the substitution itself so as to minimize checking requirements out of order. So don't check the return-type-req of a compound-requirement during partial substitution. And don't check the noexcept condition either since we can't do that on templated trees. PR c++/113966 gcc/cp/ChangeLog: * constraint.cc (tsubst_compound_requirement): Don't check the noexcept condition or the return-type-requirement when partially substituting. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-friend17.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-02-02c++: requires-exprs and partial constraint subst [PR110006]Patrick Palka1-12/+44
In r11-3261-gb28b621ac67bee we made tsubst_requires_expr never partially substitute into a requires-expression so as to avoid checking its requirements out of order during e.g. generic lambda regeneration. These PRs however illustrate that we still sometimes do need to partially substitute into a requires-expression, in particular when it appears in associated constraints that we're directly substituting for sake of declaration matching or dguide constraint rewriting. In these cases we're being called from tsubst_constraint during which processing_constraint_expression_p is true, so this patch checks this predicate to control whether we defer substitution or partially substitute. In turn, we now need to propagate semantic tsubst flags through tsubst_requires_expr rather than just using tf_none, notably for sake of dguide constraint rewriting which sets tf_dguide. PR c++/110006 PR c++/112769 gcc/cp/ChangeLog: * constraint.cc (subst_info::quiet): Accomodate non-diagnostic tsubst flags. (tsubst_valid_expression_requirement): Likewise. (tsubst_simple_requirement): Return a substituted _REQ node when processing_template_decl. (tsubst_type_requirement_1): Accomodate non-diagnostic tsubst flags. (tsubst_type_requirement): Return a substituted _REQ node when processing_template_decl. (tsubst_compound_requirement): Likewise. Accomodate non-diagnostic tsubst flags. (tsubst_nested_requirement): Likewise. (tsubst_requires_expr): Don't defer partial substitution when processing_constraint_expression_p is true, in which case return a substituted REQUIRES_EXPR. * pt.cc (tsubst_expr) <case REQUIRES_EXPR>: Accomodate non-diagnostic tsubst flags. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-alias18.C: New test. * g++.dg/cpp2a/concepts-friend16.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2024-01-03Update copyright years.Jakub Jelinek1-1/+1
2023-12-10c++: Implement __is_object built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_object. gcc/cp/ChangeLog: * cp-trait.def: Define __is_object. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_OBJECT. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_object. * g++.dg/ext/is_object.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Implement __is_function built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_function. gcc/cp/ChangeLog: * cp-trait.def: Define __is_function. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_FUNCTION. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_function. * g++.dg/ext/is_function.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Implement __is_reference built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_reference. gcc/cp/ChangeLog: * cp-trait.def: Define __is_reference. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_REFERENCE. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_reference. * g++.dg/ext/is_reference.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Implement __is_member_object_pointer built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_member_object_pointer. gcc/cp/ChangeLog: * cp-trait.def: Define __is_member_object_pointer. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_MEMBER_OBJECT_POINTER. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_member_object_pointer. * g++.dg/ext/is_member_object_pointer.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Implement __is_member_function_pointer built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_member_function_pointer. gcc/cp/ChangeLog: * cp-trait.def: Define __is_member_function_pointer. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_MEMBER_FUNCTION_POINTER. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_member_function_pointer. * g++.dg/ext/is_member_function_pointer.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Implement __is_member_pointer built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_member_pointer. gcc/cp/ChangeLog: * cp-trait.def: Define __is_member_pointer. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_MEMBER_POINTER. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_member_pointer. * g++.dg/ext/is_member_pointer.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Implement __is_scoped_enum built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_scoped_enum. gcc/cp/ChangeLog: * cp-trait.def: Define __is_scoped_enum. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_SCOPED_ENUM. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_scoped_enum. * g++.dg/ext/is_scoped_enum.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Implement __is_bounded_array built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_bounded_array. gcc/cp/ChangeLog: * cp-trait.def: Define __is_bounded_array. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_BOUNDED_ARRAY. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_bounded_array. * g++.dg/ext/is_bounded_array.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Implement __is_array built-in traitKen Matsui1-0/+3
This patch implements built-in trait for std::is_array. gcc/cp/ChangeLog: * cp-trait.def: Define __is_array. * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_ARRAY. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __is_array. * g++.dg/ext/is_array.C: New test. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-10c++: Sort built-in traits alphabeticallyKen Matsui1-34/+34
This patch sorts built-in traits alphabetically for better code readability. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): Sort built-in traits alphabetically. * cp-trait.def: Likewise. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise. (finish_trait_type): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Sort built-in traits alphabetically. Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
2023-12-01c++: mangle function template constraintsJason Merrill1-3/+7
Per https://github.com/itanium-cxx-abi/cxx-abi/issues/24 and https://github.com/itanium-cxx-abi/cxx-abi/pull/166 We need to mangle constraints to be able to distinguish between function templates that only differ in constraints. From the latter link, we want to use the template parameter mangling previously specified for lambdas to also make explicit the form of a template parameter where the argument is not a "natural" fit for it, such as when the parameter is constrained or deduced. I'm concerned about how the latter link changes the mangling for some C++98 and C++11 patterns, so I've limited template_parm_natural_p to avoid two cases found by running the testsuite with -Wabi forced on: template <class T, T V> T f() { return V; } int main() { return f<int,42>(); } template <int i> int max() { return i; } template <int i, int j, int... rest> int max() { int sub = max<j, rest...>(); return i > sub ? i : sub; } int main() { return max<1,2,3>(); } A third C++11 pattern is changed by this patch: template <template <typename...> class TT, typename... Ts> TT<Ts...> f(); template <typename> struct A { }; int main() { f<A,int>(); } I aim to resolve these with the ABI committee before GCC 14.1. We also need to resolve https://github.com/itanium-cxx-abi/cxx-abi/issues/38 (mangling references to dependent template-ids where the name is fully resolved) as references to concepts in std:: will consistently run into this area. This is why mangle-concepts1.C only refers to concepts in the global namespace so far. The library changes are to avoid trying to mangle builtins, which fails. Demangler support and test coverage is not complete yet. gcc/cp/ChangeLog: * cp-tree.h (TEMPLATE_ARGS_TYPE_CONSTRAINT_P): New. (get_concept_check_template): Declare. * constraint.cc (combine_constraint_expressions) (finish_shorthand_constraint): Use UNKNOWN_LOCATION. * pt.cc (convert_generic_types_to_packs): Likewise. * mangle.cc (write_constraint_expression) (write_tparms_constraints, write_type_constraint) (template_parm_natural_p, write_requirement) (write_requires_expr): New. (write_encoding): Mangle trailing requires-clause. (write_name): Pass parms to write_template_args. (write_template_param_decl): Factor out from... (write_closure_template_head): ...here. (write_template_args): Mangle non-natural parms and requires-clause. (write_expression): Handle REQUIRES_EXPR. include/ChangeLog: * demangle.h (enum demangle_component_type): Add DEMANGLE_COMPONENT_CONSTRAINTS. libiberty/ChangeLog: * cp-demangle.c (d_make_comp): Handle DEMANGLE_COMPONENT_CONSTRAINTS. (d_count_templates_scopes): Likewise. (d_print_comp_inner): Likewise. (d_maybe_constraints): New. (d_encoding, d_template_args_1): Call it. (d_parmlist): Handle 'Q'. * testsuite/demangle-expected: Add some constraint tests. libstdc++-v3/ChangeLog: * include/std/bit: Avoid builtins in requires-clauses. * include/std/variant: Likewise. gcc/testsuite/ChangeLog: * g++.dg/abi/mangle10.C: Disable compat aliases. * g++.dg/abi/mangle52.C: Specify ABI 18. * g++.dg/cpp2a/class-deduction-alias3.C * g++.dg/cpp2a/class-deduction-alias8.C: Avoid builtins in requires-clauses. * g++.dg/abi/mangle-concepts1.C: New test. * g++.dg/abi/mangle-ttp1.C: New test.
2023-10-16c++: improve fold-expr locationJason Merrill1-1/+2
I want to distinguish between constraint && and fold-expressions there of written by the user and those implied by template parameter type-constraints; to that end, let's improve our EXPR_LOCATION for an explicit fold-expression. The fold3.C change is needed because this moves the caret from the end of the expression to the operator, which means the location of the error refers to the macro invocation rather than the macro definition; both locations are still printed, but which one is an error and which a note changes. gcc/cp/ChangeLog: * parser.cc (cp_parser_fold_expression): Track location range. * semantics.cc (finish_unary_fold_expr) (finish_left_unary_fold_expr, finish_right_unary_fold_expr) (finish_binary_fold_expr): Add location parm. * constraint.cc (finish_shorthand_constraint): Pass it. * pt.cc (convert_generic_types_to_packs): Likewise. * cp-tree.h: Adjust. gcc/testsuite/ChangeLog: * g++.dg/concepts/diagnostic3.C: Add expected column. * g++.dg/cpp1z/fold3.C: Adjust diagnostic lines.
2023-08-22c++: maybe_substitute_reqs_for fixJason Merrill1-1/+1
While working on PR109751 I found that maybe_substitute_reqs_for was doing the wrong thing for a non-template friend, substituting in the template args of the scope's original template rather than those of the instantiation. This didn't end up being necessary to fix the PR, but it's still an improvement. gcc/cp/ChangeLog: * pt.cc (outer_template_args): Handle non-template argument. * constraint.cc (maybe_substitute_reqs_for): Pass decl to it. * cp-tree.h (outer_template_args): Adjust.
2023-05-19c++: simplify norm_cache manipulationPatrick Palka1-22/+9
We can avoid performing two norm_cache lookups during normalization of a concept-id by allocating and inserting a norm_entry* before rather than after the fact, which is simpler and cheaper. gcc/cp/ChangeLog: * constraint.cc (normalize_concept_check): Avoid having to do two norm_cache lookups. Remove unnecessary early exit for an ill-formed concept definition.
2023-05-09c++: error-recovery ICE with unstable satisfaction [PR109752]Patrick Palka1-3/+10
After diagnosing and recovering from unstable satisfaction, it's possible to evaluate an atom for the first time noisily rather than quietly. The satisfaction cache tries to handle this situation gracefully, but apparently not gracefully enough: we inserted an empty slot into the cache, and left it empty, which later makes hash_table::check_complete_insertion unhappy. This patch fixes this by removing the empty slot in this case. PR c++/109752 gcc/cp/ChangeLog: * constraint.cc (satisfaction_cache::satisfaction_cache): In the unexpected case of evaluating an atom for the first time noisily, remove the cache slot that we inserted. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-pr109752.C: New test.
2023-04-20c++: use TREE_VEC for trailing args of variadic built-in traitsPatrick Palka1-0/+10
This patch makes us use TREE_VEC instead of TREE_LIST to represent the trailing arguments of a variadic built-in trait. These built-ins are typically passed a simple pack expansion as the second argument, e.g. __is_constructible(T, Ts...) and the main benefit of this representation change is that substituting into this argument list is now basically free since tsubst_template_args makes sure we reuse the TREE_VEC of the corresponding ARGUMENT_PACK when expanding such a pack expansion. In the previous TREE_LIST representation we would need need to convert the expanded pack expansion into a TREE_LIST (via tsubst_tree_list). Note that an empty set of trailing arguments is now represented as an empty TREE_VEC instead of NULL_TREE, so now TRAIT_TYPE/EXPR_TYPE2 will be empty only for unary traits. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): Convert a TREE_VEC of arguments into a TREE_LIST for sake of pretty printing. * cxx-pretty-print.cc (pp_cxx_trait): Handle TREE_VEC instead of TREE_LIST of trailing variadic trait arguments. * method.cc (constructible_expr): Likewise. (is_xible_helper): Likewise. * parser.cc (cp_parser_trait): Represent trailing variadic trait arguments as a TREE_VEC instead of TREE_LIST. * pt.cc (value_dependent_expression_p): Handle TREE_VEC instead of TREE_LIST of trailing variadic trait arguments. * semantics.cc (finish_type_pack_element): Likewise. (check_trait_type): Likewise.
2023-03-16c++: checking ICE with diagnosed constraint recursion [PR100288]Patrick Palka1-1/+1
When satisfaction_cache::get detects constraint recursion, it asserts that entry->result is empty. This makes sense when we're initially detecting/diagnosing recursion from the inner recursive call, but afterwards from the outer recursive call the recursion error is treated like any other unrelated constraint failure encountered during satisfaction, and we set entry->result to whatever the satisfaction value ended up being. Perhaps we should keep entry->result cleared in this case, but that'd require the inner recursive call to communicate to the outer recursive call that constraint recursion occurred, likely via setting entry->result to some sentinel value, which doesn't seem to be worth the complexity. So this patch just relaxes the problematic assert to accept non-empty entry->result as long as we've already issued an error. PR c++/100288 gcc/cp/ChangeLog: * constraint.cc (satisfaction_cache::get): Relax overly strict checking assert in the constraint recursion case. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-recursive-sat5.C: New test.
2023-03-09c++: add __is_deducible trait [PR105841]Jason Merrill1-0/+3
C++20 class template argument deduction for an alias template involves adding a constraint that the template arguments for the alias template can be deduced from the return type of the deduction guide for the underlying class template. In the standard, this is modeled as defining a class template with a partial specialization, but it's much more efficient to implement with a trait that directly tries to perform the deduction. The first argument to the trait is a template rather than a type, so various places needed to be adjusted to accommodate that. PR c++/105841 gcc/ChangeLog: * doc/extend.texi (Type Traits):: Document __is_deducible. gcc/cp/ChangeLog: * cp-trait.def (IS_DEDUCIBLE): New. * cxx-pretty-print.cc (pp_cxx_trait): Handle non-type. * parser.cc (cp_parser_trait): Likewise. * tree.cc (cp_tree_equal): Likewise. * pt.cc (tsubst_copy_and_build): Likewise. (type_targs_deducible_from): New. (alias_ctad_tweaks): Use it. * semantics.cc (trait_expr_value): Handle CPTK_IS_DEDUCIBLE. (finish_trait_expr): Likewise. * constraint.cc (diagnose_trait_expr): Likewise. * cp-tree.h (type_targs_deducible_from): Declare. gcc/testsuite/ChangeLog: * g++.dg/ext/is_deducible1.C: New test.
2023-02-17c++: make manifestly_const_eval tri-statePatrick Palka1-2/+1
This patch converts the constexpr machinery's manifestly_const_eval flag into a tri-state enum to allow us to express wanting to fold __builtin_is_constant_evaluated to false via speculative constexpr evaluation. For now, only the maybe_constant_value entry point is changed to take this enum; the others continue to take bool. The subsequent patch will teach cp_fold (which uses maybe_constant_value) to fold the builtin to false when called from cp_fold_function and cp_fully_fold_init. gcc/cp/ChangeLog: * constexpr.cc (constexpr_call::manifestly_const_eval): Give it type int instead of bool. (constexpr_ctx::manifestly_const_eval): Give it type mce_value instead of bool. (cxx_eval_builtin_function_call): Adjust after making manifestly_const_eval tri-state. (cxx_eval_call_expression): Likewise. (cxx_eval_binary_expression): Likewise. (cxx_eval_conditional_expression): Likewise. (cxx_eval_constant_expression): Likewise. (cxx_eval_outermost_constant_expr): Likewise. (cxx_constant_value): Likewise. (cxx_constant_dtor): Likewise. (maybe_constant_value): Give manifestly_const_eval parameter type mce_value instead of bool and adjust accordingly. (fold_non_dependent_expr_template): Adjust call to cxx_eval_outermost_constant_expr. (fold_non_dependent_expr): Likewise. (maybe_constant_init_1): Likewise. * constraint.cc (satisfy_atom): Adjust call to maybe_constant_value. * cp-tree.h (enum class mce_value): Define. (maybe_constant_value): Adjust manifestly_const_eval parameter type and default argument. * decl.cc (compute_array_index_type_loc): Adjust call to maybe_constant_value. * pt.cc (convert_nontype_argument): Likewise.
2023-01-16Update copyright years.Jakub Jelinek1-1/+1
2022-12-29[C++] constraint: insert norm entry onceAlexandre Oliva1-3/+5
Use NO_INSERT to test whether inserting should be attempted. for gcc/cp/ChangeLog * constraint.cc (normalize_concept_check): Use NO_INSERT for pre-insertion check.
2022-12-23c++: template friend with variadic constraints [PR107853]Patrick Palka1-3/+4
When instantiating a constrained hidden template friend, we substitute into its template-head requirements in tsubst_friend_function. For this substitution we use the template's full argument vector whose outer levels correspond to the instantiated class's arguments and innermost level corresponds to the template's own level-lowered generic arguments. But for A<int>::f here, for which the relevant argument vector is {{int}, {Us...}}, the substitution into (C<Ts, Us> && ...) triggers the assert in use_pack_expansion_extra_args_p since one argument is a pack expansion and the other isn't. And for A<int, int>::f, for which the relevant argument vector is {{int, int}, {Us...}}, the use_pack_expansion_extra_args_p assert would also trigger but we first get a bogus "mismatched argument pack lengths" error from tsubst_pack_expansion. Sidestepping the question of whether tsubst_pack_expansion should be able to handle such substitutions, it seems we can work around this by using only the instantiated class's arguments and not also the template friend's own generic arguments, which is consistent with how we normally substitute into the signature of a member template. PR c++/107853 gcc/cp/ChangeLog: * constraint.cc (maybe_substitute_reqs_for): Substitute into the template-head requirements of a template friend using only its outer arguments via outer_template_args. * cp-tree.h (outer_template_args): Declare. * pt.cc (outer_template_args): Define, factored out and generalized from ... (ctor_deduction_guides_for): ... here. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-friend12.C: New test. * g++.dg/cpp2a/concepts-friend13.C: New test.
2022-12-01c++: comptypes ICE with BOUND_TEMPLATE_TEMPLATE_PARMs [PR107539]Patrick Palka1-3/+15
Here we end up giving the two BOUND_TEMPLATE_TEMPLATE_PARMs C<decltype(f::t)> and C<decltype(g::t)> the same TYPE_CANONICAL because the hash table that interns TYPE_CANONICAL for template type parameters doesn't set the comparing_specializations flag which controls how PARM_DECLs from different contexts compare equal. Later, from spec_hasher::equal for the corresponding two specializations A<C<decltype(f::t)>> and A<C<decltype(g::t)>>, we compare the two bound ttps with comparing_specializations set hence they now (structurally) compare different despite having the same TYPE_CANONICAL, and so we get the error: internal compiler error: same canonical type node for different types 'C<decltype (t)>' and 'C<decltype (t)>' This suggests that we should be setting comparing_specializations from ctp_hasher::equal to match spec_hasher::equal. But doing so introduces a separate ICE in cpp2a/concepts-placeholder3.C: internal compiler error: canonical types differ for identical types 'auto [requires ::same_as<<placeholder>, decltype(f::x)>]' and 'auto [requires ::same_as<<placeholder>, decltype(g::x)>]' because norm_hasher::equal doesn't set comparing_specializations either. I'm not sure when exactly we need to set comparing_specializations given what it controls (TYPENAME_TYPE equality/hashing and PARM_DECL equality) but it seems to be the conservative choice to set the flag wherever we have a global hash table that relies on type equality. To that end this patch sets comparing_specializations in ctp_hasher and norm_hasher, as well as in atom_hasher and sat_hasher for good measure. This turns out to be a compile time win of about 2% in some concepts tests, probably because of the improved TYPENAME_TYPE hashing enabled by the flag. PR c++/107539 gcc/cp/ChangeLog: * constraint.cc (norm_hasher::hash, norm_hasher::equal): Set comparing_specializations. (sat_hasher::hash, sat_hasher::equal): Likewise. * cp-tree.h (atom_hasher::hash, atom_hasher::equal): Likewise. * pt.cc (ctp_hasher::hash, ctp_hasher::equal): Likewise. gcc/testsuite/ChangeLog: * g++.dg/template/canon-type-19.C: New test.
2022-11-20c++: cache the normal form of a concept-idPatrick Palka1-14/+81
We already cache the overall normal form of a declaration's constraints (under the assumption that it can't change over the translation unit). But if we have something like template<class T> concept complicated = /* ... */; template<class T> void f() requires complicated<T> && /* ... */; template<class T> void g() requires complicated<T> && /* ... */; then despite this high-level caching we'd still redundantly have to expand the concept-id complicated<T> twice, once during normalization of f's constraints and again during normalization of g's. Ideally, we'd reuse the previously computed normal form of complicated<T> the second time around. To that end this patch introduces an intermediate layer of caching during constraint normalization -- caching of the normal form of a concept-id -- that sits between our high-level caching of the overall normal form of a declaration's constraints and our low-level caching of each individual atomic constraint. It turns out this caching generalizes normalize_concept_check's caching of the normal form of a concept definition (which is equivalent to the normal form of the concept-id C<gtargs> where gtargs is C's generic arguments) so this patch unifies the caching accordingly. gcc/cp/ChangeLog: * constraint.cc (struct norm_entry): Define. (struct norm_hasher): Define. (norm_cache): Define. (normalize_concept_check): Add function comment. Cache the the normal form of the substituted concept-id. Canonicalize generic arguments as NULL_TREE. Don't coerce arguments unless they were substituted. (normalize_concept_definition): Simplify. Use norm_cache instead of normalized_map.
2022-11-16c++: Allow attributes on concepts - DR 2428Jakub Jelinek1-0/+2
The following patch adds parsing of attributes to concept definition, allows deprecated attribute to be specified (as CONCEPT_DECL now needs to be checked in c-family/c-attribs.cc, I had to move its declaration from cp/*.def to c-family/*.def) and checks TREE_DEPRECATED in build_standard_check (not sure if that is the right spot, or whether it shouldn't be checked also for variable and function concepts and how to write testcase coverage for that). 2022-11-16 Jakub Jelinek <jakub@redhat.com> gcc/c-family/ * c-common.def (CONCEPT_DECL): New tree, moved here from cp-tree.def. * c-common.cc (c_common_init_ts): Handle CONCEPT_DECL. * c-attribs.cc (handle_deprecated_attribute): Allow deprecated attribute on CONCEPT_DECL. gcc/cp/ * cp-tree.def (CONCEPT_DECL): Move to c-common.def. * cp-objcp-common.cc (cp_common_init_ts): Don't handle CONCEPT_DECL here. * cp-tree.h (finish_concept_definition): Add ATTRS parameter. * parser.cc (cp_parser_concept_definition): Parse attributes in between identifier and =. Adjust finish_concept_definition caller. * pt.cc (finish_concept_definition): Add ATTRS parameter. Call cplus_decl_attributes. * constraint.cc (build_standard_check): If CONCEPT_DECL is TREE_DEPRECATED, emit -Wdeprecated-declaration warnings. gcc/testsuite/ * g++.dg/cpp2a/concepts-dr2428.C: New test.
2022-11-15c++: remove i_c_e_p parm from tsubst_copy_and_buildPatrick Palka1-7/+7
It seems the only and original purpose of tsubst_copy_and_build's integral_constant_expression_p boolean parameter (added in r116276, which predates the constexpr machinery) is to diagnose certain constructs that aren't allowed to appear in a C++98 integral constant expression context, specifically casts to a non-integral type (diagnosed from the *_CAST_EXPR case of tsubst_copy_and_build) or dependent names that resolve to a non-constant decl (diagnosed from the IDENTIFIER_NODE case of tsubst_copy_and_build). The parameter has no effect outside of C++98 AFAICT. But diagnosing such constructs should arguably be the job of the constexpr machinery (e.g. is_constant_expression) after substitution, and doing it during substitution by way of an additional parameter complicates the API of this workhorse function for what amounts to a couple of archaic C++98 restrictions. And it seems is_constant_expression already does a good job of diagnosing the aforementioned two constructs in C++98 mode, at least as far as our testsuite is concerned. So this patch removes this parameter from tsubst_copy_and_build, tsubst_expr and tsubst_copy_and_build_call_args. The only interesting changes are to potential_constant_expression_1 and the IDENTIFIER_NODE and *_CAST_EXPR cases of tsubst_copy_and_build; the rest are mechanical adjustments to the functions' signatures and their call sites. gcc/cp/ChangeLog: * constexpr.cc (potential_constant_expression_1) <case *_CAST_EXPR>: Use cast_valid_in_integral_constant_expression_p instead of open coding it. * constraint.cc (tsubst_valid_expression_requirement): Adjust calls to tsubst_copy_and_build and tsubst_expr. (tsubst_constraint): Likewise. (satisfy_atom): Likewise. (diagnose_trait_expr): Likewise. * cp-tree.h (tsubst_copy_and_build): Remove i_c_e_p parameter. (tsubst_expr): Likewise. * init.cc (get_nsdmi): Adjust calls to tsubst_copy_and_build and tsubst_expr. * pt.cc (expand_integer_pack): Likewise. (instantiate_non_dependent_expr_internal): Likewise. (tsubst_friend_function): Likewise. (tsubst_attribute): Likewise. (instantiate_class_template): Likewise. (tsubst_template_arg): Likewise. (gen_elem_of_pack_expansion_instantiation): Likewise. (tsubst_fold_expr_init): Likewise. (tsubst_pack_expansion): Likewise. (tsubst_default_argument): Likewise. (tsubst_function_decl): Likewise. (tsubst_decl): Likewise. (tsubst_arg_types): Likewise. (tsubst_exception_specification): Likewise. (tsubst): Likewise. (tsubst_init): Likewise. (tsubst_copy): Likewise. (tsubst_omp_clause_decl): Likewise. (tsubst_omp_clauses): Likewise. (tsubst_copy_asm_operands): Likewise. (tsubst_omp_for_iterator): Likewise. (tsubst_expr): Likewise. Remove i_c_e_p parameter. (tsubst_omp_udr): Likewise. (tsubst_non_call_postfix_expression): Likewise. Remove i_c_e_p parameter. (tsubst_lambda_expr): Likewise. (tsubst_copy_and_build_call_args): Likewise. (tsubst_copy_and_build): Likewise. Remove i_c_e_p parameter. <case IDENTIFIER_NODE>: Adjust call to finish_id_expression following removal of i_c_e_p. <case *_CAST_EXPR>: Remove C++98-specific cast validity check guarded by i_c_e_p. (maybe_instantiate_noexcept): Adjust calls to tsubst_copy_and_build and tsubst_expr. (instantiate_body): Likewise. (instantiate_decl): Likewise. (tsubst_initializer_list): Likewise. (tsubst_enum): Likewise. gcc/objcp/ChangeLog: * objcp-lang.cc (objcp_tsubst_copy_and_build): Adjust calls to tsubst_copy_and_build and tsubst_expr. gcc/testsuite/ChangeLog: * g++.dg/template/crash55.C: Don't expect additional C++98-specific diagnostics. * g++.dg/template/ref3.C: Remove C++98-specific xfail.
2022-11-03c++: requires-expr and access checking [PR107179]Patrick Palka1-0/+3
Like during satisfaction, we also need to avoid deferring access checks during substitution of a requires-expr because the outcome of an access check can determine the value of the requires-expr. Otherwise (in deferred access checking contexts such as within a base-clause), the requires-expr may evaluate to the wrong result, and along the way a failed access check may leak out from it into a non-SFINAE context and cause a hard error (as in the below testcase). PR c++/107179 gcc/cp/ChangeLog: * constraint.cc (tsubst_requires_expr): Make sure we're not deferring access checks. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires31.C: New test.
2022-10-25c++: remove use_default_args parm of coerce_template_parmsPatrick Palka1-3/+3
The parameter use_default_args of coerce_template_parms, introduced way back in r110693, is effectively unused ever since r7-5536-g3c75aaa3d884ef removed the last 'coerce_template_parms (..., true, false)' call. So this patch aims to simplify this function's API by getting rid of this parameter. In passing, I noticed we currently define wrapper overloads of coerce_template_parms that act as defacto default arguments for complain and require_all_args. It seems cleaner however to just specify real default arguments for the main overload instead. And I suppose we should also give c_innermost_t_p the same defaults. But I'm not sure about defaulting complain to tf_none, which is inconsistent with how we default it in other places to either tf_error or tf_warning_or_error (as a convenience for non-SFINAE callers). And since in general it's probably better to not default complain as that's a source of SFINAE bugs, and only a handful of callers use this defacto complain=tf_none default, this patch gets rid of this complain default (but keeps the require_all_args default). gcc/cp/ChangeLog: * constraint.cc (resolve_function_concept_overload): Explicitly pass complain=tf_none to coerce_template_parms. (resolve_concept_check): Likewise. (normalize_concept_check): Likewise. * cp-tree.h (coerce_template_parms): Declare the main overload and default its last parameter to true. Remove wrapper overloads. * pt.cc (determine_specialization): Adjust calls to coerce_template_parms and coerce_innermost_template_parms after removing their last parameter. (coerce_template_args_for_ttp): Likewise. (coerce_ttp_args_for_tta): Likewise. (coerce_template_template_parms): Likewise. (coerce_template_parms): Remove use_default_args parameter and adjust function comment. Document default argument. Remove wrapper overloads. No longer static. (coerce_innermost_template_parms): Remove use_default_args parameter. Default require_all_args to true. (lookup_template_class): As with determine_specialization. (finish_template_variable): Likewise. (tsubst_decl): Likewise. (instantiate_alias_template): Likewise. (fn_type_unification): Likewise. (resolve_overloaded_unification): Likewise. (resolve_nondeduced_context): Likewise. (get_partial_spec_bindings): Likewise.
2022-10-03c++: rename IS_SAME_AS trait code to IS_SAMEPatrick Palka1-1/+1
... to match the trait's canonical spelling __is_same instead of its alternative spelling __is_same_as. gcc/c-family/ChangeLog: * c-common.cc (c_common_reswords): Use RID_IS_SAME instead of RID_IS_SAME_AS. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): Use CPTK_IS_SAME instead of CPTK_IS_SAME_AS. * cp-trait.def (IS_SAME_AS): Rename to ... (IS_SAME): ... this. * pt.cc (alias_ctad_tweaks): Use CPTK_IS_SAME instead of CPTK_IS_SAME_AS. * semantics.cc (trait_expr_value): Likewise. (finish_trait_expr): Likewise.
2022-09-30c++: streamline built-in trait addition processPatrick Palka1-7/+5
Adding a new built-in trait currently involves manual boilerplate consisting of defining an rid enumerator for the identifier as well as a corresponding cp_trait_kind enumerator and handling them in various switch statements, the exact set of which depends on whether the proposed trait yields (and thus is recognized as) a type or an expression. To streamline the process, this patch adds a central cp-trait.def file that tabulates the essential details about each built-in trait (whether it yields a type or an expression, its code, its spelling and its arity) and uses this file to automate away the manual boilerplate. It also migrates all the existing C++-specific built-in traits to use this approach. After this change, adding a new built-in trait just entails declaring it in cp-trait.def and defining its behavior in finish_trait_expr/type (and handling it in diagnose_trait_expr, if it's an expression-yielding trait). gcc/c-family/ChangeLog: * c-common.cc (c_common_reswords): Use cp/cp-trait.def to handle C++ traits. * c-common.h (enum rid): Likewise. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): Likewise. * cp-objcp-common.cc (names_builtin_p): Likewise. * cp-tree.h (enum cp_trait_kind): Likewise. * cxx-pretty-print.cc (pp_cxx_trait): Likewise. * parser.cc (cp_keyword_starts_decl_specifier_p): Likewise. (cp_parser_primary_expression): Likewise. (cp_parser_trait): Likewise. (cp_parser_simple_type_specifier): Likewise. * cp-trait.def: New file.
2022-09-29c++: implement __remove_cv, __remove_reference and __remove_cvrefPatrick Palka1-0/+3
This implements builtins for std::remove_cv, std::remove_reference and std::remove_cvref using TRAIT_TYPE from the previous patch. gcc/c-family/ChangeLog: * c-common.cc (c_common_reswords): Add __remove_cv, __remove_reference and __remove_cvref. * c-common.h (enum rid): Add RID_REMOVE_CV, RID_REMOVE_REFERENCE and RID_REMOVE_CVREF. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): Handle CPTK_REMOVE_CV, CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF. * cp-objcp-common.cc (names_builtin_p): Likewise. * cp-tree.h (enum cp_trait_kind): Add CPTK_REMOVE_CV, CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF. * cxx-pretty-print.cc (pp_cxx_trait): Handle CPTK_REMOVE_CV, CPTK_REMOVE_REFERENCE and CPTK_REMOVE_CVREF. * parser.cc (cp_keyword_starts_decl_specifier_p): Return true for RID_REMOVE_CV, RID_REMOVE_REFERENCE and RID_REMOVE_CVREF. (cp_parser_trait): Handle RID_REMOVE_CV, RID_REMOVE_REFERENCE and RID_REMOVE_CVREF. (cp_parser_simple_type_specifier): Likewise. * semantics.cc (finish_trait_type): Likewise. libstdc++-v3/ChangeLog: * include/bits/unique_ptr.h (unique_ptr<_Tp[], _Dp>): Remove __remove_cv and use __remove_cv_t instead. gcc/testsuite/ChangeLog: * g++.dg/ext/has-builtin-1.C: Test existence of __remove_cv, __remove_reference and __remove_cvref. * g++.dg/ext/remove_cv.C: New test. * g++.dg/ext/remove_reference.C: New test. * g++.dg/ext/remove_cvref.C: New test.
2022-09-27c++: Don't quote nothrow in diagnosticMarek Polacek1-7/+7
In <https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602057.html> Jason noticed that we quote "nothrow" in diagnostics even though it's not a keyword in C++. This patch removes the quotes and also drops "nothrow" from c_keywords. gcc/c-family/ChangeLog: * c-format.cc (c_keywords): Drop nothrow. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): Say "nothrow" without quotes rather than in quotes. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-traits3.C: Adjust expected diagnostics.