fixed a bug where early returns could cause the stack to not pop properly

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40465
This commit is contained in:
David Anderson 2007-02-09 04:38:57 +00:00
parent 1c80875ea3
commit 18aabecfd3
3 changed files with 13 additions and 7 deletions

View File

@ -4041,7 +4041,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
* has only a single statement in its body (no compound block) and that * has only a single statement in its body (no compound block) and that
* statement declares a new variable * statement declares a new variable
*/ */
popstacklist(); popstacklist(1);
declared=0; declared=0;
} /* if */ } /* if */
if ((lastst!=tRETURN) && (lastst!=tGOTO)){ if ((lastst!=tRETURN) && (lastst!=tGOTO)){
@ -5503,8 +5503,11 @@ static void compound(int stmt_sameline,int starttok)
if (lastst!=tRETURN) if (lastst!=tRETURN)
destructsymbols(&loctab,nestlevel); destructsymbols(&loctab,nestlevel);
if (lastst!=tRETURN && lastst!=tGOTO) { if (lastst!=tRETURN && lastst!=tGOTO) {
popheaplist(); popheaplist(1);
popstacklist(); popstacklist(1);
} else {
popheaplist(0);
popstacklist(0);
} }
testsymbols(&loctab,nestlevel,FALSE,TRUE); /* look for unused block locals */ testsymbols(&loctab,nestlevel,FALSE,TRUE); /* look for unused block locals */
declared=save_decl; declared=save_decl;
@ -5845,7 +5848,7 @@ static int dofor(void)
* variable in "expr1". * variable in "expr1".
*/ */
destructsymbols(&loctab,nestlevel); destructsymbols(&loctab,nestlevel);
popstacklist(); popstacklist(1);
testsymbols(&loctab,nestlevel,FALSE,TRUE); /* look for unused block locals */ testsymbols(&loctab,nestlevel,FALSE,TRUE); /* look for unused block locals */
declared=save_decl; declared=save_decl;
delete_symbols(&loctab,nestlevel,FALSE,TRUE); delete_symbols(&loctab,nestlevel,FALSE,TRUE);

View File

@ -402,12 +402,15 @@ void genheapfree(int stop_id)
} }
} }
void popstacklist() void popstacklist(int codegen)
{ {
memuse_list_t *oldlist; memuse_list_t *oldlist;
assert(stackusage != NULL); assert(stackusage != NULL);
_stack_genusage(stackusage, 1); if (codegen)
{
_stack_genusage(stackusage, 1);
}
assert(stackusage->head==NULL); assert(stackusage->head==NULL);
oldlist = stackusage->prev; oldlist = stackusage->prev;

View File

@ -95,7 +95,7 @@ int markheap(int type, int size);
* Stack functions * Stack functions
*/ */
void pushstacklist(); void pushstacklist();
void popstacklist(); void popstacklist(int codegen);
int markstack(int type, int size); int markstack(int type, int size);
/** /**
* Generates code to free mem usage, but does not pop the list. * Generates code to free mem usage, but does not pop the list.