There are three major pieces to this support: scalar operator<=>, synthesis of comparison operators, and rewritten/reversed overload resolution (e.g. a < b becomes 0 > b <=> a). Unlike other defaulted functions, where we use synthesized_method_walk to semi-simulate what the definition of the function will be like, this patch determines the characteristics of a comparison operator by trying to define it. My handling of non-dependent rewritten operators in templates can still use some work: build_min_non_dep_op_overload can't understand the rewrites and crashes, so I'm avoiding it for now by clearing *overload. This means we'll do name lookup again at instantiation time, which can incorrectly mean a different result. I'll poke at this more in stage 3. I'm leaving out a fourth section ("strong structural equality") even though I've implemented it, because it seems likely to change radically tomorrow. Thanks to Tim van Deurzen and Jakub for implementing lexing of the <=> operator, and Jonathan for the initial <compare> header. gcc/cp/ * cp-tree.h (struct lang_decl_fn): Add maybe_deleted bitfield. (DECL_MAYBE_DELETED): New. (enum special_function_kind): Add sfk_comparison. (LOOKUP_REWRITTEN, LOOKUP_REVERSED): New. * call.c (struct z_candidate): Add rewritten and reversed methods. (add_builtin_candidate): Handle SPACESHIP_EXPR. (add_builtin_candidates): Likewise. (add_candidates): Don't add a reversed candidate if the parms are the same. (add_operator_candidates): Split out from build_new_op_1. Handle rewritten and reversed candidates. (add_candidate): Swap conversions of reversed candidate. (build_new_op_1): Swap them back. Build a second operation for rewritten candidates. (extract_call_expr): Handle rewritten calls. (same_fn_or_template): New. (joust): Handle rewritten and reversed candidates. * class.c (add_implicitly_declared_members): Add implicit op==. (classtype_has_op, classtype_has_defaulted_op): New. * constexpr.c (cxx_eval_binary_expression): Handle SPACESHIP_EXPR. (cxx_eval_constant_expression, potential_constant_expression_1): Likewise. * cp-gimplify.c (genericize_spaceship): New. (cp_genericize_r): Use it. * cp-objcp-common.c (cp_common_init_ts): Handle SPACESHIP_EXPR. * decl.c (finish_function): Handle deleted function. * decl2.c (grokfield): SET_DECL_FRIEND_CONTEXT on defaulted friend. (mark_used): Check DECL_MAYBE_DELETED. Remove assumption that defaulted functions are non-static members. * error.c (dump_expr): Handle SPACESHIP_EXPR. * method.c (type_has_trivial_fn): False for sfk_comparison. (enum comp_cat_tag, struct comp_cat_info_t): New types. (comp_cat_cache): New array variable. (lookup_comparison_result, lookup_comparison_category) (is_cat, cat_tag_for, spaceship_comp_cat) (spaceship_type, genericize_spaceship) (common_comparison_type, early_check_defaulted_comparison) (comp_info, build_comparison_op): New. (synthesize_method): Handle sfk_comparison. Handle deleted. (get_defaulted_eh_spec, maybe_explain_implicit_delete) (explain_implicit_non_constexpr, implicitly_declare_fn) (defaulted_late_check, defaultable_fn_check): Handle sfk_comparison. * name-lookup.c (get_std_name_hint): Add comparison categories. * tree.c (special_function_p): Add sfk_comparison. * typeck.c (cp_build_binary_op): Handle SPACESHIP_EXPR. 2019-11-05 Tim van Deurzen <tim@kompiler.org> Add new tree code for the spaceship operator. gcc/cp/ * cp-tree.def: Add new tree code. * operators.def: New binary operator. * parser.c: Add new token and tree code. libcpp/ * cpplib.h: Add spaceship operator for C++. * lex.c: Implement conditional lexing of spaceship operator for C++20. 2019-11-05 Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ * libsupc++/compare: New header. * libsupc++/Makefile.am (std_HEADERS): Add compare. * include/std/version: Define __cpp_lib_three_way_comparison. * include/std/functional: #include <compare>. From-SVN: r277865
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
980310-1.C | Loading commit data... | |
README | Loading commit data... | |
eb10.C | Loading commit data... | |
eb102.C | Loading commit data... | |
eb103.C | Loading commit data... | |
eb104.C | Loading commit data... | |
eb105.C | Loading commit data... | |
eb106.C | Loading commit data... | |
eb107.C | Loading commit data... | |
eb108.C | Loading commit data... | |
eb109.C | Loading commit data... | |
eb11.C | Loading commit data... | |
eb110.C | Loading commit data... | |
eb111.C | Loading commit data... | |
eb112.C | Loading commit data... | |
eb113.C | Loading commit data... | |
eb114.C | Loading commit data... | |
eb115.C | Loading commit data... | |
eb116.C | Loading commit data... | |
eb119.C | Loading commit data... | |
eb12.C | Loading commit data... | |
eb120.C | Loading commit data... | |
eb121.C | Loading commit data... | |
eb122.C | Loading commit data... | |
eb123.C | Loading commit data... | |
eb124.C | Loading commit data... | |
eb125.C | Loading commit data... | |
eb126.C | Loading commit data... | |
eb127.C | Loading commit data... | |
eb128.C | Loading commit data... | |
eb129.C | Loading commit data... | |
eb129a.C | Loading commit data... | |
eb13.C | Loading commit data... | |
eb130.C | Loading commit data... | |
eb131.C | Loading commit data... | |
eb132.C | Loading commit data... | |
eb133a.C | Loading commit data... | |
eb133b.C | Loading commit data... | |
eb133c.C | Loading commit data... | |
eb14.C | Loading commit data... | |
eb15.C | Loading commit data... | |
eb16.C | Loading commit data... | |
eb17.C | Loading commit data... | |
eb18.C | Loading commit data... | |
eb19.C | Loading commit data... | |
eb2.C | Loading commit data... | |
eb20.C | Loading commit data... | |
eb21.C | Loading commit data... | |
eb22.C | Loading commit data... | |
eb23.C | Loading commit data... | |
eb24.C | Loading commit data... | |
eb26.C | Loading commit data... | |
eb27.C | Loading commit data... | |
eb28.C | Loading commit data... | |
eb29.C | Loading commit data... | |
eb3.C | Loading commit data... | |
eb30.C | Loading commit data... | |
eb31.C | Loading commit data... | |
eb32.C | Loading commit data... | |
eb33.C | Loading commit data... | |
eb34.C | Loading commit data... | |
eb35.C | Loading commit data... | |
eb36.C | Loading commit data... | |
eb37.C | Loading commit data... | |
eb38.C | Loading commit data... | |
eb39.C | Loading commit data... | |
eb4.C | Loading commit data... | |
eb41.C | Loading commit data... | |
eb43.C | Loading commit data... | |
eb44.C | Loading commit data... | |
eb45.C | Loading commit data... | |
eb46.C | Loading commit data... | |
eb48.C | Loading commit data... | |
eb49.C | Loading commit data... | |
eb5.C | Loading commit data... | |
eb50.C | Loading commit data... | |
eb51.C | Loading commit data... | |
eb52.C | Loading commit data... | |
eb54.C | Loading commit data... | |
eb55.C | Loading commit data... | |
eb56.C | Loading commit data... | |
eb57.C | Loading commit data... | |
eb58.C | Loading commit data... | |
eb59.C | Loading commit data... | |
eb6.C | Loading commit data... | |
eb60.C | Loading commit data... | |
eb61.C | Loading commit data... | |
eb62.C | Loading commit data... | |
eb63.C | Loading commit data... | |
eb64.C | Loading commit data... | |
eb65.C | Loading commit data... | |
eb66.C | Loading commit data... | |
eb67.C | Loading commit data... | |
eb69.C | Loading commit data... | |
eb7.C | Loading commit data... | |
eb70.C | Loading commit data... | |
eb71.C | Loading commit data... | |
eb73.C | Loading commit data... | |
eb74.C | Loading commit data... | |
eb75.C | Loading commit data... | |
eb76.C | Loading commit data... | |
eb77.C | Loading commit data... | |
eb79.C | Loading commit data... | |
eb8.C | Loading commit data... | |
eb80.C | Loading commit data... | |
eb81.C | Loading commit data... | |
eb82.C | Loading commit data... | |
eb83.C | Loading commit data... | |
eb84.C | Loading commit data... | |
eb86.C | Loading commit data... | |
eb87.C | Loading commit data... | |
eb88.C | Loading commit data... | |
eb9.C | Loading commit data... | |
eb90.C | Loading commit data... | |
eb91.C | Loading commit data... | |
eb92.C | Loading commit data... | |
eb93.C | Loading commit data... | |
eb94.C | Loading commit data... | |
eb95.C | Loading commit data... | |
eb97.C | Loading commit data... | |
eb98.C | Loading commit data... | |
eb99.C | Loading commit data... | |
ebnull-cast.C | Loading commit data... | |
ebnull-oldcast.C | Loading commit data... | |
ebnull.C | Loading commit data... | |
eh990323-1.C | Loading commit data... | |
eh990323-2.C | Loading commit data... | |
eh990323-3.C | Loading commit data... | |
eh990323-4.C | Loading commit data... | |
eh990323-5.C | Loading commit data... | |
ice990323-1.C | Loading commit data... | |
ice990323-2.C | Loading commit data... | |
ice990323-3.C | Loading commit data... | |
ice990323-4.C | Loading commit data... | |
ice990323-5.C | Loading commit data... |