2011-04-07 Jason Merrill <jason@redhat.com>
+ PR c++/48481
+ * cp-tree.h (OVL_ARG_DEPENDENT): New.
+ * name-lookup.c (add_function): Set it.
+ * semantics.c (finish_call_expr): Free OVERLOADs if it's set.
+
PR c++/48481
* call.c (build_user_type_conversion_1): Use lookup_fnfields_slot.
Release unused vector.
This is not to confuse with being used somewhere, which
is not important for this node. */
#define OVL_USED(NODE) TREE_USED (NODE)
+/* If set, this OVERLOAD was created for argument-dependent lookup
+ and can be freed afterward. */
+#define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
struct GTY(()) tree_overload {
struct tree_common common;
else if (fn == k->functions)
;
else
- k->functions = build_overload (fn, k->functions);
+ {
+ k->functions = build_overload (fn, k->functions);
+ if (TREE_CODE (k->functions) == OVERLOAD)
+ OVL_ARG_DEPENDENT (k->functions) = true;
+ }
return false;
}
result = convert_from_reference (result);
}
+ if (koenig_p)
+ {
+ /* Free garbage OVERLOADs from arg-dependent lookup. */
+ tree next = NULL_TREE;
+ for (fn = orig_fn;
+ fn && TREE_CODE (fn) == OVERLOAD && OVL_ARG_DEPENDENT (fn);
+ fn = next)
+ {
+ if (processing_template_decl)
+ /* In a template, we'll re-use them at instantiation time. */
+ OVL_ARG_DEPENDENT (fn) = false;
+ else
+ {
+ next = OVL_CHAIN (fn);
+ ggc_free (fn);
+ }
+ }
+ }
+
return result;
}