* 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
2017-05-08 Nathan Sidwell <nathan@acm.org>
+ * 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.
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;
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);
}
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);
}
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;
}
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. */
extern void pop_inner_scope (tree, tree);
extern void push_binding_level (cp_binding_level *);
\f
+extern tree pushdecl_outermost_localscope (tree);
extern bool push_namespace (tree);
extern void pop_namespace (void);
extern void push_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);