This patch adds constraint checking and overloading for function
templates, class templates, and alias templates. This patch isn't as
big as it seems, it just touches the compiler in a lot of different
places.


2013-06-01  Andrew Sutton  <andrew.n.sut...@gmail.com>
        * gcc/cp/call.c (rejection_reason_code): Add rr_constraint_failure.
        (template_constraint_failure): New.
        (template_constraint_failure): Check declaration constraints
        before other viable function criteria.
        (add_template_candidate_real): Diagnose constraint failures,
        and attach constraints to instantiated candidates.
        (print_z_candidate): Diagnose constraint failures.
        (get_actual_template): New.
        (joust): Allow temploids to also participate in most specialied
        when they have constraints.
        * gcc/cp/constraint.cc (join_requirements): New
        (conjoin_requirements): Join expressions correctly.
        (disjoin_requirements): Join expressions correctly.
        (is_checkable): Rename from is_constraint, check vs. concept flag.
        (resolve_constraint_check): Fix.
        (get_type_constraints): New.
        (get_decl_constraints): New.
        (get_constraints): New.
        (suppress_template_processing): New.
        (check_requirements): New.
        (check_dependent_requirements): New.
        (check_constraints): New.
        (check_type_constraints): New.
        (check_decl_constraints): New.
        (check_template_constraints): New.
        (equivalent_constraints): New.
        (equivalently_constrained): New.
        (more_constraints): New.
        (more_constrianed): New.
        (diagnose_constraint_failure): New.
        * gcc/cp/class.c (are_constrained_member_overloads): New.
        (add_method): Allow overloading of constrained member functions.
        * gcc/cp/ptree.c (cxx_print_xnode): Print constraint info.
        * gcc/cp/pt.c (local_specialization_stack): New.
        (build_template_info): Incorporate template requirements
        (check_explicit_specialization): Instantiate requirements for
        template info.
        (push_template_decl_real): Include constraints in template info.
        (redeclare_class_template): Diagnose redeclaration with different
        constraints.
        (is_compatible_template_arg): New.
        (convert_template_argument): Check constraints on template template
        arguments.
        (lookup_template_class_1): Check constraints on alias templates.
        Keep constraints with instantiated types.
        (instantiate_class_template_1): Check constraints on class templates.
        (tsubst_decl): Instantiate and keep constraints with template info.
        Also, allow dependent pack arguments to produce neww parameter
        packs when instantiated.
        (tsubst_copy): Handle REAL_TYPE and BOOLEAN_TYPE.
        (tsubst_copy_and_build): PARM_DECLs can be instantiated as pack
        expansions (used with requires expression).
        (fn_type_unification): Check constraints for function templates.
        (more_specialized_fn): Determine which candidate is more constrained.
        (tsubst_constraint): New.
        (substitute_requirements): New.
        * gcc/cp/parser.c (cp_unevaluated): New.
        * gcc/cp/tree.h (cp_unevaluated): New.
        (local_specialization_stack): New.
        (get_constraints): New.
        (check_constraints): New.
        (check_constraints): New.
        (check_template_constraints): New.
        (subst_template_constraints): New.
        (equivalent_constraints): New.
        (equivalently_constrained): New.
        (more_constraints): New.
        (more_constrained): New.
        (diagnose_constraint_failure): New.
        * gcc/cp/decl.c: (are_constrained_overloads): New.
        (duplicate_decls): Allow constrained function overloads, and diagnose
        attempts to overload concepts.
        (grokfndecl): Supply empty constraints to build_template_info.
        (cp_tree_node_structure): Add entry for CONSTRAINT_INFO.
        (semantics.c): Create template_info for template template parameters
        as a place to house constraints.
        * gcc/cp/tree.c (bind_template_template_parm): Provide empty
        constraints for bound template template parameters.
        * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Print the
        template requirements.

Attachment: reqs-2.patch
Description: Binary data

Reply via email to