re PR c++/2922 ([DR 197] two-stage lookup for unqualified function calls with type...
authorDouglas Gregor <doug.gregor@gmail.com>
Thu, 21 Jul 2005 03:53:07 +0000 (03:53 +0000)
committerDoug Gregor <dgregor@gcc.gnu.org>
Thu, 21 Jul 2005 03:53:07 +0000 (03:53 +0000)
2005-07-20  Douglas Gregor <doug.gregor@gmail.com>

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
gcc/cp/name-lookup.c
gcc/cp/semantics.c

index 0704146..2ef53f2 100644 (file)
@@ -1,3 +1,11 @@
+2005-07-20  Douglas Gregor <doug.gregor@gmail.com>
+
+       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  <giovannibajo@libero.it>
 
        Make CONSTRUCTOR use VEC to store initializers.
index 4e28128..d196606 100644 (file)
@@ -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);
index e935bb9..b2a28e2 100644 (file)
@@ -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;
 }