]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/c-family/ChangeLog
Add C++ Concepts TS support.
authorAndrew Sutton <andrew.n.sutton@gmail.com>
Fri, 7 Aug 2015 05:44:49 +0000 (05:44 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 7 Aug 2015 05:44:49 +0000 (01:44 -0400)
commit971e17ff87337ad533b51c2dff0bbdf607fa1faf
tree23bad22378f96699b757d5523bf73d4139ad66da
parentbf5372e7f0c5c0df7f239ce96ce35a2114400269
Add C++ Concepts TS support.

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
158 files changed:
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-family/c-cppbuiltin.c
gcc/c-family/c-opts.c
gcc/c-family/c.opt
gcc/cp/ChangeLog
gcc/cp/Make-lang.in
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/constexpr.c
gcc/cp/constraint.cc [new file with mode: 0644]
gcc/cp/cp-objcp-common.c
gcc/cp/cp-tree.def
gcc/cp/cp-tree.h
gcc/cp/cxx-pretty-print.c
gcc/cp/cxx-pretty-print.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/error.c
gcc/cp/lex.c
gcc/cp/logic.cc [new file with mode: 0644]
gcc/cp/method.c
gcc/cp/parser.c
gcc/cp/parser.h
gcc/cp/pt.c
gcc/cp/ptree.c
gcc/cp/search.c
gcc/cp/semantics.c
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/doc/extend.texi
gcc/testsuite/g++.dg/concepts/alias1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/alias2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/alias3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/alias4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/class.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/class1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/class2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/class3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/class4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/class5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/class6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/constrained-parm.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/decl-diagnose.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/deduction-constraint1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/disjunction1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/dr1430.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/equiv.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/equiv2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-inst1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-inst2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-inst3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-inst4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-spec1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-spec2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-spec3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-spec4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-spec5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/explicit-spec6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/expression.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/expression2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/expression3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/feature-macro.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn-concept1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn-concept2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/fn9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/friend1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/friend2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/generic-fn-err.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/generic-fn.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/inherit-ctor1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/inherit-ctor2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/inherit-ctor3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/inherit-ctor4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/intro1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/intro2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/intro3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/intro4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/intro5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/intro6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/intro7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/member-concept.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/memfun-err.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/memfun.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/partial-concept-id1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/partial-concept-id2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/partial-spec.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/partial-spec2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/partial-spec3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/partial-spec4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/partial-spec5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/placeholder1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/placeholder2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/placeholder3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/placeholder4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/placeholder5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/pr65552.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/pr65575.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/pr65634.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/pr65636.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/pr65681.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/pr65848.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/pr65854.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/pr66091.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req-neg1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req13.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req14.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req15.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req16.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req17.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req18.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/req9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-parm9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/template-template-parm1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/traits1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/traits2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/var-concept1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/var-concept2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/var-concept3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/var-concept4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/var-concept5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/var-concept6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/var-templ1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/var-templ2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/variadic1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/concepts/variadic2.C [new file with mode: 0644]