From 4f15a5da6f41bec5eced2956cb3f2e098ec8d77b Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 11 May 2017 17:38:55 +0000 Subject: [PATCH] name-lookup.h (pushdecl): Add default friend parm. * name-lookup.h (pushdecl): Add default friend parm. (pushdecl_maybe_friend): Delete. (pushdecl_top_level): Add default friend parm. (pushdecl_top_level_maybe_friend): Delete. * name-lookup.c (pushdecl_maybe_friend): Delete. (pushdecl): Add is_friend parm. (pushdecl_top_level): Add is friend_parm. (pushdecl_top_level_maybe_friend, pushdecl_top_level_1): Delete. (pushdecl_top_level_and_finish): Do pushing and finishing directly. * friend.c (do_friend): Adjust. * pt.c (tsubst_friend_class): Adjust. From-SVN: r247918 --- gcc/cp/ChangeLog | 12 ++++++++++ gcc/cp/friend.c | 2 +- gcc/cp/name-lookup.c | 52 ++++++++++++-------------------------------- gcc/cp/name-lookup.h | 6 ++--- gcc/cp/pt.c | 2 +- 5 files changed, 30 insertions(+), 44 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 63fac4d8713..a1770d17264 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,17 @@ 2017-05-11 Nathan Sidwell + * name-lookup.h (pushdecl): Add default friend parm. + (pushdecl_maybe_friend): Delete. + (pushdecl_top_level): Add default friend parm. + (pushdecl_top_level_maybe_friend): Delete. + * name-lookup.c (pushdecl_maybe_friend): Delete. + (pushdecl): Add is_friend parm. + (pushdecl_top_level): Add is friend_parm. + (pushdecl_top_level_maybe_friend, pushdecl_top_level_1): Delete. + (pushdecl_top_level_and_finish): Do pushing and finishing directly. + * friend.c (do_friend): Adjust. + * pt.c (tsubst_friend_class): Adjust. + Revert pushdecl_top_level_and_finish name change. * name-lookup.h (pushdecl_top_level_and_finish): Resurrect old name. * name-lookup.c (pushdecl_top_level_and_finish): Likewise. diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 3815daef4d5..8708fe596a2 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -620,7 +620,7 @@ do_friend (tree ctype, tree declarator, tree decl, declaration, the program is ill-formed. */ tree t = lookup_name_innermost_nonclass_level (DECL_NAME (decl)); if (t) - decl = pushdecl_maybe_friend (decl, /*is_friend=*/true); + decl = pushdecl (decl, /*is_friend=*/true); else { error ("friend declaration %qD in local class without " diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 183133b517a..885ced5a75a 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1862,10 +1862,11 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) return x; } -/* Wrapper for pushdecl_maybe_friend_1. */ +/* Record a decl-node X as belonging to the current lexical scope. + It's a friend if IS_FRIEND is true. */ tree -pushdecl_maybe_friend (tree x, bool is_friend) +pushdecl (tree x, bool is_friend) { tree ret; bool subtime = timevar_cond_start (TV_NAME_LOOKUP); @@ -1874,14 +1875,6 @@ pushdecl_maybe_friend (tree x, bool is_friend) return ret; } -/* Record a decl-node X as belonging to the current lexical scope. */ - -tree -pushdecl (tree x) -{ - return pushdecl_maybe_friend (x, false); -} - /* Enter DECL into the symbol table, if that's appropriate. Returns DECL, or a modified version thereof. */ @@ -2862,7 +2855,7 @@ pushdecl_with_scope_1 (tree x, cp_binding_level *level, bool is_friend) { b = current_binding_level; current_binding_level = level; - x = pushdecl_maybe_friend (x, is_friend); + x = pushdecl (x, is_friend); current_binding_level = b; } current_function_decl = function_decl; @@ -4548,47 +4541,30 @@ parse_using_directive (tree name_space, tree attribs) } } -/* Like pushdecl, only it places X in the global scope if appropriate. - Calls cp_finish_decl to register the variable, initializing it with - *INIT, if INIT is non-NULL. */ +/* Pushes X into the global namespace. */ -static tree -pushdecl_top_level_1 (tree x, tree *init, bool is_friend) +tree +pushdecl_top_level (tree x, bool is_friend) { bool subtime = timevar_cond_start (TV_NAME_LOOKUP); push_to_top_level (); x = pushdecl_namespace_level (x, is_friend); - if (init) - cp_finish_decl (x, *init, false, NULL_TREE, 0); pop_from_top_level (); timevar_cond_stop (TV_NAME_LOOKUP, subtime); return x; } -/* Like pushdecl, only it places X in the global scope if appropriate. */ - -tree -pushdecl_top_level (tree x) -{ - return pushdecl_top_level_1 (x, NULL, false); -} - -/* Like pushdecl_top_level, but adding the IS_FRIEND parameter. */ - -tree -pushdecl_top_level_maybe_friend (tree x, bool is_friend) -{ - return pushdecl_top_level_1 (x, NULL, is_friend); -} - -/* Like pushdecl, only it places X in the global scope if - appropriate. Calls cp_finish_decl to register the variable, - initializing it with INIT. */ +/* Pushes X into the global namespace and Calls cp_finish_decl to + register the variable, initializing it with INIT. */ tree pushdecl_top_level_and_finish (tree x, tree init) { - return pushdecl_top_level_1 (x, &init, false); + push_to_top_level (); + x = pushdecl_namespace_level (x, false); + cp_finish_decl (x, init, false, NULL_TREE, 0); + pop_from_top_level (); + return x; } /* Combines two sets of overloaded functions into an OVERLOAD chain, removing diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 4b46f3e7dc7..9755884026b 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -335,11 +335,9 @@ extern tree innermost_non_namespace_value (tree); extern cxx_binding *outer_binding (tree, cxx_binding *, bool); extern void cp_emit_debug_info_for_using (tree, tree); -extern tree pushdecl_maybe_friend (tree, bool is_friend); -extern tree pushdecl (tree); extern tree pushdecl_outermost_localscope (tree); -extern tree pushdecl_top_level_maybe_friend (tree, bool is_friend); -extern tree pushdecl_top_level (tree); +extern tree pushdecl (tree, bool is_friend = false); +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); extern bool push_namespace (tree); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5f7d4291457..e7e2aa669f7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9920,7 +9920,7 @@ tsubst_friend_class (tree friend_tmpl, tree args) = INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (TREE_TYPE (tmpl))); /* Inject this template into the global scope. */ - friend_type = TREE_TYPE (pushdecl_top_level_maybe_friend (tmpl, true)); + friend_type = TREE_TYPE (pushdecl_top_level (tmpl, true)); } if (context != global_namespace) -- 2.30.2