mirror of
https://github.com/cc65/cc65.git
synced 2025-02-07 04:31:38 +00:00
Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@1393 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
89b206f046
commit
a6fffdf770
@ -73,7 +73,8 @@ void SwitchStatement (void)
|
||||
unsigned ExitLabel; /* Exit label */
|
||||
unsigned CaseLabel; /* Label for case */
|
||||
unsigned DefaultLabel; /* Label for the default branch */
|
||||
long Val; /* Case label value */
|
||||
long Val; /* Case label value */
|
||||
int HaveBreak = 0; /* True if the last statement had a break */
|
||||
|
||||
|
||||
/* Eat the "switch" token */
|
||||
@ -200,7 +201,7 @@ void SwitchStatement (void)
|
||||
|
||||
/* Parse statements */
|
||||
if (CurTok.Tok != TOK_RCURLY) {
|
||||
Statement (0);
|
||||
HaveBreak = Statement (0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,9 +211,22 @@ void SwitchStatement (void)
|
||||
Warning ("No case labels");
|
||||
|
||||
} else {
|
||||
|
||||
CodeMark SwitchCodeStart;
|
||||
|
||||
/* If the last statement did not have a break, we may have an open
|
||||
* label (maybe from an if or similar). Emitting code and then moving
|
||||
* this code to the top will also move the label to the top which is
|
||||
* wrong. So if the last statement did not have a break (which would
|
||||
* carry the label), add a jump to the exit. If it is useless, the
|
||||
* optimizer will remove it later.
|
||||
*/
|
||||
if (!HaveBreak) {
|
||||
g_jump (ExitLabel);
|
||||
}
|
||||
|
||||
/* Remember the current position */
|
||||
CodeMark SwitchCodeStart = GetCodePos();
|
||||
SwitchCodeStart = GetCodePos();
|
||||
|
||||
/* Generate code */
|
||||
g_switch (Nodes, DefaultLabel? DefaultLabel : ExitLabel, Depth);
|
||||
|
Loading…
x
Reference in New Issue
Block a user