From e1cad93084f9cd5bcdb3f3b0b6214605c8043871 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 26 May 2017 16:34:40 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 13 +++++++++++++ gcc/cp/call.c | 15 +++++++++------ gcc/cp/name-lookup.c | 32 +++++--------------------------- gcc/cp/name-lookup.h | 2 -- libcc1/ChangeLog | 5 +++++ libcc1/libcp1plugin.cc | 2 +- 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b1a72ee5fb7..88ab214c84c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,18 @@ 2017-05-26 Nathan Sidwell + * 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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 6b13d6e4cd8..c1fcd194b76 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4318,7 +4318,8 @@ build_operator_new_call (tree fnname, vec **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; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index b85061fd843..c167cd220b9 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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 *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) diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index ff77517744f..d41ffd702b2 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -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 *, 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 *); extern tree innermost_non_namespace_value (tree); extern cxx_binding *outer_binding (tree, cxx_binding *, bool); diff --git a/libcc1/ChangeLog b/libcc1/ChangeLog index f22ea27c9c3..76b63883938 100644 --- a/libcc1/ChangeLog +++ b/libcc1/ChangeLog @@ -1,3 +1,8 @@ +2017-05-26 Nathan Sidwell + + * libcp1plugin.cc (plugin_add_using_namespace): Call + finish_namespace_using_directive. + 2017-05-25 Nathan Sidwell * libcp1plugin.cc (plugin_make_namespace_inline): Check and set diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc index 43781adce54..877c2642c36 100644 --- a/libcc1/libcp1plugin.cc +++ b/libcc1/libcp1plugin.cc @@ -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; } -- 2.30.2