Commit a8ccdffe by Zack Weinberg Committed by Zack Weinberg

c-decl.c (struct c_scope): Remove keep_if_subblocks field.

	* c-decl.c (struct c_scope): Remove keep_if_subblocks field.
	(keep_next_if_subblocks): Rename next_is_function_body.
	(pushlevel): Adjust commentary.  Always set ->keep on the
	outermost level of a function.  Don't set ->keep_if_subblocks.
	(poplevel): Adjust commentary.  Don't look at ->keep_if_subblocks.
	(store_parm_decls): Adjust to match.
	(finish_function): Adjust to match.
	Call poplevel with all three arguments zero.

From-SVN: r69865
parent 2d29f3a1
2003-07-27 Zack Weinberg <zack@codesourcery.com> 2003-07-27 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (struct c_scope): Remove keep_if_subblocks field.
(keep_next_if_subblocks): Rename next_is_function_body.
(pushlevel): Adjust commentary. Always set ->keep on the
outermost level of a function. Don't set ->keep_if_subblocks.
(poplevel): Adjust commentary. Don't look at ->keep_if_subblocks.
(store_parm_decls): Adjust to match.
(finish_function): Adjust to match.
Call poplevel with all three arguments zero.
* c-decl.c (store_parm_decls_newstyle, store_parm_decls_oldstyle): * c-decl.c (store_parm_decls_newstyle, store_parm_decls_oldstyle):
New functions split out of store_parm_decls. New functions split out of store_parm_decls.
Avoid unnecessary work. Use local variables consistently. Avoid unnecessary work. Use local variables consistently.
......
...@@ -215,9 +215,6 @@ struct c_scope GTY(()) ...@@ -215,9 +215,6 @@ struct c_scope GTY(())
/* True means make a BLOCK for this scope regardless of all else. */ /* True means make a BLOCK for this scope regardless of all else. */
bool keep : 1; bool keep : 1;
/* True means make a BLOCK if this scope has any subblocks. */
bool keep_if_subblocks : 1;
/* List of decls in `names' that have incomplete structure or /* List of decls in `names' that have incomplete structure or
union types. */ union types. */
tree incomplete_list; tree incomplete_list;
...@@ -250,9 +247,11 @@ static GTY(()) struct c_scope *global_scope; ...@@ -250,9 +247,11 @@ static GTY(()) struct c_scope *global_scope;
static bool keep_next_level_flag; static bool keep_next_level_flag;
/* True means make a BLOCK for the next scope pushed if it has subblocks. */ /* True means the next call to pushlevel will be the outermost scope
of a function body, so do not push a new scope, merely cease
expecting parameter decls. */
static bool keep_next_if_subblocks; static bool next_is_function_body;
/* Functions called automatically at the beginning and end of execution. */ /* Functions called automatically at the beginning and end of execution. */
...@@ -408,25 +407,26 @@ in_parm_level_p (void) ...@@ -408,25 +407,26 @@ in_parm_level_p (void)
void void
pushlevel (int dummy ATTRIBUTE_UNUSED) pushlevel (int dummy ATTRIBUTE_UNUSED)
{ {
if (keep_next_if_subblocks) if (next_is_function_body)
{ {
/* This is the transition from the parameters to the top level /* This is the transition from the parameters to the top level
of the function body. These are the same scope of the function body. These are the same scope
(C99 6.2.1p4,6) so we do not push another scope structure. (C99 6.2.1p4,6) so we do not push another scope structure.
next_is_function_body is set only by store_parm_decls, which
in turn is called when and only when we are about to
encounter the opening curly brace for the function body.
XXX Note kludge - keep_next_if_subblocks is set only by The outermost block of a function always gets a BLOCK node,
store_parm_decls, which in turn is called when and only because the debugging output routines expect that each
when we are about to encounter the opening curly brace for function has at least one BLOCK. */
the function body. */
current_scope->parm_flag = false; current_scope->parm_flag = false;
current_scope->function_body = true; current_scope->function_body = true;
current_scope->keep |= keep_next_level_flag; current_scope->keep = true;
current_scope->keep_if_subblocks = true;
current_scope->outer_function = current_function_scope; current_scope->outer_function = current_function_scope;
current_function_scope = current_scope; current_function_scope = current_scope;
keep_next_level_flag = false; keep_next_level_flag = false;
keep_next_if_subblocks = false; next_is_function_body = false;
} }
else else
{ {
...@@ -448,8 +448,8 @@ pushlevel (int dummy ATTRIBUTE_UNUSED) ...@@ -448,8 +448,8 @@ pushlevel (int dummy ATTRIBUTE_UNUSED)
or tags lists are nonempty. or tags lists are nonempty.
If FUNCTIONBODY is nonzero, this level is the body of a function, If FUNCTIONBODY is nonzero, this level is the body of a function,
so create a block as if KEEP were set and also clear out all so create a BLOCK as if KEEP were set, and save that BLOCK in
label names. DECL_INITIAL of current_function_decl.
If REVERSE is nonzero, reverse the order of decls before putting If REVERSE is nonzero, reverse the order of decls before putting
them into the BLOCK. */ them into the BLOCK. */
...@@ -468,9 +468,9 @@ poplevel (int keep, int reverse, int functionbody) ...@@ -468,9 +468,9 @@ poplevel (int keep, int reverse, int functionbody)
if (keep == KEEP_MAYBE) if (keep == KEEP_MAYBE)
keep = (current_scope->names || current_scope->tags); keep = (current_scope->names || current_scope->tags);
keep |= (current_scope->keep || functionbody keep |= current_scope->keep;
|| (subblocks && current_scope->keep_if_subblocks)); keep |= functionbody;
/* We used to warn about unused variables in expand_end_bindings, /* We used to warn about unused variables in expand_end_bindings,
i.e. while generating RTL. But in function-at-a-time mode we may i.e. while generating RTL. But in function-at-a-time mode we may
...@@ -6058,11 +6058,9 @@ store_parm_decls (void) ...@@ -6058,11 +6058,9 @@ store_parm_decls (void)
else else
store_parm_decls_oldstyle (); store_parm_decls_oldstyle ();
/* Make sure the scope for the top of the function body /* The next call to pushlevel will be a function body. */
gets a BLOCK if there are any in the function.
Otherwise, the dbx output is wrong. */
keep_next_if_subblocks = 1; next_is_function_body = true;
/* Write a record describing this function definition to the prototypes /* Write a record describing this function definition to the prototypes
file (if requested). */ file (if requested). */
...@@ -6121,15 +6119,16 @@ finish_function (int nested, int can_defer_p) ...@@ -6121,15 +6119,16 @@ finish_function (int nested, int can_defer_p)
void foo(void) { } void foo(void) { }
(the argument list is irrelevant) the compstmt rule will not (the argument list is irrelevant) the compstmt rule will not
bother calling pushlevel/poplevel, which means we get here with bother calling pushlevel/poplevel, which means we get here with
the scope stack out of sync. Detect this situation by the scope stack out of sync. Detect this situation by noticing
noticing that current_scope is still as that current_scope is still as store_parm_decls left it, and do
store_parm_decls left it, and do a dummy push/pop to get back to a dummy push/pop to get back to consistency.
consistency. Note that the call to pushlevel does not actually Note that the call to pushlevel does not actually push another
push another scope - see there for details. */ scope - see there for details. */
if (current_scope->parm_flag && keep_next_if_subblocks)
if (current_scope->parm_flag && next_is_function_body)
{ {
pushlevel (0); pushlevel (0);
poplevel (1, 0, 0); poplevel (0, 0, 0);
} }
BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl; BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment