name-lookup.h (pushdecl_with_scope): Replace with ...
authorNathan Sidwell <nathan@acm.org>
Mon, 8 May 2017 17:54:55 +0000 (17:54 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 8 May 2017 17:54:55 +0000 (17:54 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/lambda.c
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h

index 05f8fa8364e24573626d5776ae87625bb4658ec5..36ccab65241540a4e35784c67003cc7a118c3a36 100644 (file)
@@ -1,5 +1,13 @@
 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.
 
index 2b20bf9ef3708a64fcd24ff5e669041666d6b19a..fbb8db7e5fc33949162d25f0424ac167cb4823c1 100644 (file)
@@ -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);
     }
index 46ab30f0a76df8f14c68bb87a26ccc9f47de953c..5061597fa3e878e580e77dbfdf4ebe9b8469b10e 100644 (file)
@@ -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);
 }
index 3e6cd9fb74cf5c2eb79919ea72c7e903759d4d29..ed9bfcdaa2604e559647c30b9b097dcf7eb6cf22 100644 (file)
@@ -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.  */
index 30c51046efc708d54d211bc9ba33110db7e9f478..904b14ea53753be67bb9cae20e035e417967cbfc 100644 (file)
@@ -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 *);
 \f
+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);