From 20ac1e0392c91bf7c5ba645b58622a7641675a8d Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 21 Jul 2005 03:53:07 +0000 Subject: [PATCH] re PR c++/2922 ([DR 197] two-stage lookup for unqualified function calls with type-dependent arguments) 2005-07-20 Douglas Gregor PR c++/2922 * semantics.c (perform_koenig_lookup): For dependent calls, just return the set of functions we've found so far. Later, it will be augmented by those found through argument-dependent lookup. * name-lookup.c (lookup_arg_dependent): From-SVN: r102216 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/name-lookup.c | 28 ++++++---------------------- gcc/cp/semantics.c | 2 -- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0704146cfff..2ef53f2946a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2005-07-20 Douglas Gregor + + PR c++/2922 + * semantics.c (perform_koenig_lookup): For dependent calls, just + return the set of functions we've found so far. Later, it will be + augmented by those found through argument-dependent lookup. + * name-lookup.c (lookup_arg_dependent): + 2005-07-20 Giovanni Bajo Make CONSTRUCTOR use VEC to store initializers. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 4e2812811c8..d196606da04 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4497,34 +4497,18 @@ tree lookup_arg_dependent (tree name, tree fns, tree args) { struct arg_lookup k; - tree fn = NULL_TREE; timevar_push (TV_NAME_LOOKUP); k.name = name; k.functions = fns; k.classes = NULL_TREE; - /* We've already looked at some namespaces during normal unqualified - lookup -- but we don't know exactly which ones. If the functions - we found were brought into the current namespace via a using - declaration, we have not really checked the namespace from which - they came. Therefore, we check all namespaces here -- unless the - function we have is from the current namespace. Even then, we - must check all namespaces if the function is a local - declaration; any other declarations present at namespace scope - should be visible during argument-dependent lookup. */ - if (fns) - fn = OVL_CURRENT (fns); - if (fn && TREE_CODE (fn) == FUNCTION_DECL - && (CP_DECL_CONTEXT (fn) != current_decl_namespace () - || DECL_LOCAL_FUNCTION_P (fn))) - k.namespaces = NULL_TREE; - else - /* Setting NAMESPACES is purely an optimization; it prevents - adding functions which are already in FNS. Adding them would - be safe -- "joust" will eliminate the duplicates -- but - wasteful. */ - k.namespaces = build_tree_list (current_decl_namespace (), NULL_TREE); + /* We previously performed an optimization here by setting + NAMESPACES to the current namespace when it was safe. However, DR + 164 says that namespaces that were already searched in the first + stage of template processing are searched again (potentially + picking up later definitions) in the second stage. */ + k.namespaces = NULL_TREE; arg_assoc_args (&k, args); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, k.functions); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index e935bb985b1..b2a28e2b846 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1738,8 +1738,6 @@ perform_koenig_lookup (tree fn, tree args) /* The unqualified name could not be resolved. */ fn = unqualified_fn_lookup_error (identifier); } - else - fn = identifier; return fn; }