From: Nathan Sidwell Date: Tue, 16 May 2017 13:15:53 +0000 (+0000) Subject: cp-tree.h (OVL_FIRST, OVL_NAME): New. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=848bf88da828bfa5467a7d07eb81f946f4937b5c;p=gcc.git cp-tree.h (OVL_FIRST, OVL_NAME): New. * 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ee25eface70..c094ea0d63e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,28 @@ 2017-05-16 Nathan Sidwell + * 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. + * pt.c (tsubst_copy_and_build): Remove unnecessary COMPONENT_REF peeking. * semantics.c (finish_id_expression): Directly init local var. diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 3783553152a..59b315159be 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -117,10 +117,9 @@ function_concept_check_p (tree t) gcc_assert (TREE_CODE (t) == CALL_EXPR); tree fn = CALL_EXPR_FN (t); if (fn != NULL_TREE - && TREE_CODE (fn) == TEMPLATE_ID_EXPR - && TREE_CODE (TREE_OPERAND (fn, 0)) == OVERLOAD) + && TREE_CODE (fn) == TEMPLATE_ID_EXPR) { - tree f1 = get_first_fn (fn); + tree f1 = OVL_FIRST (TREE_OPERAND (fn, 0)); if (TREE_CODE (f1) == TEMPLATE_DECL && DECL_DECLARED_CONCEPT_P (DECL_TEMPLATE_RESULT (f1))) return true; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 8244a768c91..8dee22f42f9 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -626,6 +626,11 @@ typedef struct ptrmem_cst * ptrmem_cst_t; and can be freed afterward. */ #define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE)) +/* The first decl of an overload. */ +#define OVL_FIRST(NODE) ovl_first (NODE) +/* The name of the overload set. */ +#define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE)) + struct GTY(()) tree_overload { struct tree_common common; tree function; @@ -6668,6 +6673,13 @@ extern tree hash_tree_cons (tree, tree, tree); extern tree hash_tree_chain (tree, tree); extern tree build_qualified_name (tree, tree, tree, bool); extern tree build_ref_qualified_type (tree, cp_ref_qualifier); +inline tree +ovl_first (tree node) +{ + while (TREE_CODE (node) == OVERLOAD) + node = OVL_FUNCTION (node); + return node; +} extern int is_overloaded_fn (tree); extern tree dependent_name (tree); extern tree get_fns (tree); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 5f4b5e30a5f..a53c0b3751a 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1722,7 +1722,7 @@ build_expr_type_conversion (int desires, tree expr, bool complain) int win = 0; tree candidate; tree cand = TREE_VALUE (conv); - cand = OVL_CURRENT (cand); + cand = OVL_FIRST (cand); if (winner && winner == cand) continue; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 476fd8da2ef..7fe0be3584c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -683,7 +683,7 @@ poplevel (int keep, int reverse, int functionbody) for (link = decls; link; link = TREE_CHAIN (link)) { decl = TREE_CODE (link) == TREE_LIST ? TREE_VALUE (link) : link; - tree name = DECL_NAME (OVL_CURRENT (decl)); + tree name = OVL_NAME (decl); if (leaving_for_scope && VAR_P (decl) /* It's hard to make this ARM compatibility hack play nicely with @@ -10104,10 +10104,7 @@ grokdeclarator (const cp_declarator *declarator, if (variable_template_p (dname)) dname = DECL_NAME (dname); else - { - gcc_assert (is_overloaded_fn (dname)); - dname = DECL_NAME (get_first_fn (dname)); - } + dname = OVL_NAME (dname); } } /* Fall through. */ diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 46959ec77f7..4b99a8ebe8d 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -5029,7 +5029,7 @@ mark_used (tree decl, tsubst_flags_t complain) decl = BASELINK_FUNCTIONS (decl); if (really_overloaded_fn (decl)) return true; - decl = OVL_CURRENT (decl); + decl = OVL_FIRST (decl); } /* Set TREE_USED for the benefit of -Wunused. */ diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 0912d2d66b9..e8136d3eca1 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1208,7 +1208,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) /* If there's only one function, just treat it like an ordinary FUNCTION_DECL. */ - t = OVL_CURRENT (t); + t = OVL_FIRST (t); /* Fall through. */ case FUNCTION_DECL: @@ -1235,10 +1235,8 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) tree name = TREE_OPERAND (t, 0); tree args = TREE_OPERAND (t, 1); - if (is_overloaded_fn (name)) - name = get_first_fn (name); - if (DECL_P (name)) - name = DECL_NAME (name); + if (!identifier_p (name)) + name = OVL_NAME (name); dump_decl (pp, name, flags); pp_cxx_begin_template_argument_list (pp); if (args == error_mark_node) @@ -2498,7 +2496,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) /* A::f */ dump_expr (pp, t, flags | TFF_EXPR_IN_PARENS); else if (BASELINK_P (t)) - dump_expr (pp, OVL_CURRENT (BASELINK_FUNCTIONS (t)), + dump_expr (pp, OVL_FIRST (BASELINK_FUNCTIONS (t)), flags | TFF_EXPR_IN_PARENS); else dump_decl (pp, t, flags); @@ -3004,7 +3002,7 @@ location_of (tree t) return input_location; } else if (TREE_CODE (t) == OVERLOAD) - t = OVL_FUNCTION (t); + t = OVL_FIRST (t); if (DECL_P (t)) return DECL_SOURCE_LOCATION (t); diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 8708fe596a2..834a1544a54 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -494,8 +494,7 @@ do_friend (tree ctype, tree declarator, tree decl, if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR) { declarator = TREE_OPERAND (declarator, 0); - if (is_overloaded_fn (declarator)) - declarator = DECL_NAME (get_first_fn (declarator)); + declarator = OVL_NAME (declarator); } if (ctype) diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 00916d73a91..a905af8c85a 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2063,7 +2063,7 @@ build_offset_ref (tree type, tree member, bool address_p, if (TREE_CODE (t) != TEMPLATE_ID_EXPR && !really_overloaded_fn (t)) { /* Get rid of a potential OVERLOAD around it. */ - t = OVL_CURRENT (t); + t = OVL_FIRST (t); /* Unique functions are handled easily. */ diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 9ee74a776ac..42290fee675 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2833,8 +2833,7 @@ write_member_name (tree member) else if (TREE_CODE (member) == TEMPLATE_ID_EXPR) { tree name = TREE_OPERAND (member, 0); - if (TREE_CODE (name) == OVERLOAD) - name = OVL_FUNCTION (name); + name = OVL_FIRST (name); write_member_name (name); write_template_args (TREE_OPERAND (member, 1)); } @@ -3053,10 +3052,7 @@ write_expression (tree expr) else if (TREE_CODE (expr) == TEMPLATE_ID_EXPR) { tree fn = TREE_OPERAND (expr, 0); - if (is_overloaded_fn (fn)) - fn = get_first_fn (fn); - if (DECL_P (fn)) - fn = DECL_NAME (fn); + fn = OVL_NAME (fn); if (IDENTIFIER_OPNAME_P (fn)) write_string ("on"); write_unqualified_id (fn); @@ -3257,7 +3253,7 @@ write_expression (tree expr) if ((TREE_CODE (fn) == FUNCTION_DECL || TREE_CODE (fn) == OVERLOAD) && type_dependent_expression_p_push (expr)) - fn = DECL_NAME (get_first_fn (fn)); + fn = OVL_NAME (fn); write_expression (fn); } diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 6a2f18ce0fd..a9bc4907eb7 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -502,10 +502,8 @@ strip_inheriting_ctors (tree dfn) return dfn; tree fn = dfn; while (tree inh = DECL_INHERITED_CTOR (fn)) - { - inh = OVL_CURRENT (inh); - fn = inh; - } + fn = OVL_FIRST (inh); + if (TREE_CODE (fn) == TEMPLATE_DECL && TREE_CODE (dfn) == FUNCTION_DECL) fn = DECL_TEMPLATE_RESULT (fn); diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 7b4d27f44d0..1de8680faf5 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3610,7 +3610,6 @@ set_inherited_value_binding_p (cxx_binding *binding, tree decl, bool pushdecl_class_level (tree x) { - tree name; bool is_valid = true; bool subtime; @@ -3621,10 +3620,7 @@ pushdecl_class_level (tree x) subtime = timevar_cond_start (TV_NAME_LOOKUP); /* Get the name of X. */ - if (TREE_CODE (x) == OVERLOAD) - name = DECL_NAME (get_first_fn (x)); - else - name = DECL_NAME (x); + tree name = OVL_NAME (x); if (name) { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8f120aa1446..aa6af295c0f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2930,7 +2930,7 @@ check_explicit_specialization (tree declarator, methods->iterate (idx, &ovl); ++idx) { - if (!DECL_CONV_FN_P (OVL_CURRENT (ovl))) + if (!DECL_CONV_FN_P (OVL_FIRST (ovl))) /* There are no more conversion functions. */ break; @@ -3910,8 +3910,7 @@ check_template_shadow (tree decl) return true; /* Figure out what we're shadowing. */ - if (TREE_CODE (decl) == OVERLOAD) - decl = OVL_CURRENT (decl); + decl = OVL_FIRST (decl); olddecl = innermost_non_namespace_value (DECL_NAME (decl)); /* If there's no previous binding for this name, we're not shadowing @@ -14128,7 +14127,7 @@ tsubst_baselink (tree baselink, tree object_type, template_args = tsubst_template_args (template_args, args, complain, in_decl); } - name = DECL_NAME (get_first_fn (fns)); + name = OVL_NAME (fns); if (IDENTIFIER_TYPENAME_P (name)) name = mangle_conv_op_name_for_type (optype); baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1); @@ -14150,7 +14149,7 @@ tsubst_baselink (tree baselink, tree object_type, if (BASELINK_P (baselink)) fns = BASELINK_FUNCTIONS (baselink); if (!template_id_p && !really_overloaded_fn (fns) - && !mark_used (OVL_CURRENT (fns), complain) && !(complain & tf_error)) + && !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error)) return error_mark_node; /* Add back the template arguments, if present. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6c46823cec0..d9e1ee39d61 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2231,15 +2231,10 @@ perform_koenig_lookup (cp_expr fn, vec *args, /* Find the name of the overloaded function. */ if (identifier_p (fn)) identifier = fn; - else if (is_overloaded_fn (fn)) - { - functions = fn; - identifier = DECL_NAME (get_first_fn (functions)); - } - else if (DECL_P (fn)) + else { functions = fn; - identifier = DECL_NAME (fn); + identifier = OVL_NAME (functions); } /* A call to a namespace-scope function using an unqualified name. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 2382f14b571..7b621736d6a 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2169,7 +2169,7 @@ get_fns (tree from) tree get_first_fn (tree from) { - return OVL_CURRENT (get_fns (from)); + return OVL_FIRST (get_fns (from)); } /* Return a new OVL node, concatenating it with the old one. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 6bc88a9d780..6f15c9be07b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2764,10 +2764,8 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p, template_args = TREE_OPERAND (name, 1); name = TREE_OPERAND (name, 0); - if (TREE_CODE (name) == OVERLOAD) - name = DECL_NAME (get_first_fn (name)); - else if (DECL_P (name)) - name = DECL_NAME (name); + if (!identifier_p (name)) + name = OVL_NAME (name); } if (scope) @@ -5746,7 +5744,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) /* Fall through. */ case OVERLOAD: - arg = OVL_CURRENT (arg); + arg = OVL_FIRST (arg); break; case OFFSET_REF: