From 83044e4fcc7b3f7514eaa84b31f44608ae5fbaf1 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 16 Nov 2018 16:23:20 +0000 Subject: Remove ovl_used, it is no longer needed Remove ovl_used, it is no longer needed * cp-tree.h (OVL_USED_P): Delete. (lookup_keep): Delete. * friend.c (add_friend): Don't call it. * parser.c (lookup_literal_operator): Likewise. (cp_parser_primary_expression): Likewise. * semantics.c (perform_koenig_lookup): Likewise. * pt.c (tsubst_copy ): Don't assert OVL_USED_P. * tree.c (ovl_copy): Delete. (ovl_insert): Remove OVL_USED_P checks. (ovl_iterator::reveal_node): Likewise. (ovl_iterator::remove__node): Likewise. (ovl_used, lookup_keep): Delete. From-SVN: r266212 --- gcc/cp/ChangeLog | 14 +++++++++++ gcc/cp/cp-tree.h | 3 --- gcc/cp/friend.c | 6 ----- gcc/cp/parser.c | 14 +---------- gcc/cp/pt.c | 2 -- gcc/cp/semantics.c | 5 ---- gcc/cp/tree.c | 73 ++++-------------------------------------------------- 7 files changed, 20 insertions(+), 97 deletions(-) (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6b167f3..b8a7437 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,19 @@ 2018-11-16 Nathan Sidwell + Remove ovl_used, it is no longer needed + * cp-tree.h (OVL_USED_P): Delete. + (lookup_keep): Delete. + * friend.c (add_friend): Don't call it. + * parser.c (lookup_literal_operator): Likewise. + (cp_parser_primary_expression): Likewise. + * semantics.c (perform_koenig_lookup): Likewise. + * pt.c (tsubst_copy ): Don't assert OVL_USED_P. + * tree.c (ovl_copy): Delete. + (ovl_insert): Remove OVL_USED_P checks. + (ovl_iterator::reveal_node): Likewise. + (ovl_iterator::remove__node): Likewise. + (ovl_used, lookup_keep): Delete. + PR c++/87269 * parser.c (lookup_literal_operator): Mark overload for keeping when inside template. Refactor. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f2e6709..a5c9e5b 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -706,8 +706,6 @@ typedef struct ptrmem_cst * ptrmem_cst_t; #define OVL_NESTED_P(NODE) TREE_LANG_FLAG_3 (OVERLOAD_CHECK (NODE)) /* If set, this overload was constructed during lookup. */ #define OVL_LOOKUP_P(NODE) TREE_LANG_FLAG_4 (OVERLOAD_CHECK (NODE)) -/* If set, this is a persistant lookup. */ -#define OVL_USED_P(NODE) TREE_USED (OVERLOAD_CHECK (NODE)) /* The first decl of an overload. */ #define OVL_FIRST(NODE) ovl_first (NODE) @@ -7222,7 +7220,6 @@ extern void lookup_mark (tree lookup, bool val); extern tree lookup_add (tree fns, tree lookup); extern tree lookup_maybe_add (tree fns, tree lookup, bool deduping); -extern void lookup_keep (tree lookup); extern int is_overloaded_fn (tree) ATTRIBUTE_PURE; extern bool really_overloaded_fn (tree) ATTRIBUTE_PURE; extern tree dependent_name (tree); diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index ce85a80..8cb1388 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -173,12 +173,6 @@ add_friend (tree type, tree decl, bool complain) if (decl == error_mark_node) return; - if (TREE_CODE (decl) == FUNCTION_DECL - && DECL_TEMPLATE_INSTANTIATION (decl)) - /* We'll have parsed this as a declaration, and therefore not - marked the lookup set for keeping. Do that now. */ - lookup_keep (DECL_TI_TEMPLATE (decl)); - typedecl = TYPE_MAIN_DECL (type); list = DECL_FRIENDLIST (typedecl); name = DECL_NAME (decl); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 99bd4dc..92a4f96 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4294,11 +4294,7 @@ lookup_literal_operator (tree name, vec *args) work in presence of default arguments on the literal operator parameters. */ && parmtypes == void_list_node) - { - if (processing_template_decl) - lookup_keep (decl); - return decl; - } + return decl; } } @@ -5684,14 +5680,6 @@ cp_parser_primary_expression (cp_parser *parser, } } - if (processing_template_decl) - if (tree fns = maybe_get_fns (decl)) - /* It's too difficult to mark ths in all the places where - we know for sure we need to keep the lookup, so do it - now. The cost is extra GC to recycle the lookups - resolved at parse time. */ - lookup_keep (fns); - decl = (finish_id_expression (id_expression, decl, parser->scope, idk, diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b58ec06..66e8f6f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15541,8 +15541,6 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) return t; case OVERLOAD: - /* We must have marked any lookups as persistent. */ - gcc_assert (!OVL_LOOKUP_P (t) || OVL_USED_P (t)); return t; case BASELINK: diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 20fd9c4..733c42f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2345,11 +2345,6 @@ perform_koenig_lookup (cp_expr fn, vec *args, else fn = identifier; } - else if (TREE_CODE (fn) == OVERLOAD && processing_template_decl) - /* FIXME: We shouldn't really need to mark the lookup here, as - resolving the (non-dependent) call should save the single - function we resolve to. Related to PR c++/83529. */ - lookup_keep (fn); } if (fn && template_id && fn != error_mark_node) diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 02a9856..10b2cfb 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2167,23 +2167,6 @@ ovl_make (tree fn, tree next) return result; } -static tree -ovl_copy (tree ovl) -{ - tree result = make_node (OVERLOAD); - - gcc_checking_assert (!OVL_NESTED_P (ovl) && OVL_USED_P (ovl)); - TREE_TYPE (result) = TREE_TYPE (ovl); - OVL_FUNCTION (result) = OVL_FUNCTION (ovl); - OVL_CHAIN (result) = OVL_CHAIN (ovl); - OVL_DEDUP_P (result) = OVL_DEDUP_P (ovl); - OVL_LOOKUP_P (result) = OVL_LOOKUP_P (ovl); - OVL_HIDDEN_P (result) = OVL_HIDDEN_P (ovl); - OVL_USING_P (result) = OVL_USING_P (ovl); - - return result; -} - /* Add FN to the (potentially NULL) overload set OVL. USING_P is true, if FN is via a using declaration. We also pay attention to DECL_HIDDEN. We keep the hidden decls first, but remaining ones @@ -2200,8 +2183,7 @@ ovl_insert (tree fn, tree maybe_ovl, bool using_p) && OVL_HIDDEN_P (maybe_ovl); maybe_ovl = OVL_CHAIN (maybe_ovl)) { - gcc_checking_assert (!OVL_LOOKUP_P (maybe_ovl) - && !OVL_USED_P (maybe_ovl)); + gcc_checking_assert (!OVL_LOOKUP_P (maybe_ovl)); insert_after = maybe_ovl; } @@ -2254,9 +2236,8 @@ ovl_skip_hidden (tree ovl) tree ovl_iterator::reveal_node (tree overload, tree node) { - /* We cannot have returned NODE as part of a lookup overload, so it - cannot be USED. */ - gcc_checking_assert (!OVL_USED_P (node)); + /* We cannot have returned NODE as part of a lookup overload, so we + don't have to worry about preserving that. */ OVL_HIDDEN_P (node) = false; if (tree chain = OVL_CHAIN (node)) @@ -2275,8 +2256,7 @@ ovl_iterator::reveal_node (tree overload, tree node) return overload; } -/* NODE is on the overloads of OVL. Remove it. If a predecessor is - OVL_USED_P we must copy OVL nodes, because those are immutable. +/* NODE is on the overloads of OVL. Remove it. The removed node is unaltered and may continue to be iterated from (i.e. it is safe to remove a node from an overload one is currently iterating over). */ @@ -2284,20 +2264,11 @@ ovl_iterator::reveal_node (tree overload, tree node) tree ovl_iterator::remove_node (tree overload, tree node) { - bool copying = false; /* Checking use only. */ - tree *slot = &overload; while (*slot != node) { tree probe = *slot; - gcc_checking_assert (!OVL_LOOKUP_P (probe) - && (!copying || OVL_USED_P (probe))); - if (OVL_USED_P (probe)) - { - copying = true; - probe = ovl_copy (probe); - *slot = probe; - } + gcc_checking_assert (!OVL_LOOKUP_P (probe)); slot = &OVL_CHAIN (probe); } @@ -2388,40 +2359,6 @@ lookup_maybe_add (tree fns, tree lookup, bool deduping) return lookup; } -/* Regular overload OVL is part of a kept lookup. Mark the nodes on - it as immutable. */ - -static void -ovl_used (tree ovl) -{ - for (; - ovl && TREE_CODE (ovl) == OVERLOAD - && !OVL_USED_P (ovl); - ovl = OVL_CHAIN (ovl)) - { - gcc_checking_assert (!OVL_LOOKUP_P (ovl)); - OVL_USED_P (ovl) = true; - } -} - -/* Preserve the contents of a lookup so that it is available for a - later instantiation. */ - -void -lookup_keep (tree lookup) -{ - for (; - lookup && TREE_CODE (lookup) == OVERLOAD - && OVL_LOOKUP_P (lookup) && !OVL_USED_P (lookup); - lookup = OVL_CHAIN (lookup)) - { - OVL_USED_P (lookup) = true; - ovl_used (OVL_FUNCTION (lookup)); - } - - ovl_used (lookup); -} - /* Returns nonzero if X is an expression for a (possibly overloaded) function. If "f" is a function or function template, "f", "c->f", "c.f", "C::f", and "f" will all be considered possibly -- cgit v1.1