From: Nathan Sidwell Date: Mon, 8 May 2017 17:54:55 +0000 (+0000) Subject: name-lookup.h (pushdecl_with_scope): Replace with ... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d16d5eac2a0132adcd9e88ae288bedd03abfc513;p=gcc.git name-lookup.h (pushdecl_with_scope): Replace with ... * name-lookup.h (pushdecl_with_scope): Replace with ... (pushdecl_outermost_localscope): ... this. * name-lookup.c (pushdecl_with_scope): Replace with ... (pushdecl_outermost_localscope): ... this. (pushdecl_namespace_level): Adjust. * decl.c (cp_make_fname_decl): Use pushdecl_outermost_localscope. * lambda.c (insert_capture_proxy): Likewise. From-SVN: r247752 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 05f8fa8364e..36ccab65241 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ 2017-05-08 Nathan Sidwell + * name-lookup.h (pushdecl_with_scope): Replace with ... + (pushdecl_outermost_localscope): ... this. + * name-lookup.c (pushdecl_with_scope): Replace with ... + (pushdecl_outermost_localscope): ... this. + (pushdecl_namespace_level): Adjust. + * decl.c (cp_make_fname_decl): Use pushdecl_outermost_localscope. + * lambda.c (insert_capture_proxy): Likewise. + * class.c (build_vtbl_initializer): Don't shadow outer variable with static var. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2b20bf9ef37..fbb8db7e5fc 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4335,9 +4335,6 @@ cp_make_fname_decl (location_t loc, tree id, int type_dep) if (name) free (CONST_CAST (char *, name)); - /* As we're using pushdecl_with_scope, we must set the context. */ - DECL_CONTEXT (decl) = current_function_decl; - TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; DECL_ARTIFICIAL (decl) = 1; @@ -4346,12 +4343,8 @@ cp_make_fname_decl (location_t loc, tree id, int type_dep) if (current_function_decl) { - cp_binding_level *b = current_binding_level; - if (b->kind == sk_function_parms) - return error_mark_node; - while (b->level_chain->kind != sk_function_parms) - b = b->level_chain; - pushdecl_with_scope (decl, b, /*is_friend=*/false); + DECL_CONTEXT (decl) = current_function_decl; + decl = pushdecl_outermost_localscope (decl); cp_finish_decl (decl, init, /*init_const_expr_p=*/false, NULL_TREE, LOOKUP_ONLYCONVERTING); } diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 46ab30f0a76..5061597fa3e 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -295,24 +295,13 @@ is_normal_capture_proxy (tree decl) void insert_capture_proxy (tree var) { - cp_binding_level *b; - tree stmt_list; - /* Put the capture proxy in the extra body block so that it won't clash with a later local variable. */ - b = current_binding_level; - for (;;) - { - cp_binding_level *n = b->level_chain; - if (n->kind == sk_function_parms) - break; - b = n; - } - pushdecl_with_scope (var, b, false); + pushdecl_outermost_localscope (var); /* And put a DECL_EXPR in the STATEMENT_LIST for the same block. */ var = build_stmt (DECL_SOURCE_LOCATION (var), DECL_EXPR, var); - stmt_list = (*stmt_list_stack)[1]; + tree stmt_list = (*stmt_list_stack)[1]; gcc_assert (stmt_list); append_to_statement_list_force (var, &stmt_list); } diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 3e6cd9fb74c..ed9bfcdaa26 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -2870,14 +2870,23 @@ pushdecl_with_scope_1 (tree x, cp_binding_level *level, bool is_friend) return x; } -/* Wrapper for pushdecl_with_scope_1. */ +/* Inject X into the local scope just before the function parms. */ tree -pushdecl_with_scope (tree x, cp_binding_level *level, bool is_friend) +pushdecl_outermost_localscope (tree x) { - tree ret; bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - ret = pushdecl_with_scope_1 (x, level, is_friend); + cp_binding_level *b = NULL, *n = current_binding_level; + + if (n->kind == sk_function_parms) + return error_mark_node; + do + { + b = n; + n = b->level_chain; + } + while (n->kind != sk_function_parms); + tree ret = pushdecl_with_scope_1 (x, b, false); timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; } @@ -4350,7 +4359,8 @@ pushdecl_namespace_level (tree x, bool is_friend) tree t; bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - t = pushdecl_with_scope (x, NAMESPACE_LEVEL (current_namespace), is_friend); + t = pushdecl_with_scope_1 + (x, NAMESPACE_LEVEL (current_namespace), is_friend); /* Now, the type_shadowed stack may screw us. Munge it so it does what we want. */ diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 30c51046efc..904b14ea537 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -300,6 +300,7 @@ extern tree push_inner_scope (tree); extern void pop_inner_scope (tree, tree); extern void push_binding_level (cp_binding_level *); +extern tree pushdecl_outermost_localscope (tree); extern bool push_namespace (tree); extern void pop_namespace (void); extern void push_nested_namespace (tree); @@ -307,7 +308,6 @@ extern void pop_nested_namespace (tree); extern bool handle_namespace_attrs (tree, tree); extern void pushlevel_class (void); extern void poplevel_class (void); -extern tree pushdecl_with_scope (tree, cp_binding_level *, bool); extern tree lookup_name_prefer_type (tree, int); extern tree lookup_name_real (tree, int, int, bool, int, int); extern tree lookup_type_scope (tree, tag_scope);