diff options
| author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-04-08 06:08:13 +0000 |
|---|---|---|
| committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-04-08 06:08:13 +0000 |
| commit | b75fa3a6b883f8aac98675d59cc94729321aaebc (patch) | |
| tree | d9df08540a47670491171f7843e50c2e8dc8420f | |
| parent | f9c9f8e431cacdd26c670e6fcb86b2b129453c0c (diff) | |
| download | ppe42-gcc-b75fa3a6b883f8aac98675d59cc94729321aaebc.tar.gz ppe42-gcc-b75fa3a6b883f8aac98675d59cc94729321aaebc.zip | |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@172163 138bc75d-0d04-0410-961f-82ee72b054a4
| -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 2cb394f00e6..307272bef42 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 ea251a8dbbd..885b31cd61a 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 18e34417b26..696a8f5fdcb 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 30175afaaa5..2184a53558e 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; } |

