From 5256a7f5961e6a5137be1d340cb380b62b06e19f Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 30 May 2017 17:48:57 +0000 Subject: [PATCH] cp-tree.def (OVERLOAD): Fix comment. * cp-tree.def (OVERLOAD): Fix comment. * cp-tree.h: Fix comments and whitespace. * error.c (dump_decl): Use pp_cxx_colon_colon, ovl_scope. * name-lookup.c (add_decl_to_level): Assert not class. (check_local_shadow): Use OVL_P. (pushdecl_with_scope_1): Rename to ... (do_pushdecl_with_Scope): ... here. (do_nonmember_using_decl): Use qualified_namespace_lookup return value. (push_class_level_binding_1): Use OVL_P. (pushdecl_namespace_level): Use do_pushdecl_with_scope. (pushtag_1): Rename to ... (do_pushtag): ... here. Adjust do_pushdecl_with_scope call. (pushtag): Adjust. (store_class_bindings): Do not time here. * name-lookup.h (pushdecl_outermost_localscope): Reorder. * pt.c (listify): Declare argvec at point of initialization. From-SVN: r248693 --- gcc/cp/ChangeLog | 18 ++++++++++++++++++ gcc/cp/cp-tree.def | 3 +-- gcc/cp/cp-tree.h | 8 +++++--- gcc/cp/error.c | 7 +++---- gcc/cp/name-lookup.c | 41 ++++++++++++++++------------------------- gcc/cp/name-lookup.h | 3 +-- gcc/cp/pt.c | 5 +++-- 7 files changed, 47 insertions(+), 38 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1aa5df8..1e4685f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,23 @@ 2017-05-30 Nathan Sidwell + * cp-tree.def (OVERLOAD): Fix comment. + * cp-tree.h: Fix comments and whitespace. + * error.c (dump_decl): Use pp_cxx_colon_colon, ovl_scope. + * name-lookup.c (add_decl_to_level): Assert not class. + (check_local_shadow): Use OVL_P. + (pushdecl_with_scope_1): Rename to ... + (do_pushdecl_with_Scope): ... here. + (do_nonmember_using_decl): Use qualified_namespace_lookup return + value. + (push_class_level_binding_1): Use OVL_P. + (pushdecl_namespace_level): Use do_pushdecl_with_scope. + (pushtag_1): Rename to ... + (do_pushtag): ... here. Adjust do_pushdecl_with_scope call. + (pushtag): Adjust. + (store_class_bindings): Do not time here. + * name-lookup.h (pushdecl_outermost_localscope): Reorder. + * pt.c (listify): Declare argvec at point of initialization. + PR c++/80913 * name-lookup.c (add_decl_to_level): Assert not making a circular chain. diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index c51c5c1..356d030 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -228,8 +228,7 @@ DEFTREECODE (DEFERRED_NOEXCEPT, "deferred_noexcept", tcc_exceptional, 0) member template, the template may be an IDENTIFIER_NODE. */ DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", tcc_expression, 2) -/* A list-like node for chaining overloading candidates. TREE_TYPE is - the original name, and the parameter is the FUNCTION_DECL. */ +/* One of a set of overloaded functions. */ DEFTREECODE (OVERLOAD, "overload", tcc_exceptional, 0) /* A pseudo-destructor, of the form "OBJECT.~DESTRUCTOR" or diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 0bfa6c6..a01e76a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -692,7 +692,8 @@ struct GTY(()) tree_overload { tree function; }; -/* Iterator for a 1 dimensional overload. */ +/* Iterator for a 1 dimensional overload. Permits iterating over the + outer level of a 2-d overload when explicitly enabled. */ class ovl_iterator { @@ -970,7 +971,7 @@ enum GTY(()) abstract_class_use { (LANG_IDENTIFIER_CAST (NODE)->class_template_info) /* The IDENTIFIER_BINDING is the innermost cxx_binding for the - identifier. It's PREVIOUS is the next outermost binding. Each + identifier. Its PREVIOUS is the next outermost binding. Each VALUE field is a DECL for the associated declaration. Thus, name lookup consists simply of pulling off the node at the front of the list (modulo oddities for looking up the names of types, @@ -1454,6 +1455,7 @@ union GTY((desc ("cp_tree_node_structure (&%h)"), userdef_literal; }; + /* Global state. */ struct GTY(()) saved_scope { @@ -2496,9 +2498,9 @@ struct GTY(()) lang_decl_fn { unsigned static_function : 1; unsigned pure_virtual : 1; unsigned defaulted_p : 1; - unsigned has_in_charge_parm_p : 1; unsigned has_vtt_parm_p : 1; + unsigned pending_inline_p : 1; unsigned nonconverting : 1; unsigned thunk_p : 1; diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 624a0e9..8481e2d 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1146,7 +1146,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) case SCOPE_REF: dump_type (pp, TREE_OPERAND (t, 0), flags); - pp_colon_colon (pp); + pp_cxx_colon_colon (pp); dump_decl (pp, TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME); break; @@ -1193,8 +1193,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) case OVERLOAD: if (!OVL_SINGLE_P (t)) { - t = OVL_FIRST (t); - tree ctx = CP_DECL_CONTEXT (t); + tree ctx = ovl_scope (t); if (ctx != global_namespace) { if (TYPE_P (ctx)) @@ -1203,7 +1202,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) dump_decl (pp, ctx, flags); pp_cxx_colon_colon (pp); } - dump_decl (pp, DECL_NAME (t), flags); + dump_decl (pp, OVL_NAME (t), flags); break; } diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 3a11d50..7f58682 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -120,13 +120,12 @@ find_namespace_value (tree ns, tree name) static void add_decl_to_level (cp_binding_level *b, tree decl) { - /* We used to record virtual tables as if they were ordinary - variables, but no longer do so. */ - gcc_assert (!(VAR_P (decl) && DECL_VIRTUAL_P (decl))); + gcc_assert (b->kind != sk_class); - if (TREE_CODE (decl) == NAMESPACE_DECL - && !DECL_NAMESPACE_ALIAS (decl)) + if (TREE_CODE (decl) == NAMESPACE_DECL && !DECL_NAMESPACE_ALIAS (decl)) { + /* Inner namespaces get their own chain, to make walking + simpler. */ DECL_CHAIN (decl) = b->namespaces; b->namespaces = decl; } @@ -2132,8 +2131,7 @@ check_local_shadow (tree decl) /* Warn if a variable shadows a non-function, or the variable is a function or a pointer-to-function. */ - if ((TREE_CODE (member) != FUNCTION_DECL - && TREE_CODE (member) != OVERLOAD) + if (!OVL_P (member) || TREE_CODE (decl) == FUNCTION_DECL || TYPE_PTRFN_P (TREE_TYPE (decl)) || TYPE_PTRMEMFUNC_P (TREE_TYPE (decl))) @@ -3328,7 +3326,7 @@ push_using_decl (tree scope, tree name) closer binding level than LEVEL. */ static tree -pushdecl_with_scope_1 (tree x, cp_binding_level *level, bool is_friend) +do_pushdecl_with_scope (tree x, cp_binding_level *level, bool is_friend) { cp_binding_level *b; tree function_decl = current_function_decl; @@ -3365,7 +3363,7 @@ pushdecl_outermost_localscope (tree x) n->kind != sk_function_parms; n = b->level_chain) b = n; - tree ret = b ? pushdecl_with_scope_1 (x, b, false) : error_mark_node; + tree ret = b ? do_pushdecl_with_scope (x, b, false) : error_mark_node; timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; @@ -3436,10 +3434,6 @@ do_nonmember_using_decl (tree scope, tree name, tree *value_p, tree *type_p) name_lookup lookup (name, 0); if (!qualified_namespace_lookup (scope, &lookup)) - /* Lookup error */ - return; - - if (!lookup.value) { error ("%qD not declared", name); return; @@ -4062,7 +4056,7 @@ push_class_level_binding_1 (tree name, tree x) } } else if (TREE_CODE (target_decl) == OVERLOAD - && is_overloaded_fn (target_bval)) + && OVL_P (target_bval)) old_decl = bval; else if (TREE_CODE (decl) == USING_DECL && TREE_CODE (bval) == USING_DECL @@ -4077,10 +4071,10 @@ push_class_level_binding_1 (tree name, tree x) && DECL_DEPENDENT_P (bval)) return true; else if (TREE_CODE (decl) == USING_DECL - && is_overloaded_fn (target_bval)) + && OVL_P (target_bval)) old_decl = bval; else if (TREE_CODE (bval) == USING_DECL - && is_overloaded_fn (target_decl)) + && OVL_P (target_decl)) return true; if (old_decl && binding->scope == class_binding_level) @@ -4544,7 +4538,7 @@ pushdecl_namespace_level (tree x, bool is_friend) tree t; bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - t = pushdecl_with_scope_1 + t = do_pushdecl_with_scope (x, NAMESPACE_LEVEL (current_namespace), is_friend); /* Now, the type_shadowed stack may screw us. Munge it so it does @@ -5627,12 +5621,11 @@ maybe_process_template_type_declaration (tree type, int is_friend, Returns TYPE upon success and ERROR_MARK_NODE otherwise. */ static tree -pushtag_1 (tree name, tree type, tag_scope scope) +do_pushtag (tree name, tree type, tag_scope scope) { - cp_binding_level *b; tree decl; - b = current_binding_level; + cp_binding_level *b = current_binding_level; while (/* Cleanup scopes are not scopes from the point of view of the language. */ b->kind == sk_cleanup @@ -5721,7 +5714,7 @@ pushtag_1 (tree name, tree type, tag_scope scope) } else if (b->kind != sk_template_parms) { - decl = pushdecl_with_scope_1 (decl, b, /*is_friend=*/false); + decl = do_pushdecl_with_scope (decl, b, /*is_friend=*/false); if (decl == error_mark_node) return decl; @@ -5783,14 +5776,14 @@ pushtag_1 (tree name, tree type, tag_scope scope) return type; } -/* Wrapper for pushtag_1. */ +/* Wrapper for do_pushtag. */ tree pushtag (tree name, tree type, tag_scope scope) { tree ret; bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - ret = pushtag_1 (name, type, scope); + ret = do_pushtag (name, type, scope); timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; } @@ -5879,7 +5872,6 @@ store_class_bindings (vec *names, size_t i; cp_class_binding *cb; - bool subtime = timevar_cond_start (TV_NAME_LOOKUP); for (i = 0; vec_safe_iterate (names, i, &cb); ++i) if (store_binding_p (cb->identifier)) bindings_need_stored.safe_push (cb->identifier); @@ -5891,7 +5883,6 @@ store_class_bindings (vec *names, store_binding (id, old_bindings); bindings_need_stored.truncate (0); } - timevar_cond_stop (TV_NAME_LOOKUP, subtime); } /* A chain of saved_scope structures awaiting reuse. */ diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 96e7128..7a61b96 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -194,7 +194,6 @@ struct GTY(()) cp_binding_level { /* A list of USING_DECL nodes. */ tree usings; - /* Using directives. */ vec *using_directives; @@ -331,8 +330,8 @@ extern void finish_namespace_using_decl (tree, tree, tree); extern void finish_local_using_decl (tree, tree, tree); extern void finish_namespace_using_directive (tree, tree); extern void finish_local_using_directive (tree, tree); -extern tree pushdecl_outermost_localscope (tree); extern tree pushdecl (tree, bool is_friend = false); +extern tree pushdecl_outermost_localscope (tree); extern tree pushdecl_top_level (tree, bool is_friend = false); extern tree pushdecl_top_level_and_finish (tree, tree); extern tree pushtag (tree, tree, tag_scope); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3602166..8f69939 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -24788,15 +24788,16 @@ static tree listify (tree arg) { tree std_init_list = get_namespace_binding (std_node, init_list_identifier); - tree argvec; + if (!std_init_list || !DECL_CLASS_TEMPLATE_P (std_init_list)) { error ("deducing from brace-enclosed initializer list requires " "#include "); return error_mark_node; } - argvec = make_tree_vec (1); + tree argvec = make_tree_vec (1); TREE_VEC_ELT (argvec, 0) = arg; + return lookup_template_class (std_init_list, argvec, NULL_TREE, NULL_TREE, 0, tf_warning_or_error); } -- 2.7.4