name-lookup.h (pop_binding): Rename to pop_local_binding.
* name-lookup.h (pop_binding): Rename to pop_local_binding. (getdecls): Rename to get_local_decls. * name-lookup.c (pop_binding): Rename to ... (pop_local_binding): ... here. (pop_bindings_and_leave_scope): Adjust. (getdecls): Rename to ... (get_local_decls): ... here. Assert local scope. * decl.c (poplevel): Assert not namespace. Adjust and simplify logic. (store_parm_decls): Adjust get_local_decls call. (parser.c (synthesize_implicit_template_parm): Likewise. From-SVN: r247901
This commit is contained in:
parent
67ac9a9db1
commit
9c82d7b68e
@ -1,3 +1,17 @@
|
||||
2017-05-11 Nathan Sidwell <nathan@acm.org>
|
||||
|
||||
* name-lookup.h (pop_binding): Rename to pop_local_binding.
|
||||
(getdecls): Rename to get_local_decls.
|
||||
* name-lookup.c (pop_binding): Rename to ...
|
||||
(pop_local_binding): ... here.
|
||||
(pop_bindings_and_leave_scope): Adjust.
|
||||
(getdecls): Rename to ...
|
||||
(get_local_decls): ... here. Assert local scope.
|
||||
* decl.c (poplevel): Assert not namespace. Adjust and simplify
|
||||
logic.
|
||||
(store_parm_decls): Adjust get_local_decls call.
|
||||
(parser.c (synthesize_implicit_template_parm): Likewise.
|
||||
|
||||
2017-05-11 Ville Voutilainen <ville.voutilainen@gmail.com>
|
||||
|
||||
PR c++/80682
|
||||
|
@ -582,7 +582,8 @@ poplevel (int keep, int reverse, int functionbody)
|
||||
|
||||
block = NULL_TREE;
|
||||
|
||||
gcc_assert (current_binding_level->kind != sk_class);
|
||||
gcc_assert (current_binding_level->kind != sk_class
|
||||
&& current_binding_level->kind != sk_namespace);
|
||||
|
||||
if (current_binding_level->kind == sk_cleanup)
|
||||
functionbody = 0;
|
||||
@ -644,12 +645,13 @@ poplevel (int keep, int reverse, int functionbody)
|
||||
if ((warn_unused_variable || warn_unused_but_set_variable)
|
||||
&& current_binding_level->kind != sk_template_parms
|
||||
&& !processing_template_decl)
|
||||
for (tree d = getdecls (); d; d = TREE_CHAIN (d))
|
||||
for (tree d = get_local_decls (); d; d = TREE_CHAIN (d))
|
||||
{
|
||||
/* There are cases where D itself is a TREE_LIST. See in
|
||||
push_local_binding where the list of decls returned by
|
||||
getdecls is built. */
|
||||
decl = TREE_CODE (d) == TREE_LIST ? TREE_VALUE (d) : d;
|
||||
|
||||
tree type = TREE_TYPE (decl);
|
||||
if (VAR_P (decl)
|
||||
&& (! TREE_USED (decl) || !DECL_READ_P (decl))
|
||||
@ -680,14 +682,15 @@ poplevel (int keep, int reverse, int functionbody)
|
||||
/* Remove declarations for all the DECLs in this level. */
|
||||
for (link = decls; link; link = TREE_CHAIN (link))
|
||||
{
|
||||
if (leaving_for_scope && VAR_P (link)
|
||||
decl = TREE_CODE (link) == TREE_LIST ? TREE_VALUE (link) : link;
|
||||
tree name = DECL_NAME (OVL_CURRENT (decl));
|
||||
|
||||
if (leaving_for_scope && VAR_P (decl)
|
||||
/* It's hard to make this ARM compatibility hack play nicely with
|
||||
lambdas, and it really isn't necessary in C++11 mode. */
|
||||
&& cxx_dialect < cxx11
|
||||
&& DECL_NAME (link))
|
||||
&& name)
|
||||
{
|
||||
tree name = DECL_NAME (link);
|
||||
|
||||
cxx_binding *ob = outer_binding (name,
|
||||
IDENTIFIER_BINDING (name),
|
||||
/*class_p=*/true);
|
||||
@ -703,7 +706,7 @@ poplevel (int keep, int reverse, int functionbody)
|
||||
|
||||
and we are leaving the `for' scope. There's no reason to
|
||||
keep the binding of the inner `i' in this case. */
|
||||
pop_binding (name, link);
|
||||
;
|
||||
else if ((ob && (TREE_CODE (ob->value) == TYPE_DECL))
|
||||
|| (ns_binding && TREE_CODE (ns_binding) == TYPE_DECL))
|
||||
/* Here, we have something like:
|
||||
@ -716,7 +719,7 @@ poplevel (int keep, int reverse, int functionbody)
|
||||
|
||||
We must pop the for-scope binding so we know what's a
|
||||
type and what isn't. */
|
||||
pop_binding (name, link);
|
||||
;
|
||||
else
|
||||
{
|
||||
/* Mark this VAR_DECL as dead so that we can tell we left it
|
||||
@ -742,32 +745,20 @@ poplevel (int keep, int reverse, int functionbody)
|
||||
its SCOPE since the scope is going away now. */
|
||||
IDENTIFIER_BINDING (name)->scope
|
||||
= current_binding_level->level_chain;
|
||||
|
||||
/* Don't remove the binding. */
|
||||
name = NULL_TREE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tree name;
|
||||
|
||||
/* Remove the binding. */
|
||||
decl = link;
|
||||
|
||||
if (TREE_CODE (decl) == TREE_LIST)
|
||||
decl = TREE_VALUE (decl);
|
||||
name = decl;
|
||||
|
||||
if (TREE_CODE (name) == OVERLOAD)
|
||||
name = OVL_FUNCTION (name);
|
||||
|
||||
gcc_assert (DECL_P (name));
|
||||
pop_binding (DECL_NAME (name), decl);
|
||||
}
|
||||
/* Remove the binding. */
|
||||
pop_local_binding (name, decl);
|
||||
}
|
||||
|
||||
/* Remove declarations for any `for' variables from inner scopes
|
||||
that we kept around. */
|
||||
FOR_EACH_VEC_SAFE_ELT_REVERSE (current_binding_level->dead_vars_from_for,
|
||||
ix, decl)
|
||||
pop_binding (DECL_NAME (decl), decl);
|
||||
pop_local_binding (DECL_NAME (decl), decl);
|
||||
|
||||
/* Restore the IDENTIFIER_TYPE_VALUEs. */
|
||||
for (link = current_binding_level->type_shadowed;
|
||||
@ -15231,7 +15222,7 @@ store_parm_decls (tree current_function_parms)
|
||||
/* Get the decls in their original chain order and record in the
|
||||
function. This is all and only the PARM_DECLs that were
|
||||
pushed into scope by the loop above. */
|
||||
DECL_ARGUMENTS (fndecl) = getdecls ();
|
||||
DECL_ARGUMENTS (fndecl) = get_local_decls ();
|
||||
}
|
||||
else
|
||||
DECL_ARGUMENTS (fndecl) = NULL_TREE;
|
||||
|
@ -936,7 +936,7 @@ push_binding (tree id, tree decl, cp_binding_level* level)
|
||||
for ID. */
|
||||
|
||||
void
|
||||
pop_binding (tree id, tree decl)
|
||||
pop_local_binding (tree id, tree decl)
|
||||
{
|
||||
cxx_binding *binding;
|
||||
|
||||
@ -979,8 +979,8 @@ pop_binding (tree id, tree decl)
|
||||
void
|
||||
pop_bindings_and_leave_scope (void)
|
||||
{
|
||||
for (tree t = getdecls (); t; t = DECL_CHAIN (t))
|
||||
pop_binding (DECL_NAME (t), t);
|
||||
for (tree t = get_local_decls (); t; t = DECL_CHAIN (t))
|
||||
pop_local_binding (DECL_NAME (t), t);
|
||||
leave_scope ();
|
||||
}
|
||||
|
||||
@ -2367,14 +2367,13 @@ keep_next_level (bool keep)
|
||||
keep_next_level_flag = keep;
|
||||
}
|
||||
|
||||
/* Return the list of declarations of the current level.
|
||||
Note that this list is in reverse order unless/until
|
||||
you nreverse it; and when you do nreverse it, you must
|
||||
store the result back using `storedecls' or you will lose. */
|
||||
/* Return the list of declarations of the current local scope. */
|
||||
|
||||
tree
|
||||
getdecls (void)
|
||||
get_local_decls (void)
|
||||
{
|
||||
gcc_assert (current_binding_level->kind != sk_namespace
|
||||
&& current_binding_level->kind != sk_class);
|
||||
return current_binding_level->names;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ struct GTY(()) cxx_saved_binding {
|
||||
extern tree identifier_type_value (tree);
|
||||
extern void set_identifier_type_value (tree, tree);
|
||||
extern void push_binding (tree, tree, cp_binding_level*);
|
||||
extern void pop_binding (tree, tree);
|
||||
extern void pop_local_binding (tree, tree);
|
||||
extern void pop_bindings_and_leave_scope (void);
|
||||
extern tree constructor_name (tree);
|
||||
extern bool constructor_name_p (tree, tree);
|
||||
@ -324,7 +324,7 @@ extern void push_local_binding (tree, tree, int);
|
||||
extern bool pushdecl_class_level (tree);
|
||||
extern tree pushdecl_namespace_level (tree, bool);
|
||||
extern bool push_class_level_binding (tree, tree);
|
||||
extern tree getdecls (void);
|
||||
extern tree get_local_decls ();
|
||||
extern int function_parm_depth (void);
|
||||
extern tree cp_namespace_decls (tree);
|
||||
extern void set_decl_namespace (tree, tree, bool);
|
||||
|
@ -38970,7 +38970,7 @@ synthesize_implicit_template_parm (cp_parser *parser, tree constr)
|
||||
else
|
||||
parser->implicit_template_parms = new_parm;
|
||||
|
||||
tree new_decl = getdecls ();
|
||||
tree new_decl = get_local_decls ();
|
||||
if (non_type)
|
||||
/* Return the TEMPLATE_PARM_INDEX, not the PARM_DECL. */
|
||||
new_decl = DECL_INITIAL (new_decl);
|
||||
|
Loading…
Reference in New Issue
Block a user