We have a funky combined lookup & ADL, called exactly twice to find
operator new. Let's break that apart to separate lookups for clarity.
struct scope_binding is now dead, having been consumed by name_lookup.
A stale declaration of do_using_directive was still there and confused
libcp1plugin into thinking it could be called.
A couple of places used is_overloaded_fn when plain OVL_P could be used.
cp_emit_debug_info_for_using didn;t know about the new
MAYBE_BASELINK_FUNCTIONS
nathan
--
Nathan Sidwell
2017-05-26 Nathan Sidwell <nat...@acm.org>
gcc/cp/
* call.c (build_operator_new_call): Do namelookup and ADL here.
(build_new_op_1): Likewise.
* name-lookup.h (lookup_function_nonclass): Delete declaration.
(do_using_directive): Likewise.
* name-lookup.c (set_namespace_binding, push_local_binding): Don't
declare early.
(struct scope_binding): Delete.
(EMPTY_SCOPE_BINDING): Delete.
(set_decl_namespace): Use OVL_P.
(finish_local_using_decl): Lose unnecesary checks.
(lookup_function_nonclass): Delete.
(cp_emit_debug_info_for_using): Use MAYBE_BASELINK_P.
libcc1/
* libcp1plugin.cc (plugin_add_using_namespace): Call
finish_namespace_using_directive.
Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c (revision 248517)
+++ gcc/cp/call.c (working copy)
@@ -4318,7 +4318,8 @@ build_operator_new_call (tree fnname, ve
up in the global scope.
we disregard block-scope declarations of "operator new". */
- fns = lookup_function_nonclass (fnname, *args, /*block_p=*/false);
+ fns = lookup_name_real (fnname, 0, 1, /*block_p=*/false, 0, 0);
+ fns = lookup_arg_dependent (fnname, fns, *args);
if (align_arg)
{
@@ -5628,11 +5629,13 @@ build_new_op_1 (location_t loc, enum tre
/* Add namespace-scope operators to the list of functions to
consider. */
if (!memonly)
- add_candidates (lookup_function_nonclass (fnname, arglist,
- /*block_p=*/true),
- NULL_TREE, arglist, NULL_TREE,
- NULL_TREE, false, NULL_TREE, NULL_TREE,
- flags, &candidates, complain);
+ {
+ tree fns = lookup_name_real (fnname, 0, 1, /*block_p=*/true, 0, 0);
+ fns = lookup_arg_dependent (fnname, fns, arglist);
+ add_candidates (fns, NULL_TREE, arglist, NULL_TREE,
+ NULL_TREE, false, NULL_TREE, NULL_TREE,
+ flags, &candidates, complain);
+ }
args[0] = arg1;
args[1] = arg2;
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c (revision 248517)
+++ gcc/cp/name-lookup.c (working copy)
@@ -37,16 +37,6 @@ static cxx_binding *cxx_binding_make (tr
static cp_binding_level *innermost_nonclass_level (void);
static void set_identifier_type_value_with_scope (tree id, tree decl,
cp_binding_level *b);
-static void set_namespace_binding (tree scope, tree name, tree val);
-static void push_local_binding (tree, tree, bool);
-
-/* The bindings for a particular name in a particular scope. */
-
-struct scope_binding {
- tree value;
- tree type;
-};
-#define EMPTY_SCOPE_BINDING { NULL_TREE, NULL_TREE }
/* Create a local binding level for NAME. */
@@ -4243,7 +4233,7 @@ set_decl_namespace (tree decl, tree scop
print_candidates (old);
return;
}
- if (!is_overloaded_fn (decl))
+ if (!OVL_P (decl))
{
/* We might have found OLD in an inline namespace inside SCOPE. */
if (TREE_CODE (decl) == TREE_CODE (old))
@@ -4254,7 +4244,7 @@ set_decl_namespace (tree decl, tree scop
return;
}
/* Since decl is a function, old should contain a function decl. */
- if (!is_overloaded_fn (old))
+ if (!OVL_P (old))
goto complain;
/* We handle these in check_explicit_instantiation_namespace. */
if (processing_explicit_instantiation)
@@ -4411,6 +4401,7 @@ handle_namespace_attrs (tree ns, tree at
return saw_vis;
}
+
/* Temporarily set the namespace for the current declaration. */
void
@@ -4544,10 +4535,7 @@ finish_local_using_decl (tree decl, tree
if (decl == NULL_TREE)
return;
- gcc_assert (building_stmt_list_p ());
- if (building_stmt_list_p ()
- && at_function_scope_p ())
- add_decl_expr (decl);
+ add_decl_expr (decl);
cxx_binding *binding = find_local_binding (current_binding_level, name);
tree value = binding ? binding->value : NULL_TREE;
@@ -5308,15 +5296,6 @@ lookup_name_nonclass (tree name)
}
tree
-lookup_function_nonclass (tree name, vec<tree, va_gc> *args, bool block_p)
-{
- return
- lookup_arg_dependent (name,
- lookup_name_real (name, 0, 1, block_p, 0, 0),
- args);
-}
-
-tree
lookup_name (tree name)
{
return lookup_name_real (name, 0, 0, /*block_p=*/true, 0, 0);
@@ -6277,8 +6256,7 @@ cp_emit_debug_info_for_using (tree t, tr
if (context == global_namespace)
context = NULL_TREE;
- if (BASELINK_P (t))
- t = BASELINK_FUNCTIONS (t);
+ t = MAYBE_BASELINK_FUNCTIONS (t);
/* FIXME: Handle TEMPLATE_DECLs. */
for (lkp_iterator iter (t); iter; ++iter)
Index: gcc/cp/name-lookup.h
===================================================================
--- gcc/cp/name-lookup.h (revision 248517)
+++ gcc/cp/name-lookup.h (working copy)
@@ -311,7 +311,6 @@ extern void set_global_binding (tree id,
extern tree lookup_qualified_name (tree, tree, int, bool, /*hidden*/bool = false);
extern tree lookup_name_nonclass (tree);
extern bool is_local_extern (tree);
-extern tree lookup_function_nonclass (tree, vec<tree, va_gc> *, bool);
extern bool pushdecl_class_level (tree);
extern tree pushdecl_namespace_level (tree, bool);
extern bool push_class_level_binding (tree, tree);
@@ -323,7 +322,6 @@ extern void push_decl_namespace (tree);
extern void pop_decl_namespace (void);
extern void do_namespace_alias (tree, tree);
extern tree do_class_using_decl (tree, tree);
-extern void do_using_directive (tree);
extern tree lookup_arg_dependent (tree, tree, vec<tree, va_gc> *);
extern tree innermost_non_namespace_value (tree);
extern cxx_binding *outer_binding (tree, cxx_binding *, bool);
Index: libcc1/libcp1plugin.cc
===================================================================
--- libcc1/libcp1plugin.cc (revision 248517)
+++ libcc1/libcp1plugin.cc (working copy)
@@ -946,7 +946,7 @@ plugin_add_using_namespace (cc1_plugin::
gcc_assert (TREE_CODE (used_ns) == NAMESPACE_DECL);
- do_using_directive (used_ns);
+ finish_namespace_using_directive (used_ns, NULL_TREE);
return 1;
}