diff options
author | Jason Merrill <jason@redhat.com> | 2011-04-08 02:08:13 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-04-08 02:08:13 -0400 |
commit | 3a2cb4d037cc66a0b6567d944cbc9450adf11814 (patch) | |
tree | d9df08540a47670491171f7843e50c2e8dc8420f /gcc/cp | |
parent | c9b558895e7c82d5973c8682c766dedb95bb4d32 (diff) | |
download | gcc-3a2cb4d037cc66a0b6567d944cbc9450adf11814.zip gcc-3a2cb4d037cc66a0b6567d944cbc9450adf11814.tar.gz gcc-3a2cb4d037cc66a0b6567d944cbc9450adf11814.tar.bz2 |
re PR c++/48481 (C++ overloading memory hog)
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.
From-SVN: r172163
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 19 |
4 files changed, 32 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2cb394f..307272b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,11 @@ 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. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ea251a8..885b31c 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -317,6 +317,9 @@ typedef struct ptrmem_cst * ptrmem_cst_t; 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; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 18e3441..696a8f5 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4725,7 +4725,11 @@ add_function (struct arg_lookup *k, tree fn) 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; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 30175af..2184a53 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2160,6 +2160,25 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, 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; } |