2018-11-16 Nathan Sidwell <nathan@acm.org>
+ 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 <OVERLOAD>): 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.
#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)
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);
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;
}
}
}
}
- 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,
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
&& 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;
}
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))
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). */
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);
}
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<int>" will all be considered possibly