aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constraint.cc
AgeCommit message (Collapse)AuthorFilesLines
2018-02-15re PR c++/84330 ([concepts] ICE with broken constraint)Paolo Carlini1-1/+1
/cp 2018-02-15 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84330 * constraint.cc (tsubst_constraint_info): Handle an error_mark_node as first argument. /testsuite 2018-02-15 Paolo Carlini <paolo.carlini@oracle.com> PR c++/84330 * g++.dg/concepts/pr84330.C: New. From-SVN: r257698
2018-01-03Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r256169
2017-10-10Check non-dependent conversion in return from template fn.Jason Merrill1-1/+6
* typeck.c (check_return_expr): Check non-dependent conversion in templates. * constraint.cc (check_function_concept): Don't complain about an empty concept if seen_error. From-SVN: r253599
2017-06-29Whitespace cleanups.Nathan Sidwell1-1/+1
* call.c (name_as_c_string): Move CONST_CAST to return. (build_new_method_call_1): Remove unneeded bracing. * class.c (include_empty_classes): Unbreak line. * constraint.cc (tsubst_check_constraint): Add space. * cp-tree.h (lang_decl_ns): Add comment. (PTRMEM_CST_MEMBER): Break line. * decl.c (grokfndecl): Add blank lines. Unbreak some others. (grokdeclarator): Remove lines, move declaration to first use. * decl2.c (decl_needed_p): Fix indentation. (c_parse_final_cleanups): Remove blank line. * method.c (implicitly_declare_fn): Move declaration to first use. * search.c (current_scope): Add blank lines. From-SVN: r249786
2017-05-17class.c (handle_using_decl): Use OVL_FIRST, ovl_iterator.Nathan Sidwell1-18/+8
* class.c (handle_using_decl): Use OVL_FIRST, ovl_iterator. (maybe_warn_about_overly_private_class): Use ovl_iterator. (method_name_cmp, resort_method_name_cmp): Use OVL_NAME. (resort_type_method_vec, finish_struct_methods): Use OVL_FIRST. (get_base_fndecls): Use ovl_iterator. (warn_hidden): Use OVL_NAME, ovl_iterator. (add_implicitly_declared_members): Use ovl_iterator. * constraint.cc (normalize_template_id_expression): Use OVL_FIRST, flatten nested if. (finish_shorthand_constraint): Simplify, use ovl_make. * pt.c (make_constrained_auto): Simplify. Use ovl_make. * search.c (shared_member_p): Use ovl_iterator. (lookup_field_fuzzy_info::fuzzy_lookup_fn): Use OVL_NAME. (lookup_conversion_operator): Use OVL_FIRST. (lookup_fnfiels_idx_nolazy): Use OVL_FIRST, OVL_NAME. (look_for_overrides_here): Use ovl_iterator. (lookup_conversions_r): Use OVL_FIRST, OVL_NAME, ovl_iterator. * typeck.c (build_x_unary_op): Use ovl_make. From-SVN: r248144
2017-05-16cp-tree.h (class ovl_iterator, [...]): New OVERLOAD iterators.Nathan Sidwell1-2/+2
* cp-tree.h (class ovl_iterator, class lkp_iterator): New OVERLOAD iterators. (MAYBE_BASELINK_FUNCTIONS): New. * constraint.cc (resolve_constraint_check): Use lkp_iterator. * decl2.c (maybe_warn_sized_delete): Use ovl_iterator. * lambda.c (maybe_generic_this_capture): Use lkp_iterator. * method.c (inherited_ctor_binfo): Use ovl_iterator. (binfo_inherited_from): Likewise. * parser.c (lookup_literal_operator): Use lkp_iterator. * pt.c (iterative_hash_template_arg): Use lkp_iterator. (print_candidates_1): Likewise. (determine_specialization): Likewise. (resolve_overloaded_unification): Likewise. (resolve_nondeduced_context): Likewise. (type_dependent_expression_p): Likewise. (dependent_template_p): Likewise. * ptree.c (cxx_print_xnode): Likewise. * semantics.c (omp_reduction_lookup): Use lkp_iterator. (classtype_has_nothrow_assign_or_copy_p): Use ovl_iterator. * typeck.c (check_template_keyword): Use lkp_iterator. From-SVN: r248112
2017-05-16cp-tree.h (OVL_FIRST, OVL_NAME): New.Nathan Sidwell1-3/+2
* cp-tree.h (OVL_FIRST, OVL_NAME): New. (ovl_first): New. * constexpr.c (function_concept_check): Use OVL_FIRST. * cvt.c (build_expr_type_conversion): Likewise. * decl.c (poplevel, grokdeclarator): Use OVL_NAME. * decl2.c (mark_used): Use OVL_FIRST. * error.c (dump_decl): Use OVL_FIRST, OVL_NAME. (dump_expr, location_of): Use OVL_FIRST. * friend.c (do_friend): Use OVL_NAME. * init.c (build_offset_ref): Use OVL_FIRST. * mangle.c (write_member_name): Likewise. (write_expression): Use OVL_NAME. * method.c (strip_inheriting_ctors): Use OVL_FIRST. * name-lookup.c (pushdecl_class_level): Use OVL_NAME. * pt.c (check_explicit_specialization): Use OVL_FIRST. (check_template_shadow): Likewise. (tsubst_template_args): Use OVL_NAME. (tsubst_baselink): Use OVL_FIRST. * semantics.c (perform_koenig_lookup): Use OVL_NAME. * tree.c (get_first_fn): Use OVL_FIRST. * typeck.c (finish_class_member_access_expr): Use OVL_NAME. (cp_build_addr_expr_1): Use OVL_FIRST. From-SVN: r248108
2017-05-04* constraint.cc (diagnose_check_constraint): Fix %E thinko.Nathan Sidwell1-1/+1
From-SVN: r247614
2017-05-04PR translation/80280 - Missing closing quote (%>) c/semantics.c and c/c-typeck.cMartin Sebor1-1/+1
gcc/c-family/ChangeLog: PR translation/80280 * c-attribs.c (handle_alias_ifunc_attribute): Quote a %D directive. (handle_weakref_attribute): Same. PR translation/80280 - Missing closing quote (%>) c/semantics.c and c/c-typeck.c gcc/ChangeLog: PR translation/80280 * config/i386/i386.c (ix86_function_versions): Quote a %D directive. PR translation/80280 - Missing closing quote (%>) c/semantics.c and c/c-typeck.c gcc/cp/ChangeLog: PR translation/80280 * call.c (print_z_candidate): Add missing quoting to %D and other like directives. (build_op_call_1): Same. * constraint.cc (diagnose_check_constraint): Same. * mangle.c (mangle_decl): Same. * name-lookup.c (cp_binding_level_debug): Same. (set_decl_namespace): Same. * parser.c (cp_parser_tx_qualifier_opt): Same. * pt.c (print_candidates_1): Same. (check_template_variable): Same. (tsubst_default_argument): Same. (most_specialized_partial_spec): Same. * semantics.c (omp_reduction_lookup): Same. * tree.c (check_abi_tag_redeclaration): Same. * typeck.c (comptypes): Same. * typeck2.c (abstract_virtuals_error_sfinae): Same. PR translation/80280 - Missing closing quote (%>) c/semantics.c and c/c-typeck.c gcc/ChangeLog: PR translation/80280 * builtins.c (expand_builtin_object_size): Add missing quoting to %D and like directives. * hsa-gen.c (hsa_type_for_scalar_tree_type): Same. (hsa_type_for_tree_type): Same. (verify_function_arguments): Same. * symtab.c (symbol_table::change_decl_assembler_name): Same. * varasm.c (get_section): Same. (mark_weak): Same. PR translation/80280 - Missing closing quote (%>) c/semantics.c and c/c-typeck.c gcc/objc/ChangeLog: PR translation/80280 * objc-gnu-runtime-abi-01.c (objc_eh_runtime_type): Add missing quoting to directives. * objc-next-runtime-abi-01.c (objc_eh_runtime_type): Ditto. * objc-next-runtime-abi-02.c (next_runtime_02_eh_type): Ditto. PR translation/80280 - Missing closing quote (%>) c/semantics.c and c/c-typeck.c gcc/testsuite/ChangeLog: PR translation/80280 * g++.dg/abi/Wabi-2-3.C: Adjust. * g++.dg/abi/Wabi-3-2.C: Ditto. * g++.dg/lookup/using17.C: Ditto. * gcc.dg/format/gcc_diag-1.c (foo): Ditto. From-SVN: r247607
2017-01-01Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r243994
2016-10-24cxx-pretty-print.c (pp_cxx_check_constraint): Use VAR_P (x) instead of ↵Jakub Jelinek1-5/+3
TREE_CODE (x) == VAR_DECL. * cxx-pretty-print.c (pp_cxx_check_constraint): Use VAR_P (x) instead of TREE_CODE (x) == VAR_DECL. * constraint.cc (get_concept_definition): Likewise. (finish_shorthand_constraint): Likewise. * init.c (warn_placement_new_too_small): Likewise. * cp-gimplify.c (cp_genericize_r): Likewise. From-SVN: r241480
2016-09-26Implement -Wimplicit-fallthrough.Marek Polacek1-1/+2
Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r240485
2016-07-21Improving concepts performance and diagnostics.Andrew Sutton1-544/+991
PR c++/67565 PR c++/67579 PR c++/71843 gcc/ * timevar.def (TV_CONSTRAINT_SAT, TV_CONSTRAINT_SUB): New time vars for constraint satisfaction and subsumption. * timevar.h (auto_timevar): New constructor that matches the push/pop pattern of usage in pt.c. gcc/cp/ * cp-tree.def (CHECK_CONSTR): New. * cp-tree.h (CHECK_CONSTR_CONCEPT): New. (CHECK_CONSTR_ARGS): New. * constraint.cc (make_predicate_constraint): Remove in favor of normalize_expression. (resolve_constraint_check): Actually return error_mark_node when resolution fails. (resolve_variable_concept_check): Perform coercion as if processing a template. Also return errors on resolution failure. (lift_*): Remove all of these functions. Don't unnecessarily inline concepts. (learn_*): Add facilities to memoize implications for subsumption during normalization. (expanding_concept): New. (expand_concept): New. Return the inlined and normalized definition of a concept when needed. (transform_*, xform_*): Rename to normalize_* to better reflect the responsibility of those functions. (normalize_template_id_expression): Check for non-boolean operands when possible. Generate check constraints instead of normal variable references. (normalize_call_expression): Report errors when resolution fails. (check_for_logical_overloads): Rewrite this check to more accurately report the error. (normalize_atom): Check for overloaded calls and invalid types before determining if the expression refers to a concept. (build_constraints): Don't cache normalized constraints or decmposed assumptions. (finish_shorthand_constraint): Return a normalized expression instead of a predicate constraint. (finish_template_introduction): Same. (placeholder_extract_concept_and_args): Rewrite this since we only ever get check constraints here. (equivalent_placeholder_constraints): Rewrite in terms of check constraints, and handle error_mark_nodes correctly. (tsubst_check_constraint, tsubst_expr_constr, tsubst_type_constr) (tsubst_implicit_conversion_constr) (tsubst_argument_deduction_constr, tsubst_exception_constr) (tsubst_parameterized_constraint, tsubst_constraint): New. (tsbust_conjunection): Replace with tsubst_logical_operator and actually generate the right kind of constraint. (tsubst_requirement_body): Reverse the order of substituted arguments so that they appear in the order written (helps diagnostics). (satisfy_check_constraint): New. (satisfy_conjunction): Simplify. (satisfy_disjunction): Same. (satisfy_constraint_1): Handle check constraints. (eval_constr): New (private) global state. (evaluating_constraints_sentinel): New. Manages eval_constr. (satisfy_constraint): Add timing variables. (satisfy_associated_constraints): Add hooks for memoization. (evaluate_function_concept): Build a check constraint instead of normalizing its definition. (evaluate_variable_concept): Same. (evaluate_constraint_expression): Normalize, but in the current declaration processing context. (evaluating_constraints_p): New. (elide_constraint_failure_p): Actually emit constraint_thresh errors. (diagnose_*): Remove artificial indentation. Add a new parameter to each that tracks the current (complete) constraint prior to any substitutions. (diagnose_expression): Removed. (diagnose_call_expression): Same. (diagnose_template_id): Same. (diagnose_template_id): New. (diagnose_logical_constraint): New. (diagnose_expression_constraint): Show the original expression. (diagnose_type_constraint): Show the original type. (diagnose_implicit_conversion_constraint): Be specific about failures, don't re-diagnose a known-to-be-failed substitutions, and manage elisions properly. (diagnose_argument_deduction_constraint): Same. (diagnose_exception_constraint): Same. (diagnose_parameterized_constraint): Same. (constraint_p): Allow EXPR_PACK_EXPANSION. * logic.cc (next_by_distance): Removed. No longer used. (any_p): Renamed from any_of. (term_entry, term_hasher): New. (term_list): Rewrite to include a hash table for quick lookup. Also, make less stateful. (proof_state): Extend to allow goals to be discharged once satisfied. (non_atomic_constraint_p): New. (any_non_atomic_constraints_p): New. (...rest...): Previous implementation completely replaced with an iterative algorithm that opportunistically prunes the search space before committing to using more memory. * parser.c: (cp_parser_type_parameter): Normalize constraints. (cp_parser_explicit_template_declaration): Same. * pt.c: (finish_template_variable): Be less redundant with this error message. (template_args_equal): No longer static. (tsubst_decl): Don't try to find specializations of variables that have already been instantiated. (build_non_dependent_expr): Avoid infinite recursion during concept expansion. (make_constrained_auto): Normalize constraints. (do_auto_deduction): When doing auto deduction from a partial-concept-id, be sure to include the explicit args checking the constraints. (constraint_sat_*): New. Memoize satisfied constraints. (concept_spec_*): New. Memoize expressions associated with a concept specialization. (constraint_memos, concept_memos): New. (lookup_constraint_satisfaction, memoize_constraint_satisfaction): New. (lookup_concept_satisfaction, memoize_concept_satisfaction): New. (get_concept_expansion, save_concept_expansion): New. (hash_subsumption_args): New. (comp_subsumption_args): New. (subsumption_*): New. Memoize parts of the subsumption relation. (lookup_subsumption_result, save_subsumption_result): New. (init_constraint_processing): Initialize memo tables. (get_constraints): Shortcut if !flag_concepts. * decl.c (grokfndecl): Normalize constraints. * error.c (dump_simple_decl): Print "concept" when appropriate. (dump_function_decl): Same. (dump_template_decl): Don't write requirements when we're not printing the header. (dump_expr): Handle fold expressions. * cxx-pretty-print.c (cxx_pretty_printer::expression): Handle fold expressions. (get_fold_operator): New. (pp_cxx_unary_left_fold_expression): New. (pp_cxx_unary_right_fold_expression): New. (pp_cxx_binary_fold_expression): New. (pp_cxx_check_constraint): New. (pp_cxx_*_constraint): Rewrite the grammar of internal constraints to make them easier to read when debugging. * search.c (accessible_p): Don't shortcut when evaluating constraints. * tree.c (cp_tree_equal): Handle CHECK_CONSTR. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r238558
2016-06-21Fix constraint satisfaction in uninstantiated template.Jason Merrill1-2/+4
* constraint.cc (constraints_satisfied_p): Keep as many levels of args as our template has levels of parms. From-SVN: r237655
2016-01-04Update copyright years.Jakub Jelinek1-1/+1
From-SVN: r232055
2015-12-07re PR c++/68683 ([concepts] function satisfy_argument_deduction_constraint ↵Ryan Burn1-0/+3
modifies a type tree node but leaves TYPE_CANONICAL unchanged) PR c++/68683 * constraint.cc (satisfy_argument_deduction_constraint): Set TYPE_CANONICAL to NULL_TREE if PLACEHOLDER_TYPE_CONSTRAINTS are changed. From-SVN: r231385
2015-12-06Fix memclass5.C, memfriend10.C, var-templ19.C with -std=c++1z.Jason Merrill1-0/+9
* constraint.cc (strictly_subsumes): New. * cp-tree.h: Declare it. * pt.c (process_partial_specialization): Use it instead of subsumes_constraints. (maybe_new_partial_specialization): Do compare null constraints. * search.c (lookup_member): Handle currently_open_class returning null. From-SVN: r231350
2015-12-02re PR c++/68290 (g++.dg/concepts/auto1.C FAILs)Eric Botcazou1-26/+0
PR c++/68290 * constraint.cc (make_constrained_auto): Move to... * pt.c (make_auto_1): Add set_canonical parameter and set TYPE_CANONICAL on the type only if it is true. (make_decltype_auto): Adjust call to make_auto_1. (make_auto): Likewise. (splice_late_return_type): Likewise. (make_constrained_auto): ...here. Call make_auto_1 instead of make_auto and pass false. Set TYPE_CANONICAL directly. From-SVN: r231189
2015-11-06Support non-type constrained-type-specifiers.Jason Merrill1-10/+27
* parser.c (check_type_concept): Remove. (cp_parser_maybe_constrained_type_specifier): Don't call it. (synthesize_implicit_template_parm): Handle non-type and template template parameters. Also compare extra args. Return the decl. (cp_parser_template_argument): Handle constrained-type-specifiers for non-type template parameters. (finish_constrained_template_template_parm): Split out from cp_parser_constrained_template_template_parm. (cp_parser_nonclass_name): Move some logic into cp_parser_maybe_concept_name. (cp_parser_init_declarator): Fix error recovery. (get_concept_from_constraint): Remove. (cp_parser_simple_type_specifier): Adjust for synthesize_implicit_template_parm returning the decl. * constraint.cc (placeholder_extract_concept_and_args) (equivalent_placeholder_constraints): Also handle TYPE_DECL constrained parms. From-SVN: r229860
2015-10-31Implement multiple 'auto' feature from Concepts TS.Jason Merrill1-0/+83
* parser.c (cp_parser_type_id_1): Allow 'auto' if -fconcepts. (cp_parser_template_type_arg): Likewise. (get_concept_from_constraint): Split out most logic to... * constraint.cc (placeholder_extract_concept_and_args): ...here. (equivalent_placeholder_constraints, hash_placeholder_constraint): New. * cxx-pretty-print.c (pp_cxx_constrained_type_spec): New. * cxx-pretty-print.h: Declare it. * error.c (dump_type) [TEMPLATE_TYPE_PARM]: Call it. * pt.c (is_auto_r, extract_autos_r, extract_autos, auto_hash): New. (type_uses_auto): Use is_auto_r. (do_auto_deduction): Handle multiple 'auto's if -fconcepts. * typeck.c (structural_comptypes) [TEMPLATE_TYPE_PARM]: Compare constraints. From-SVN: r229629
2015-08-21re PR c++/67240 ([concepts] Implicit conversion constraints are not respected)Jason Merrill1-1/+1
PR c++/67240 * constraint.cc (satisfy_implicit_conversion_constraint): Also check for NULL_TREE. From-SVN: r227081
2015-08-08re PR c++/67159 ([c++concepts] Segfault while diagnosing constraint violation)Jason Merrill1-0/+1
PR c++/67159 * constraint.cc (finish_template_introduction): SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT. From-SVN: r226738
2015-08-07Add C++ Concepts TS support.Andrew Sutton1-0/+2617
gcc/c-family/ * c-common.c (c_common_reswords): Add __is_same_as, concept, requires. * c-common.h (enum rid): Add RID_IS_SAME_AS, RID_CONCEPT, RID_REQUIRES. (D_CXX_CONCEPTS, D_CXX_CONCEPTS_FLAGS): New. * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_concepts. * c-opts.c (set_std_cxx1z): Set flag_concepts. * c.opt (fconcepts): New. gcc/cp/ * constraint.cc, logic.cc: New files. * Make-lang.in (CXX_AND_OBJCXX_OBJS): Add constraint.o and logic.o. (c++.tags): Also process .cc files. * call.c (enum rejection_reason_code): Add rr_constraint_failure. (print_z_candidate): Handle it. (constraint_failure): New. (add_function_candidate): Check constraints. (build_new_function_call): Handle evaluating concepts. (joust): Check more_constrained. * class.c (add_method): Check equivalently_constrained. (build_clone): Copy constraints. (currently_open_class): Return tree. (resolve_address_of_overloaded_function): Check constraints. * constexpr.c (cxx_eval_constant_expression): Handle REQUIRES_EXPR. (potential_constant_expression_1): Likewise. * cp-objcp-common.c (cp_tree_size): Handle CONSTRAINT_INFO. (cp_common_init_ts): Handle WILDCARD_DECL and REQUIRES_EXPR. * cp-tree.def: Add CONSTRAINT_INFO, WILDCARD_DECL, REQUIRES_EXPR, SIMPLE_REQ, TYPE_REQ, COMPOUND_REQ, NESTED_REQ, PRED_CONSTR, EXPR_CONSTR, TYPE_CONSTR, ICONV_CONSTR, DEDUCT_CONSTR, EXCEPT_CONSTR, PARM_CONSTR, CONJ_CONSTR, DISJ_CONSTR. * cp-tree.h (struct tree_constraint_info, check_nonnull) (check_constraint_info, CI_TEMPLATE_REQS, CI_DECLARATOR_REQS) (CI_ASSOCIATED_CONSTRAINTS, CI_NORMALIZED_CONSTRAINTS) (CI_ASSUMPTIONS, TEMPLATE_PARMS_CONSTRAINTS) (TEMPLATE_PARM_CONSTRAINTS, COMPOUND_REQ_NOEXCEPT_P) (PLACEHOLDER_TYPE_CONSTRAINTS, PRED_CONSTR_EXPR, EXPR_CONSTR_EXPR) (TYPE_CONSTR_TYPE, ICONV_CONSTR_EXPR, ICONV_CONSTR_TYPE) (DEDUCT_CONSTR_EXPR, DEDUCT_CONSTR_PATTERN) (DEDUCT_CONSTR_PLACEHOLDER, EXCEPT_CONSTR_EXPR, PARM_CONSTR_PARMS) (PARM_CONSTR_OPERAND, CONSTRAINT_VAR_P, CONSTRAINED_PARM_CONCEPT) (CONSTRAINED_PARM_EXTRA_ARGS, CONSTRAINED_PARM_PROTOTYPE) (DECL_DECLARED_CONCEPT_P, WILDCARD_PACK_P, struct cp_unevaluated) (struct local_specialization_stack, enum auto_deduction_context) (variable_concept_p, concept_template_p) (struct deferring_access_check_sentinel): New. (enum cp_tree_node_structure_enum): Add TS_CP_CONSTRAINT_INFO. (union lang_tree_node): Add constraint_info field. (struct lang_decl_base): Add concept_p flag. (enum cp_decl_spec): Add ds_concept. (struct cp_declarator): Add requires_clause. * cxx-pretty-print.c (cxx_pretty_printer::primary_expression) (cxx_pretty_printer::expression): Handle REQUIRES_EXPR, TRAIT_EXPR, *_CONSTR. (pp_cxx_parameter_declaration_clause): Accept a chain of PARM_DECLs. (cxx_pretty_printer::declarator): Print requires-clause. (pp_cxx_template_declaration): Likewise. (pp_cxx_trait_expression): Handle CPTK_IS_SAME_AS. (pp_cxx_requires_clause, pp_cxx_requirement) (pp_cxx_requirement_list, pp_cxx_requirement_body) (pp_cxx_requires_expr, pp_cxx_simple_requirement) (pp_cxx_type_requirement, pp_cxx_compound_requirement) (pp_cxx_nested_requirement, pp_cxx_predicate_constraint) (pp_cxx_expression_constraint, pp_cxx_type_constraint) (pp_cxx_implicit_conversion_constraint) (pp_cxx_argument_deduction_constraint) (pp_cxx_exception_constraint, pp_cxx_parameterized_constraint) (pp_cxx_conjunction, pp_cxx_disjunction, pp_cxx_constraint): New. * cxx-pretty-print.h: Declare them. * decl.c (decls_match): Compare constraints. (duplicate_decls): Likewise. Remove constraints before freeing. (cxx_init_decl_processing): Call init_constraint_processing. (cp_finish_decl): Diagnose concept without initializer. (grokfndecl, grokvardecl): Handle concepts and constraints. (grokdeclarator): Handle concept, requires-clause. (grokparms): No longer static. (xref_tag_1): Check constraints. (finish_function): Call check_function_concept. (cp_tree_node_structure): Handle CONSTRAINT_INFO. (check_concept_refinement, is_concept_var, check_concept_fn): New. * decl2.c (check_classfn): Compare constraints. (mark_used): Don't instantiate concepts. * error.c (dump_template_decl): Print constraints. (dump_function_decl): Likewise. (dump_expr): Handle REQUIRES_EXPR, *_REQ, *_CONSTR. * lex.c (init_reswords): Set D_CXX_CONCEPTS. * method.c (implicitly_declare_fn): Copy constraints from inherited ctor. * parser.h (struct cp_parser): Add in_result_type_constraint_p and prevent_constrained_type_specifiers fields. * parser.c (make_call_declarator): Add requires_clause parm. (cp_parser_new): Clear prevent_constrained_type_specifiers. (cp_parser_primary_expression): Handle RID_IS_SAME_AS, RID_REQUIRES. (cp_parser_postfix_expression): Set prevent_constrained_type_specifiers. (cp_parser_trait_expr): Handle RID_IS_SAME_AS. (cp_parser_declaration): Handle concept introduction. (cp_parser_member_declaration): Likewise. (cp_parser_template_parameter): Handle constrained parameter. (cp_parser_type_parameter): Handle constraints. (cp_parser_decl_specifier_seq): Handle RID_CONCEPT. (cp_parser_template_id): Handle partial concept id. (cp_parser_type_name): Add overload that takes typename_keyword_p. Handle constrained parameter. (cp_parser_nonclass_name): Handle concept names. (cp_parser_alias_declaration): Handle constraints. (cp_parser_late_return_type_opt): Also handle requires-clause. (cp_parser_type_id_1): Handle deduction constraint. (cp_parser_parameter_declaration): Handle constrained parameters. (cp_parser_class_specifier_1): Handle constraints. (cp_parser_template_declaration_after_parameters): Split out from cp_parser_template_declaration_after_export. (cp_parser_single_declaration): Handle constraints. (synthesize_implicit_template_parm): Handle constraints. (cp_parser_maybe_concept_name, cp_parser_maybe_partial_concept_id) (cp_parser_introduction_list, get_id_declarator) (get_unqualified_id, is_constrained_parameter) (cp_parser_check_constrained_type_parm) (cp_parser_constrained_type_template_parm) (cp_parser_constrained_template_template_parm) (constrained_non_type_template_parm, finish_constrained_parameter) (declares_constrained_type_template_parameter) (declares_constrained_template_template_parameter) (check_type_concept, cp_parser_maybe_constrained_type_specifier) (cp_parser_maybe_concept_name, cp_parser_maybe_partial_concept_id) (cp_parser_requires_clause, cp_parser_requires_clause_opt) (cp_parser_requires_expression) (cp_parser_requirement_parameter_list, cp_parser_requirement_body) (cp_parser_requirement_list, cp_parser_requirement) (cp_parser_simple_requirement, cp_parser_type_requirement) (cp_parser_compound_requirement, cp_parser_nested_requirement) (cp_parser_template_introduction) (cp_parser_explicit_template_declaration) (get_concept_from_constraint): New. * pt.c (local_specialization_stack): Implement. (maybe_new_partial_specialization): New. (maybe_process_partial_specialization): Use it. (retrieve_local_specialization, register_local_specialization) (template_parm_to_arg, build_template_decl, extract_fnparm_pack) (tsubst_expr): No longer static. (spec_hasher::equal): Compare constraints. (determine_specialization): Handle constraints. (check_explicit_specialization): Handle concepts. (process_template_parm): Handle constraints. (end_template_parm_list): Add overload taking no arguments. (process_partial_specialization): Handle concepts and constraints. Register partial specializations of variable templates. (redeclare_class_template): Handle constraints. (convert_template_argument): Handle WILDCARD_DECL. Check is_compatible_template_arg. (coerce_template_parameter_pack): Handle wildcard packs. (coerce_template_parms): DR 1430 also applies to concepts. Add overloads taking fewer parameters. (lookup_template_class_1): Handle constraints. (lookup_template_variable): Concepts are always bool. (finish_template_variable): Handle concepts and constraints. (tsubst_friend_class): Handle constraints. (gen_elem_of_pack_expansion_instantiation): Handle constraints. (tsubst_pack_expansion): Handle local parameters. (tsubst_decl) [FUNCTION_DECL]: Handle constraints. (tsubst) [TEMPLATE_TYPE_PARM]: Handle deduction constraints. (tsubst_copy_and_build): Handle REQUIRES_EXPR. (more_specialized_fn, more_specialized_partial_spec): Check constraints. (more_specialized_inst): Split out from most_specialized_instantiation. (most_specialized_partial_spec): Check constraints. (instantiate_decl): Never instantiate a concept. (value_dependent_expression_p): Handle REQUIRES_EXPR, TYPE_REQ, variable concepts. (type_dependent_expression_p): Handle WILDCARD_DECL, REQUIRES_EXPR. (instantiation_dependent_r): Handle REQUIRES_EXPR and concepts. (do_auto_deduction): Add overload taking tsubst flags and context enum. Handle constraints. (get_template_for_ordering, most_constrained_function) (is_compatible_template_arg, convert_wildcard_argument) (struct constr_entry, struct constr_hasher, decl_constraints) (valid_constraints_p, get_constraints, set_constraints) (remove_constraints, init_constraint_processing): New. * ptree.c (cxx_print_xnode): Handle CONSTRAINT_INFO. * search.c (lookup_member): Do lookup in the open partial instantiation. * semantics.c (finish_template_template_parm): Handle constraints. (fixup_template_type): New. (finish_template_type): Call it. (trait_expr_value, finish_trait_expr): Handle CPTK_IS_SAME_AS. * tree.c (cp_tree_equal): Handle local parameters, CONSTRAINT_INFO. (cp_walk_subtrees): Handle REQUIRES_EXPR. * typeck.c (cp_build_function_call_vec): Check constraints. Co-Authored-By: Braden Obrzut <admin@maniacsvault.net> Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r226713