aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-05-11 11:06:26 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-05-11 11:06:26 +0000
commit9c82d7b68ed064386dcfa78d8894c7fb39f4eddb (patch)
tree209eb175f0e2550a51dc83c016a2ceaa4a44eab9 /gcc/cp/decl.c
parent67ac9a9db1b63e93fcdc2d959325c984edd521b8 (diff)
downloadgcc-9c82d7b68ed064386dcfa78d8894c7fb39f4eddb.zip
gcc-9c82d7b68ed064386dcfa78d8894c7fb39f4eddb.tar.gz
gcc-9c82d7b68ed064386dcfa78d8894c7fb39f4eddb.tar.bz2
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
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a5f62fe..9e913f3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
- }
- }
- 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);
+ /* Don't remove the binding. */
+ name = NULL_TREE;
+ }
}
+ /* 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;