call.c (build_operator_new_call): Do namelookup and ADL here.

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.

From-SVN: r248518
This commit is contained in:
Nathan Sidwell 2017-05-26 16:34:40 +00:00 committed by Nathan Sidwell
parent 32196b873a
commit e1cad93084
6 changed files with 33 additions and 36 deletions

View File

@ -1,5 +1,18 @@
2017-05-26 Nathan Sidwell <nathan@acm.org>
* 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.
* cp-tree.h (OVL_CHAIN): Check looking at OVERLOAD.
(ovl_iterator): Add allow_inner field. Adjust ctor. Make
unduplicatable.

View File

@ -4318,7 +4318,8 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args,
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 tree_code code, int flags, tree arg1,
/* 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;

View File

@ -37,16 +37,6 @@ static cxx_binding *cxx_binding_make (tree value, tree type);
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 scope, bool friendp)
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 scope, bool friendp)
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 attributes)
return saw_vis;
}
/* Temporarily set the namespace for the current declaration. */
void
@ -4544,10 +4535,7 @@ finish_local_using_decl (tree decl, tree scope, tree name)
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;
@ -5307,15 +5295,6 @@ lookup_name_nonclass (tree name)
return lookup_name_real (name, 0, 1, /*block_p=*/true, 0, 0);
}
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)
{
@ -6277,8 +6256,7 @@ cp_emit_debug_info_for_using (tree t, tree context)
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)

View File

@ -311,7 +311,6 @@ extern void set_global_binding (tree id, tree val);
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);

View File

@ -1,3 +1,8 @@
2017-05-26 Nathan Sidwell <nathan@acm.org>
* libcp1plugin.cc (plugin_add_using_namespace): Call
finish_namespace_using_directive.
2017-05-25 Nathan Sidwell <nathan@acm.org>
* libcp1plugin.cc (plugin_make_namespace_inline): Check and set

View File

@ -946,7 +946,7 @@ plugin_add_using_namespace (cc1_plugin::connection *,
gcc_assert (TREE_CODE (used_ns) == NAMESPACE_DECL);
do_using_directive (used_ns);
finish_namespace_using_directive (used_ns, NULL_TREE);
return 1;
}