From 21204d3437afb26b4925c388498ba844cc5e9787 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 16 Sep 1999 04:39:52 +0000 Subject: [PATCH] function.c (identify_blocks): Don't shadow a variable in an outer scope. * function.c (identify_blocks): Don't shadow a variable in an outer scope. * integrate.c (integrate_decl_tree): Don't use pushlevel, pushdecl, or poplevel to build up the new BLOCK tree. (expand_inline_function): Likewise. (integrate_parm_decls): Likewise. From-SVN: r29453 --- gcc/ChangeLog | 9 ++++++ gcc/function.c | 8 +++--- gcc/integrate.c | 75 +++++++++++++++++++++++++------------------------ 3 files changed, 51 insertions(+), 41 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6e7c2487c22..40e358e463c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Wed Sep 15 21:37:06 1999 Mark Mitchell + + * function.c (identify_blocks): Don't shadow a variable in an + outer scope. + * integrate.c (integrate_decl_tree): Don't use pushlevel, + pushdecl, or poplevel to build up the new BLOCK tree. + (expand_inline_function): Likewise. + (integrate_parm_decls): Likewise. + Wed Sep 15 21:20:38 1999 Mark Mitchell * c-typeck.c (qualify_type): Merge qualifiers from both types. diff --git a/gcc/function.c b/gcc/function.c index a6c967995c0..81a1ef16170 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -5421,11 +5421,11 @@ identify_blocks (block, insns) { if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_BEG) { - tree block; + tree b; - block = block_vector[current_block_number++]; - NOTE_BLOCK (insn) = block; - block_stack[depth++] = block; + b = block_vector[current_block_number++]; + NOTE_BLOCK (insn) = b; + block_stack[depth++] = b; } if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_BLOCK_END) NOTE_BLOCK (insn) = block_stack[--depth]; diff --git a/gcc/integrate.c b/gcc/integrate.c index 0ffa2b3565b..3c278767ce0 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -65,7 +65,7 @@ static void adjust_copied_decl_tree PROTO((tree)); static void note_modified_parmregs PROTO((rtx, rtx)); static void integrate_parm_decls PROTO((tree, struct inline_remap *, rtvec)); -static void integrate_decl_tree PROTO((tree, int, +static tree integrate_decl_tree PROTO((tree, struct inline_remap *)); static void subst_constants PROTO((rtx *, rtx, struct inline_remap *)); @@ -581,11 +581,6 @@ expand_inline_function (fndecl, parms, target, ignore, type, expand_expr (TREE_VALUE (actual), const0_rtx, TYPE_MODE (TREE_TYPE (TREE_VALUE (actual))), 0); - /* Make a binding contour to keep inline cleanups called at - outer function-scope level from looking like they are shadowing - parameter declarations. */ - pushlevel (0); - /* Expand the function arguments. Do this first so that any new registers get created before we allocate the maps. */ @@ -985,7 +980,6 @@ expand_inline_function (fndecl, parms, target, ignore, type, /* Make a fresh binding contour that we can easily remove. Do this after expanding our arguments so cleanups are properly scoped. */ - pushlevel (0); expand_start_bindings (0); /* Initialize label_map. get_label_from_map will actually make @@ -1281,17 +1275,18 @@ expand_inline_function (fndecl, parms, target, ignore, type, inline_function_decl = fndecl; integrate_parm_decls (DECL_ARGUMENTS (fndecl), map, arg_vector); - integrate_decl_tree (inl_f->original_decl_initial, 0, map); + block = integrate_decl_tree (inl_f->original_decl_initial, map); + BLOCK_ABSTRACT_ORIGIN (block) = (DECL_ABSTRACT_ORIGIN (fndecl) == NULL + ? fndecl : DECL_ABSTRACT_ORIGIN (fndecl)); inline_function_decl = 0; + insert_block (block); /* End the scope containing the copied formal parameter variables - and copied LABEL_DECLs. */ - - expand_end_bindings (getdecls (), 1, 1); - block = poplevel (1, 1, 0); - BLOCK_ABSTRACT_ORIGIN (block) = (DECL_ABSTRACT_ORIGIN (fndecl) == NULL - ? fndecl : DECL_ABSTRACT_ORIGIN (fndecl)); - poplevel (0, 0, 0); + and copied LABEL_DECLs. We pass NULL_TREE for the variables list + here so that expand_end_bindings will not check for unused + variables. That's already been checked for when the inlined + function was defined. */ + expand_end_bindings (NULL_TREE, 1, 1); /* Must mark the line number note after inlined functions as a repeat, so that the test coverage code can avoid counting the call twice. This @@ -1355,7 +1350,7 @@ integrate_parm_decls (args, map, arg_vector) TREE_USED (decl) = 1; /* Prevent warning for shadowing with these. */ DECL_ABSTRACT_ORIGIN (decl) = DECL_ORIGIN (tail); - pushdecl (decl); + DECL_CONTEXT (decl) = current_function_decl; /* Fully instantiate the address with the equivalent form so that the debugging information contains the actual register, instead of the virtual register. Do this by not passing an insn to @@ -1369,24 +1364,22 @@ integrate_parm_decls (args, map, arg_vector) /* Given a BLOCK node LET, push decls and levels so as to construct in the current function a tree of contexts isomorphic to the one that is given. - LEVEL indicates how far down into the BLOCK tree is the node we are - currently traversing. It is always zero except for recursive calls. - MAP, if nonzero, is a pointer to an inline_remap map which indicates how registers used in the DECL_RTL field should be remapped. If it is zero, no mapping is necessary. */ -static void -integrate_decl_tree (let, level, map) +static tree +integrate_decl_tree (let, map) tree let; - int level; struct inline_remap *map; { - tree t, node; + tree t; + tree new_block; + tree *next; + + new_block = make_node (BLOCK); + next = &BLOCK_VARS (new_block); - if (level > 0) - pushlevel (0); - for (t = BLOCK_VARS (let); t; t = TREE_CHAIN (t)) { tree d; @@ -1412,21 +1405,29 @@ integrate_decl_tree (let, level, map) if (DECL_LANG_SPECIFIC (d)) copy_lang_decl (d); - pushdecl (d); - } + /* This new declaration is now in the scope of the function into + which we are inlining the function, not the function being + inlined. */ + DECL_CONTEXT (d) = current_function_decl; - for (t = BLOCK_SUBBLOCKS (let); t; t = TREE_CHAIN (t)) - integrate_decl_tree (t, level + 1, map); + /* Add this declaration to the list of variables in the new + block. */ + *next = d; + next = &TREE_CHAIN (d); + } - if (level > 0) + next = &BLOCK_SUBBLOCKS (new_block); + for (t = BLOCK_SUBBLOCKS (let); t; t = BLOCK_CHAIN (t)) { - node = poplevel (1, 0, 0); - if (node) - { - TREE_USED (node) = TREE_USED (let); - BLOCK_ABSTRACT_ORIGIN (node) = let; - } + *next = integrate_decl_tree (t, map); + BLOCK_SUPERCONTEXT (*next) = new_block; + next = &BLOCK_CHAIN (*next); } + + TREE_USED (new_block) = TREE_USED (let); + BLOCK_ABSTRACT_ORIGIN (new_block) = let; + + return new_block; } /* Create a new copy of an rtx. -- 2.30.2